Chapter 3 Entity Relationship
Chapter 3 Entity Relationship
(ER) Model
● Definition of key terms
● Entity and Entity Set
● Attributes
● Definition of an attribute
● Types of attributes
● Relationship and relationship set
● Specialization
● Weak entity
● Constraints of an ER model
● Participation constraints
● Key constraints
● Aggregation
● Exercise One
● Construction of the Entity Relationship Diagram
● Exercise Two
3.3.2 Conversion of the Entity Relationship Diagram into a Relational Model
Definition of key terms
◦Entities
◦Relationships
◦Attributes
Entity:
⚫ One-to-One Relationships
⚫ One-to-Many Relationships
⚫ May to One Relationships
⚫ Many-to-Many Relationships
Relationships: Degree
Binary relationship
Complex relationship –
here ternary
14
Relationships: Multiplicity
label lines to show cardinality and participation
0..1 “zero or one”
0..* “zero or more” optional
1..1 “one”
1..4 “between 1 and 4”
1..* “one or more”
mandatory
1..1 0..*
responsibility [1..*]
dateAllocated
Each manager
Each manages UP TO 3
department is departments
Relationship
managed by (but need not manage
attributes
ONE manager any department)
16
Over to You now!
⚫ See if you can draw an E-R diagram for this scenario –
you are already familiar with this!
◦ “A student registers for up to 8 modules and each module has
many students on it. Record the student ID, their full name and
address and also each module ID and title. We also want to
hold the grade attained by each student for each module”
● Remember to show in your model:
● All primary keys,
● Entities
● Relationships
● Attributes
17
Unary Example with Data
A member of staff may supervise
◄ supervises another staff member, but a staff
member may be supervised by one
0..* or more staff members
Staff
0..1
STAFF
Member Age Supervisor
Grey 43 Black
Black 27
Brown 35 Black
White 33 Brown
18
Ternary Diagrams are Tricky!
“a client at a branch will be “a member of staff will register a
registered by one member of staff” client at one branch”
1..1 1..1
registe
Staff rs Branch
0..*
“a member of staff at a branch may
register many clients”
Client
19
Key Points
⚫ ERM
◦ Entities (strong, weak)
◦ Attributes (simple, composite, etc)
◦ Relationships
● Degree
● Cardinality
● participation
20
ER SYMBOLS
• Rectangles: This Entity Relationship Diagram symbol
represents entity types
• Ellipses : Symbol represent attributes
• Diamonds: This symbol represents relationship types
• Lines: It links attributes to entity types and entity types
with other relationship types
• Primary key: attributes are underlined
• Double Ellipses: Represent multi-valued attributes
⚫
DRAWING AN ER DIAGRAM
EXAMPLE
⚫ In a university, a Student enrolls in Courses. A student
must be assigned to at least one or more Courses. Each
course is taught by a single Professor. To maintain
instruction quality, a Professor can deliver only one
course
Step 1) Entity Identification
we know that,
• A student can be assigned multiple courses
• A Professor can deliver only one course
Step 4) Identify Attributes
⚫ You need to study the files, forms, reports, data currently maintained by the organization to
identify attributes.You can also conduct interviews with various stakeholders to identify
entities. Initially, it’s important to identify the attributes without mapping them to a particular
entity.
⚫ Once, you have a list of Attributes, you need to map them to the identified entities. Ensure an
attribute is to be paired with exactly one entity. If you think an attribute should belong to
more than one entity, use a modifier to make it unique.
⚫ Once the mapping is done, identify the primary Keys. If a unique key is not readily available,
create one.
⚫ For Course Entity, attributes could be Duration, Credits, Assignments, etc. For the sake of ease
we have considered just one attribute.
Step 5) Create the ERD Diagram