具有不同属性的实体,具体取决于其类型?

时间:2017-02-19 18:26:56

标签: mysql database database-design entity-relationship entity-attribute-value

尝试根据大学项目的给定简报设计ER图。

我很困惑如何处理这个问题:

The items sold in the Food Truck can be of different types: burritos and
beverages. Every item have an ID, a description and a price. Assume that every
Food Truck has infinite stock of each item (i.e. we do not need to track stock levels
in each Food Truck).
All Burritos come with rice, a type of bean, a filling, and a set of optional
toppings. Burritos are priced by size (Mini, Regular, and Grande). Bean types will
vary. Chipp will start by offering two types: black beans and red beans. Burrito
fillings will vary (depending on the season). There are at least 3 types of Burrito
fillings and there should be a vegetarian option.
A Burrito may optionally have toppings: lettuce, tomato, and mild and hot
salsa. Toppings are free, but Chipp will also offer guacamole as a topping for which
there is an extra charge.
The Food Truck also sells different types of refreshing beverages, both
alcoholic and non-alcoholic. All beverages have a size measured in milliliters (just in
case Chipp takes his Food Truck business over the Channel to mainland Europe).

到目前为止,解决方案是通过制作两个具有关系的弱实体,如下所示:

enter image description here

这是处理问题的正确方法吗?

1 个答案:

答案 0 :(得分:1)

Chen的原始符号没有用于子类型的符号。没有弱键的弱实体集产生相同的结果。您的方法在该框架内是正确的。然而,在相同的原始符号中,弱实体集与识别关系(双边钻石)相关联,并且总参与在实体集和关系之间用双线表示,而不是基线指标的(最小,最大)样式。 。这不是坚持使用原始符号的建议,但在这些方面验证您对教科书的答案可能是个好主意。

已经开发了许多不同的扩展符号来表示子类型,并表示不相交,原始符号不能。如果您的课程中包含任何这些内容,我建议您使用它们,因为它们更具表现力。

另请注意鳄梨酱的额外费用要求,您的图表尚未包含。最后,您将price指示为item的派生属性,但我没有看到可以从中计算的任何其他属性。