Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013.

Similar presentations


Presentation on theme: "1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013."— Presentation transcript:

1 1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013

2  The next slides shows an algorithm for converting an E/R diagram to a relational model  The algorithm contains 7 steps: 1. Mapping of regular entity types 2. Mapping of weak entity types 3. Mapping of binary 1:1 relationship types 4. Mapping of binary 1:N relationship types 5. Mapping of binary M:N relationship types 6. Mapping of multivalued attributes 7. Mapping of N-ary relationship types 2

3  The steps will be based upon figure 7.1 from Elmasri chapter 7 3

4  For each regular (strong) entity type create a relation, that includes all simple attributes  Choose one of the attributes as a primary key  See a) in the below figure 4

5  For each weak entity type create a relation, that includes all simple attributes  Include as foreign key the primary key(s) of the relation(s) corresponding to the owner entity type(s)  The primary key is the combination of the foreign key and the partial key of the weak entity  See b) in the below figure 5

6  Include a foreign key in one of the entities taking part of the relationship (pick either end)  Also include any attributes from the relationship  See the below figure – here the entity type Department is chosen (relationship Manages) 6

7  Include a foreign key in the N-side of the relationship  Also include any attributes from the relationship  See the below figure – the relationships Works_for, Controls and Supervision has been implemented) 7

8  Each M:N relationship is converted into a relation with a combined primary key (the primary key from both participating entities)  Also include any attributes from the relationship  See c) in the below figure – the relationship Works_on has been implemented 8

9  Each multivalued attribute is converted into a relation with a combined primary key: the attribute itself + foreign key  For each value a tuple will exist in the new relation  See d) in the below figure – the multivalued attribute Locations has been implemented 9

10  Each N-ary relationship is converted into a relation with a combined primary key (the primary keys from all participating entities)  Also include any attributes from the relationship 10 Figure 3.17 from chapt. 3 in Elmasri Figure 7.4 from chapt. 7 in Elmasri

11  Continue with your solution for Amazon – the E/R diagram  Follow the steps described in the slides and convert the E/R diagram into a relational model  Start today and continue at home, so you can present a solution next time in class – make a Word document with the relational models and upload it to the folder called Relational models for Amazon in studie.rhs.dk 11


Download ppt "1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013."

Similar presentations


Ads by Google