Conversion to Relational Model
(Many-many
relationship)
Create an additional relation for the relationship.
Define in the additional relation the primary keys of
the other relations as well as all attributes of the relationship.
Note: The primary key of the relation modeled from the
relationship needs to be determined after careful inspection
Example:
The above ER diagram is transformed to the following
relational model:
Patient:
pNr |
pName | address
Doctor:
dNr | dName
operation:
pNr | dNr
| date | type | medication | sideEffects
In operation
relationship, date needs to be part of the primary key. The same patient can be
operated by the same doctor on two different dates for example. In that case
values for pNr and dNr become the same in two different tuples. We know that
the value of primary key has to be different in every tuple. So we need to add
date as a part of the primary key for the relation operation in order to make the key unique.