N01 Erd
N01 Erd
N01 Erd
2023
5 Weak Entity
Strong Entity
Weak entity and Identifying Relationship
Weak Entity connected Weak Entity
Update Methodology
Mapping Weak Entity to Rational Database
6 Extensions with Binary Relationships
Attributes of Relationship
M:N Relationship
More Entity and Relationship
7 Recursive Relationship
Structural Constraints
Multiple Relationship
• One-to-One (1:1) one entity is associated with one other entity and vice versa
• Many-to-One (M:1) many entity are associated with one another entity
• One-to-Many (1:M)
• Many-to-Many (M:N)
• Participation (Full/Partial)
Full (doube lines): All entity associated with another entity
Partial (single line): Not every entity associated with another entity
1(full):1 Relationship
M(full):1 Relationship
1(partial):1 Relationship
M(partial):1 Relationship
1(full):M Relationship
M(full):N Relationship
1(partial):M Relationship
M(partial):N Relationship
• Step 1. Select one primary entity from the database requirements description and
show attributes to be recorded for that entity. Label key if appropriate, and show
some sample data.
• Step 2. Use structured English for entities, attributes, and keys to describe the
database.
• Step 3. Examine attributes in the primary entity (possibly with user assistance)
to find out if information about one of the attributes is to be recorded.
• Step 3a. If information about an attribute is needed, then make the attribute an
entity, and then
• Step 3b. Define the relationship back to the original entity.
• Step 4. If another entity is appropriate, draw the second entity with its attributes.
Repeat step 2 to see if this entity should be further split into more entities.
Consider a model for a simplified airport where PASSENGERS and FLIGHTS are to
be recorded. Suppose the attributes of PASSENGERS are name, luggage_pieces
and frequent_flier_no. Suppose the attributes for FLIGHT are flight_no,
destination, arrive_time and depart_time. Draw the ER diagram.
ER Design Methodology:
Step 1. Select one primary entity from the database requirements description and
show attributes to be recorded for that entity. Label keys if appropriate and show some
sample data.
Suppose we choose PASSENGERS as our primary entity. PASSENGERS has the
following attributes: frequent_flier_no, name [frst, middle, last], luggage_pieces.
Step 2. Use structured English for entities, attributes, and keys to describe the elicited
database.
Step 3. Examine attributes in the primary entity (possibly with user assistance) to find
out if information about one of the attributes is to be recorded.
Step 6. State the exact nature of the relationships in structured English from all sides,
such as, if a relationship is A:B::1:M, then there is a relationship from A(1) to B(M)
and from B(M) back to A(1).
Step 7. Present the “as designed” database to the user complete with the English for
entities, attributes, keys, and relationships. Refine the diagram, as necessary.
Step 8. Show some sample data.
Mapping rule 1: Mapping strong entities. Develop a new table (relation) for each
strong entity and make the indicated key of the strong entity the primary key of the
table. If more than one candidate key is indicated on the ER diagram, choose one for
the primary key. Call this table, TABLE1.
Mapping rule 2: Mapping atomic attributes. For entities with atomic attributes, map
the entities to a table and form columns for each atomic attribute. Here we’d map the
atomic attributes associated with TABLE1 into it.
Mapping rule 4: Mapping multivalued attributes. Form a separate table for the
multivalued attribute. Record a row for each value of the multivalued attribute
together with the key from the original table. The key of the new table will be the
concatenation of the multivalued attribute plus the key of the owner entity. Remove
the multivalued attribute from the original table.
Mapping rule 5: Mapping binary M:N relationships. For each M:N relationship,
create a new table (relation) with the primary keys of each of the two entities (owner
entities) related in the M:N relationship. The primary key of this new table will be the
concatenated keys of the owner entities. Include any attributes the M:N relationship
may have in this new table.
Mapping rule 6: Mapping a binary 1:1 relationship when one side of the relationship
has full participation and the other has partial participation. When one of the sides of
the relationship has full participation and the other has partial participation, then store
the primary key of the side with the partial participation constraint on the side with
the full participation constraint as a foreign key. Include any attributes on the
relationship on the same side to which the key was added.
AUTOMOBILE(vehicle_id, make,
body_style, color, year,
student_number)
STUDENT(student_number,
name.first, name.mid,
name.last, address)
Mapping rule 7: Mapping a binary 1:1 relationship when both sides have partial
participation constraints.
When both sides have partial participation constraints in a binary 1:1 relationship, the
relationships can be mapped in one of two ways.
Mapping rule 7A: Select either one of the relations to store the key of the other.
Mapping rule 7B:. Depending on the semantics of the situation, you can create a
new relation to house the relationship to contain the key of the two related entities.
Mapping rule 8: Mapping a binary 1:1 relationship when both sides have full
participation constraints. Use the semantics of the relationship to select which of the
relations should contain the key of the other. If this choice is unclear, then use
mapping rule 7B.
Mapping rule 9: Mapping binary 1:N relationships when the N side has full
participation. Include the key of the entity on the 1 side of the relationship as a foreign
key on the N side.
Mapping rule 10: Mapping binary 1:N relationships when the N side has partial
participation. This situation would be handled just like a binary M:N relationship with
a separate table for the relationship. The key of the new relation would consist of a
concatenation of the keys of the related entities. Include any attributes on the
relationship on this new table.
Strong entities almost always have a unique identifer that is a subset of all the
attributes.
e.g.
Sample data:
Nguyễn Văn Diêu 5. Weak Entity :: Weak entity and Identifying Relationship 49/80
Weak Entity
Nguyễn Văn Diêu 5. Weak Entity :: Weak entity and Identifying Relationship 50/80
Weak Entity - Weak Entity
Nguyễn Văn Diêu 5. Weak Entity :: Weak Entity connected Weak Entity 51/80
Methodology (+ Weak Entity)
Step 3. Examine attributes in the primary entity (possibly with user assistance) to find
out if information about one of the attributes is to be recorded.
Step 3a. If information about an attribute is needed, then make the attribute an
entity, and then
Step 3b. Define the relationship back to the original entity.
So, we add
Step 3c. If the new entity depends entirely on another entity for its existence, then
draw the entity as weak (double boxed) and show the connection to the identifying
entity as a double diamond. The participation of the weak entity in the relationship is
full. Dash underline the partial key identifier(s) in the weak entity.
Step 4. If another entity is appropriate, draw the second entity with its attributes.
Repeat step 2 to see if any attributes should be further split into more entities.
Step 4a. If the additional entity or entities do not have candidate keys, then draw
them as weak entities (as explained in step 3c) and show the connection to an
identifying entity. The participation of the weak entity in the relationship is full or
mandatory. Dash or dot underline the partial key identifier(s) in the weak entity.
Mapping Rule 11: Mapping weak entities. Develop a new table (relation) for each
weak entity. As is the case with the strong entity, include any atomic attributes from
the weak entity in the table.
If there is a composite attribute, include only the atomic parts of the composite
attribute and be sure to qualify the atomic parts in order not to lose information. To
relate the weak entity to its owner, include the primary key of the owner entity in the
weak relation. The primary key of the weak relation will be the partial key of the weak
entity concatenated to the primary key of the owner entity.
If a weak entity owns other weak entities, then the weak entity connected to the strong
entity must be mapped first. The key of the weak owner-entity has to be defined
before the “weaker” entity (the one furthest from the strong entity) can be mapped.
Nguyễn Văn Diêu 5. Weak Entity :: Mapping Weak Entity to Rational Database 54/80
Mapping
EMPLOYEE(employee_id, fname,
minit, lname)
DEPENDENT(employee_id, dname,
insurance, birth_date)
HOBBY(employee_id, dname, type,
year_involved)
Nguyễn Văn Diêu 5. Weak Entity :: Mapping Weak Entity to Rational Database 55/80
Attributes of Relationship
Nguyễn Văn Diêu 6. Extensions with Binary Relationships :: Attributes of Relationship 56/80
Change M:N Relationship
Change to:
• Intersection Weak Entity:
STUDENT-COURSE
• Attribute: grade
• Key: student_ID +
course_ID
• Relationship 1: Rel1
• Relationship 2: Rel2
Nguyễn Văn Diêu 6. Extensions with Binary Relationships :: M:N Relationship 57/80
More Entity and Relationship
Update Methodology:
Step 4. If another entity is appropriate, draw the second entity with its attributes.
Repeat step 2 to see if this entity should be further split into more entities.
Step 5. Connect entities with relationships (one or more) if relationships exist.
Nguyễn Văn Diêu 6. Extensions with Binary Relationships :: More Entity and Relationship 58/80
More Entity and Relationship
Te relationship between
INSTRUCTOR and COURSE is
teach; instructors teach many
courses, and a course is taught by
an instructor.
We add relationship teach.
Nguyễn Văn Diêu 6. Extensions with Binary Relationships :: More Entity and Relationship 59/80
More Entity and Relationship
Nguyễn Văn Diêu 6. Extensions with Binary Relationships :: More Entity and Relationship 60/80
Recursive Relationship
e.g.
e.g.
e.g.
e.g.
Mapping Rule 12: Mapping 1:N recursive relationships. Re-include the primary key of
the table with the recursive relationship in the same table, giving it some other role
name.
e.g.
PERSONNELL(emplye_id, fname, mname, lname, super_id)
Mapping Rule 13: Mapping M:N recursive relationships. Create a separate table for
the relationship (as in mapping rule 5).
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Generalization and Specialization 68/80
Generalization or Specialization
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Generalization and Specialization 69/80
Generalization or Specialization
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Generalization and Specialization 70/80
Subclasses of Subclasses
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Subclasses of Subclasses 71/80
Subclasses of Subclasses
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Subclasses of Subclasses 72/80
Mapping rules to Relation
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Mapping rules 73/80
Union Types
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Union Types 74/80
Union Types
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Union Types 75/80
Union Types
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Union Types 76/80
Union Types
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Union Types 77/80
Union Types
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Union Types 78/80
Union Types
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Union Types 79/80
Mapping rules to Relation
Nguyễn Văn Diêu 9. Enhanced EntityRelationship (EER) Model :: Mapping rules 80/80