Lecture Note 2 - Entity Relationship Diagram
Lecture Note 2 - Entity Relationship Diagram
Unit 2
Entity Relationship
Diagram
Dilini Thamarasee 1
What we discuss Today………
• Entities
• Attributes
• Constraints
• Key Constraints
• Relationships
Entity –Relationship Model Concepts
Ex :- A company
A job
A university
• Weak Entity
– Depends in Strong Entity(Without Strong Entity, Weak Entity can not exist)
• Students
• Classes
• Courses offered
• Entity set
• Simple
• Composite
Color of a CAR
• The value of Age can be determined from the current (today’s) date and the value of
that person’s Birthdate.
• And is said to be derivable from the Birthdate attribute, which is called a stored
attribute
Null and Complex Attributes
Complex Attributes
Null Values Combination of composite and multi-valued
Some particular entity may not have an applicable
attributes
value for an attribute
Previous Degrees of a STUDENT is a
Ex : The Apartment Number
composite multi-valued attribute
• Relationship Set
• One to one
• One to many
• Many to many
Assume that a male can marry to one female and a female can marry to one male.
• It means that for one customer there can have n accounts but for one account, there will
be only one customer.
Many to Many
• When entities in all entity sets can take part more than once in the relationship
• Let us assume that a student can take more than one course and one course can be taken
by many students.
• Primary Key
• Candidate Key
• Composite Key
• Foreign Key
Primary Key
• The Key which is used to uniquely identify the data/records in the table
• Set of keys that is minimal and can uniquely identify any data row in the
table.
Composite Key
• A foreign key is an attribute value in a table that acts as the primary key in
another table.
30 Maths Sandamini
3 Naduni 0412345654 10
Enroll
Stu_No Sub_No
1 10
2 20
3 10
Summary of ER Diagram Notations
Example
• Assumptions