Topic of Databases
ER Diagram to Relational Schema (aka Translation) Every "strong" entity maps to a Relation 1.1. For each regular entity type, create a relation R 1.2. Create an attribute for each simple attribute of the entity 1.3. Create an attribute for each composite attribute of the entity 1.4. Ignore multivalued attributes, for now 1.5. Skip derived attributes -they will be computed by other means 1.6. Map the Primary Key (PK) of the Entity to the Relation, as a PK Every "weak" entity type maps to a Relation 2.1. Same treatment as strong entity-steps 1.1 to 1.5 2.2. Add an attribute to the new Relation that is a FK to the PK of the strong entity of the 1. 2. identifying relationship (the 'owner' of the weak entity) 2.3. The PK of the weak entity's relation is the owner's PK plus its own partial key Binary N:1 or 1:N relationship 3.1. Identify entity type (S) at N-side of the relationship 3.2. Include primary key of other entity type as foreign key ins 3.3. Include simple attributes of 1:N relationship type as attributes of s Binary 1:1 relationship 4.1. Choose 1 of 3 options 3. 4. 4.1.1. FK Approach Extend the Relation of the Entity that fully participates Included FK to the other Relation 4.1.1.1. 4.1.1.2. 4.1.2. Merged Approach (if both entities fully participate) 4.1.2.1. combine the 2 Entities into one Relation 4.1.3. New Relation (cross-reference) approach 4.1.3.1. 4.1.3.2. 4.1.3.3. Create a new relation Add FK for both relations of the two entities (this is the PK) Add attributes of the relation Binary M:N relationship 5.1. Add a new Relation. The primary 5. CITY key of this relation is the combination of the primary keys of the participating entity types. TOTOTY FIRST 5.2. These are also foreign keys. 5.3. 4.1.3.3. Add attributes of NAME EMPLOTEE LAST the relation. PHONE Multi-valued attributes (MVA) 6.1. Create a new Relation that has an 6. attribute for each simple attribute of the Entity's MVA Add a FK attribute for the Relation of the entity the MVA was attached to 6.2. DNAME