- Learning PostgreSQL 10(Second Edition)
- Salahaldin Juba Andrey Volkov
- 262字
- 2021-07-02 22:42:06
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 which belongs to several entities can be promoted to be an independent entity. The most common rules are listed 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.
推薦閱讀
- Mastering Hadoop 3
- 教父母學會上網
- 機器人創新實訓教程
- 統計策略搜索強化學習方法及應用
- 水晶石精粹:3ds max & ZBrush三維數字靜幀藝術
- Kubernetes for Developers
- SAP Business Intelligence Quick Start Guide
- 教育機器人的風口:全球發展現狀及趨勢
- ESP8266 Robotics Projects
- 電子設備及系統人機工程設計(第2版)
- Drupal高手建站技術手冊
- Learn Microsoft Azure
- 智能+:制造業的智能化轉型
- 新世紀Photoshop CS6中文版應用教程
- 基于Quartus Ⅱ的數字系統Verilog HDL設計實例詳解