2. 2
2
ERD (Entity Relationship Diagram)ERD (Entity Relationship Diagram)
►is modeling tool used to depict graphically ais modeling tool used to depict graphically a
database design before it is actuallydatabase design before it is actually
implemented.implemented.
►It has three basic components, namely, anIt has three basic components, namely, an
EntityEntity,, RelationshipRelationship and anand an AttributeAttribute..
3. 3
3
EntityEntity
► is a real-world object distinguishable or uniqueis a real-world object distinguishable or unique
from other objects.from other objects.
► An entity can be aAn entity can be a concreteconcrete oror physicalphysical objectobject
likelike employeeemployee,, studentstudent,, facultyfaculty,, customercustomer etc. Or itetc. Or it
could also becould also be conceptualconceptual oror abstractabstract likelike
transactiontransaction,, orderorder,, coursecourse,, subjectssubjects etc.etc.
► It can be thought of as a noun likeIt can be thought of as a noun like student,student,
employeeemployee etc.etc.
► It is normally represented by a rectangle shape.It is normally represented by a rectangle shape.
4. 4
4
RelationshipRelationship
►is a way of relating one entity to another.is a way of relating one entity to another.
Entities can therefore participate in aEntities can therefore participate in a
relationship.relationship.
►it is commonly thought as ait is commonly thought as a verbverb connectingconnecting
thethe entitiesentities oror nouns.nouns.
►It is normally represented by a diamondIt is normally represented by a diamond
shape.shape.
5. 5
5
Example of Entities with RelationshipExample of Entities with Relationship
Person belongs Location
Student enrolls Subject(s)
Faculty teaches Subject(s)
7. 7
7
Types of RelationshipTypes of Relationship
Student has ID
Division has Program
Student enrolls Subject
1 1
1 M
MM
One-to-One
One-to-Many
Many-to-Many
8. 8
8
Types of Relationship (CrowTypes of Relationship (Crow
Notation)Notation)
Student has ID
Division has Program
Student enrolls Subject
One-to-One
One-to-Many
Many-to-Many
9. 9
9
AttributeAttribute
► Refers to the characteristic or basic fact or field ofRefers to the characteristic or basic fact or field of
an Entity or Relationship.an Entity or Relationship.
► For example a Student entity could have theFor example a Student entity could have the
followingfollowing attributesattributes ID NumberID Number,, Last Name, FirstLast Name, First
Name, Address, Birth DateName, Address, Birth Date etc.etc.
► A relationship could also have an attribute forA relationship could also have an attribute for
example an Entity nameexample an Entity name StudentStudent enrollsenrolls
(relationship) to a(relationship) to a Course/ProgramCourse/Program. Now, when. Now, when
you enroll you enroll on a certain date so you willyou enroll you enroll on a certain date so you will
have an attribute ofhave an attribute of Enrollment DateEnrollment Date underunder EnrollEnroll
relationship.relationship.
► It is normally represented by aIt is normally represented by a circlecircle..
10. 10
10
Example of AttributesExample of Attributes
Student
ID No.
Lastname Firstname
Gender
Address
Birth date
Email
Note : A Primary Key is Underlined, in this case the ID No.
11. 11
11
Example of AttributesExample of Attributes
Student
ID No.
Lastname Firstname
Gender
Address
Birth date
Email
enrollsProgram
Enrollment
Date
Program ID
Name
Chairperson
has Faculty
ID No.
Lastname
Firstname
12. 12
12
Example of AttributesExample of Attributes
Student
ID No.
Lastname Firstname
Gender
Address
Birth date
Email
enrollsProgram
Enrollment
Date
Program ID
Name
Chairperson
has Faculty
ID No.
Lastname
Firstname
16. 16
16
ERD (More Examples)ERD (More Examples)
Employee
Project
Department
Branch
Manages
Is_a_Member
Participates has
Code
Name
Age
Salary
Start Date
Name
Budget
Release Date
Start Date
Name
Dept ID
City
Address
Editor's Notes
In the examples above, a relationship has always been between occurrences in two different entities. However, it is possible for the same entity to participate in the relationship. This is termed a recursive relationship.
Let us take the example of an employee who is also a manager. But a manager is also an employee, whose details will be held in the employee entity. To implement this a foreign key of the employee's manager number would be held in each employee record.