官术网_书友最值得收藏!

Mapping ER to relations

The rules to map an ER diagram to a set of relations (that is, the database schema) are almost straightforward, but not rigid. One could model an entity as an attribute, and then refine it to a relationship. An attribute that belongs to several entities can be promoted to be an independent entity. The most common rules are as follows (note that only basic rules have been covered, and the list is not exhaustive):

  • Map regular entities to relations. If entities have composite attributes, then include all the subparts of the attributes. Pick one of the key attributes as a primary key.
  • Map weak entities to relations. Include simple attributes and the subparts of the composite attributes. Add a foreign key to reference the identifying entity. The primary key is normally the combination of the partial key and the foreign key.
  • If a relationship has an attribute and the relation cardinality is 1:1, then the relation attribute can be assigned to one of the participating entities.
  • If a relationship has an attribute and the relation cardinality is 1:N, then the relation attribute can be assigned to the participating entity on the N side. 
  • Map many-to-many relationships, also known as N:M, to a new relation. Add foreign keys to reference the participating entities. The primary key is the composition of foreign keys. 
  • Map a multi-valued attribute to a relation. Add a foreign key to reference the entity that owns the multi-valued attribute. The primary key is the composition of the foreign key and the multi-valued attribute.
主站蜘蛛池模板: 清丰县| 香格里拉县| 邹平县| 湖南省| 原平市| 邹平县| 东乡族自治县| 桃源县| 察哈| 呼伦贝尔市| 五台县| 郸城县| 遂平县| 榆林市| 繁峙县| 涟水县| 淮阳县| 孟州市| 蒙山县| 类乌齐县| 扶沟县| 汪清县| 海宁市| 鄄城县| 常山县| 康保县| 平山县| 广宗县| 新巴尔虎右旗| 长垣县| 临西县| 久治县| 攀枝花市| 丽江市| 宜阳县| 溧水县| 玉田县| 三亚市| 丹阳市| 舞阳县| 普格县|