110 likes | 522 Views
The transformation of an ER or EER model into a relational model. Transforming an ER model into a relational model. ER model - not supported directly by any DBMS needs to be translated into a model that is supported by DBMSs transformation / mapping process non-deterministic
E N D
The transformation of an ER or EER model into a relational model
Transforming an ER model into a relational model • ER model - not supported directly by any DBMS • needs to be translated into a model that is supported by DBMSs • transformation / mapping process • non-deterministic • certain ER configurations can be expressed in more than one way in the relational model • certain aspects related to the relational model are not specified in the ER model • transformation guidelines (rules) • some approaches propose two phases • ER model to translatable ER model (this can be optional/implicit) • translatable ER model into relational model
ER model relational modelentities • strong entity base relation • simple, single valued base attributes - ok • composite - flatten • multi-valued - introduce entity and link with 1:M relationship • calculated attributes - eliminate • weak entity base relation • primary key contains part of the strong entity primary key • foreign key referencing the base relation corresponding to the strong entity • how is the “weak entity” information modelled in the relational model? • cannot have SET NULL or SET DEFAULT
ER model relational modelbinary relationships • one to one • one partial and one total participation foreign key from the base relation corresponding to the entity with partial participation to the one with total participation • two partial participations one foreign key from one base relation to another • two total participations as above or merge • why would you want to keep them separate? • one to many • FK from the “many entity” relationship to the “one entity” relationship • does it matter whether the “many entity” is weak or strong?
ER model relational modelbinary relationships • many to many • no attributes • relationship relation consisting of two foreign keys, one for each relation corresponding to the two entities involved • the two foreign keys primary key • alternatively, change the ER model • with attributes • transform relationship into entity • implement the two resulting 1:M relationships
ER model relational modelbinary relationships • Activity: how are the participation constraints represented? e.g.: Student Student No No 0..1 1 takes takes 1..* 0..* Project Project Title Supervisor Title Supervisor
ER model relational modelcomplex relationships • with attributes • transform into entity • no attributes • relationship relation consisting of foreign keys, one for each relation corresponding to the entities involved • alternatively, transform complex relationship into binary relationships
ER model relational modelrecursive relationships • introduce new entity Staff Staff staff manager staff manager 1 1 0..1 0..* natIns natIns HasAllocation IsAllocatedTo Allocation 0..1 0..* IsManaged
ER model relational modelrecursive relationships • Activity: what is the difference between (a) and (b)? (a) (b)
EER model relational model • Activity: translate type hierarchies
Conclusion • conceptual model logical model • is the resulting logical model the model that is going to be implemented? • logical design expressing further constraints on data • functional dependencies • multi-valued dependencies • join dependencies • if they are not correctly expressed - the logical model can lead to update anomalies