1 Converting ER model Into Relational Table Tarek El-Shishtawy Professor Ass. Of Computer...
-
Upload
tracey-wilson -
Category
Documents
-
view
217 -
download
3
Transcript of 1 Converting ER model Into Relational Table Tarek El-Shishtawy Professor Ass. Of Computer...
11
Converting ER Converting ER model Into model Into
Relational TableRelational Table
Tarek El-ShishtawyTarek El-ShishtawyProfessor Ass. Of Computer EngineeringProfessor Ass. Of Computer Engineering
22
Mapping Regular EntitiesMapping Regular Entities
Each regular entity type in an ER diagram Each regular entity type in an ER diagram is transformed into a relation. The name is transformed into a relation. The name given to the relation is generally the same given to the relation is generally the same as the entity type.as the entity type.
Each simple attribute of the entity type Each simple attribute of the entity type becomes an attribute of the relation. – The becomes an attribute of the relation. – The identifier of the entity type becomes the identifier of the entity type becomes the primary key of the corresponding relation.primary key of the corresponding relation.
33
ExampleExample
Entity name = Name of the relation or table.Entity name = Name of the relation or table. Attributes of ER diagram=Column name of the table.Attributes of ER diagram=Column name of the table.
Table PLAYERPlayer Name Nation Position Number of wonRoger Federer Switzerland 1 5 Roddick USA 2 4
44
Example using Oracle designer Example using Oracle designer notationsnotations
55
Converting Composite AttributeConverting Composite Attribute
only the simple component attributes of the composite only the simple component attributes of the composite attribute are included in the relation. attribute are included in the relation.
CUSTOMER
Customer-IDNameStreetCityStateZip
66
Mapping Multivalued Attributes in ER Mapping Multivalued Attributes in ER
One way to map a multivalued attribute is One way to map a multivalued attribute is to create two tables.to create two tables.
77
Converting “Weak Entities”Converting “Weak Entities”
m1
88
Converting “Weak Entities” Converting “Weak Entities”
For each weak entity type, create a new relationFor each weak entity type, create a new relation All of the simple attributes as attributes of the All of the simple attributes as attributes of the
relation. relation. The primary key of the identifying relation as a The primary key of the identifying relation as a
foreign key attribute to this new relation. foreign key attribute to this new relation. The primary key of the new relation is the The primary key of the new relation is the
combination of the primary key of the identifying combination of the primary key of the identifying and the partial identifier of the weak entity type. and the partial identifier of the weak entity type.
In this example DEPENDENT is weak entity.In this example DEPENDENT is weak entity.
99
Converting “Weak Entities”Converting “Weak Entities”
1010
Converting Binary Relationship Converting Binary Relationship Mapping one-to-Many RelationshipMapping one-to-Many Relationship
One customer can give many orders.
m
1
1111
Mapping one-to-Many RelationshipMapping one-to-Many Relationship
1212
Using Oracle Designer notationUsing Oracle Designer notation
1313
Binary one-to-one relationship Binary one-to-one relationship
Can be viewed as a special case of one-Can be viewed as a special case of one-to-many relationships. to-many relationships.
First, two relations are created, one for First, two relations are created, one for each of the participating entity types. each of the participating entity types.
Second, the primary key of one of the Second, the primary key of one of the relations is included as a foreign key in the relations is included as a foreign key in the other relation.other relation.
Example Parking place and employee Example Parking place and employee
1414
Many to Many relationshipsMany to Many relationships
M-M Needs an intersection tableM-M Needs an intersection tableNote: Pre-requests requires more additional Note: Pre-requests requires more additional
tabletable
1515
Many to Many relationshipsMany to Many relationships
EM P_ ID NAM E OTHER S
CR S_ ID T IT LE S
CR S_ ID PR EREQ
EM P_ ID CR S_ ID
EM PLOYEE
COUR SE
EM PLOYEE _COUR SE
1616
Mapping Associative Entity to TablesMapping Associative Entity to TablesWithout IdentifierWithout Identifier
1717
Mapping Associative Entity to TablesMapping Associative Entity to Tables
1818
Mapping Associative Entity to TablesMapping Associative Entity to TablesWith IdentifierWith Identifier
1919
Mapping Associative Entity to TablesMapping Associative Entity to TablesWith IdentifierWith Identifier
2020
Converting Unary RelationshipConverting 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
2121
Converting Unary RelationshipConverting Unary Relationship
2222
Converting Ternary RelationshipConverting Ternary Relationship
2323
Converting Ternary RelationshipConverting Ternary Relationship