230 likes | 260 Views
Learn how to convert ER model into relational tables using Oracle Designer notations for regular, composite, weak entities, and one-to-many relationships. Includes examples and guidelines.
E N D
Converting ER model Into Relational Table Tarek El-Shishtawy Professor Ass. Of Computer Engineering
Mapping Regular Entities • Each regular entity type in an ER diagram is transformed into a relation. The name given to the relation is generally the same as the entity type. • Each simple attribute of the entity type becomes an attribute of the relation. – The identifier of the entity type becomes the primary key of the corresponding relation.
Example • Entity name = Name of the relation or table. • Attributes of ER diagram=Column name of the table. Table PLAYER Player Name Nation Position Number of won Roger Federer Switzerland 1 5 Roddick USA 2 4
Converting Composite Attribute • only the simple component attributes of the composite attribute are included in the relation. CUSTOMER
Mapping Multivalued Attributes in ER • One way to map a multivalued attribute is to create two tables.
Converting “Weak Entities” • For each weak entity type, create a new relation • All of the simple attributes as attributes of the relation. • The primary key of the identifying relation as a foreign key attribute to this new relation. • The primary key of the new relation is the combination of the primary key of the identifying and the partial identifier of the weak entity type. • In this example DEPENDENT is weak entity.
Converting Binary Relationship Mapping one-to-Many Relationship 1 m One customer can give many orders.
Binary one-to-one relationship • Can be viewed as a special case of one-to-many relationships. • First, two relations are created, one for each of the participating entity types. • Second, the primary key of one of the relations is included as a foreign key in the other relation. • Example Parking place and employee
Many to Many relationships M-M Needs an intersection tableNote: Pre-requests requires more additional table
Converting Unary Relationship Each employee has exactly one manager. A given employee may manage zero to many employees. The foreign key in the relation is named Manager-ID