物理数据模型中的枚举 class
Enumeration class in physical data model
我已经为我的外卖业务创建了我的数据库的 UML class 图。我在那里使用 3 <<Enumeration>>
classes。现在我想为该数据库创建一个物理数据模型,这样我就可以继续构建基于该物理数据模型的实际 MySQL 数据库。
问题是我不知道如何在物理数据模型中绘制 <<Enumeration>>
classes 的等价物。他们看起来像其他人吗 table?
下面你可以看到我的 UML class 图的一部分,其中包含 3 <<Enumeration>>
classes.
!!!更新
早在 2009 年 通过使用名为 Toad Data Modeler 的数据建模软件您可以这样做:
Order
-----------------------------------
PK order_id : integer
datetime_order_taken : date
datetime_order_completed : date
total_order_price : long
order_details : string
payment_method : enum('cash','credit card')
payment_status : enum('paid','waiting for delivery','not paid')
etc. ...
现在,现代数据建模工具不再允许您为字段指定枚举类型。相反,您创建一个查找(参考)table,其中包含该字段的所有可能值,并使用字段的 table 创建一个 link - 如下所示:
Order
-----------------------------------
PK order_id : integer
FK payment_method_code : integer
etc. ...
Ref_Payment_Method
-----------------------------------
PK payment_method_code : integer
payment_method_decription : varchar(30)
然后你需要把所有可能的Payment methods填入Ref_Payment_Method table(所谓的lookup/reference table)
Ref_Payment_Method
=====================================================
payment_method_code | payment_method_decription
-----------------------------------------------------
1 | cash
2 | credit card
我已经为我的外卖业务创建了我的数据库的 UML class 图。我在那里使用 3 <<Enumeration>>
classes。现在我想为该数据库创建一个物理数据模型,这样我就可以继续构建基于该物理数据模型的实际 MySQL 数据库。
问题是我不知道如何在物理数据模型中绘制 <<Enumeration>>
classes 的等价物。他们看起来像其他人吗 table?
下面你可以看到我的 UML class 图的一部分,其中包含 3 <<Enumeration>>
classes.
!!!更新
早在 2009 年 通过使用名为 Toad Data Modeler 的数据建模软件您可以这样做:
Order
-----------------------------------
PK order_id : integer
datetime_order_taken : date
datetime_order_completed : date
total_order_price : long
order_details : string
payment_method : enum('cash','credit card')
payment_status : enum('paid','waiting for delivery','not paid')
etc. ...
现在,现代数据建模工具不再允许您为字段指定枚举类型。相反,您创建一个查找(参考)table,其中包含该字段的所有可能值,并使用字段的 table 创建一个 link - 如下所示:
Order
-----------------------------------
PK order_id : integer
FK payment_method_code : integer
etc. ...
Ref_Payment_Method
-----------------------------------
PK payment_method_code : integer
payment_method_decription : varchar(30)
然后你需要把所有可能的Payment methods填入Ref_Payment_Method table(所谓的lookup/reference table)
Ref_Payment_Method
=====================================================
payment_method_code | payment_method_decription
-----------------------------------------------------
1 | cash
2 | credit card