The transformation of an ER or EER model into a relational model 1.

11
The transformation of an ER or EER model into a relational model 1 The transformation of an ER or EER model into a relational model

Transcript of The transformation of an ER or EER model into a relational model 1.

Page 1: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

1

The transformation of an ER or EER model into a relational model

Page 2: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

2

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

Page 3: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

3

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

Page 4: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

4

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?

Page 5: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

5

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

Page 6: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

6

ER model relational modelbinary relationships

Activity: how are the participation constraints represented? e.g.:

Student

No

Project

TitleSupervisor

takes

1

0..*

Student

No

Project

TitleSupervisor

takes

0..1

1..*

Page 7: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

7

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

Page 8: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

8

ER model relational modelrecursive relationships

Staff

natIns

IsManaged

0..10..*

staff manager

introduce new entity

Staff

natIns 11

IsAllocatedTo

Allocation

0..*0..1

staff manager

HasAllocation

Page 9: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

9

ER model relational modelrecursive relationships

Activity: what is the difference between (a) and (b)?

Staff(id) … Manager

Staff(id) … Staff(id) Manager

(a)

(b)

Page 10: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

10

EER model relational model

Activity: translate type hierarchies

Page 11: The transformation of an ER or EER model into a relational model 1.

The transformation of an ER or EER model into a relational model

11

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