Entity-Relationship Modeling
COMP313 – Database Management System
COMPANY LOGO
a technique used to analyze & model the data in organizations using an Entity Relationship (E-R) diagram.
COMPANY LOGO
E-R MODEL
COMPANY LOGO
Widely used conceptual level data model proposed by Peter P. Chen in 1970s
A database can be modeled as: a collection of entities, relationship among entities.
COMPANY LOGO
CONCEPTS OF E-R MODEL
COMPANY LOGO
Entity types
Attributes
Relationship types
COMPANY LOGO
ENTITY TYPE
COMPANY LOGO
Entity
An object that exists and is distinguishable from other objects. Examples: specific person, company, event,
plantAn instance of an entity is an object
in the class represented by the entity Examples: Course and Room are entities.
Their instances are particular courses (eg CSC340F) and rooms (eg MS2172)
COMPANY LOGO
Entity Type
Sometimes called Entity SetCollection of entities all having the
same properties. Examples:
• Student entity set – collection of all student entities.
• Course entity set – collection of all course entities.
COMPANY LOGO
ATTRIBUTES
COMPANY LOGO
Attributes
Entities have attributesEach entity is described by a set of
attributes/properties. Examples:
• Student entity– StudName – name of the student.– RollNumber – the roll number of the student.– Sex – the gender of the student etc.
• All entities in an Entity set/type have the same set of attributes.
COMPANY LOGO
Types of Attributes
Simple Attributes having atomic or indivisible values. examples:
• Dept – a string• PhoneNumber – an eight digit number
COMPANY LOGO
Types of Attributes
Composite Attributes having several components in the value. example:
• Qualification with components (DegreeName, Year, UniversityName)
COMPANY LOGO
Types of Attributes
Derived Attributes Attribute value is dependent on some other
attribute. example:
• Age depends on DateOfBirth. So age is a derived attribute.
COMPANY LOGO
Types of Attributes
Single-valued having only one value rather than a set of
values. Example:
• PlaceOfBirth – single string value.
COMPANY LOGO
Types of Attributes
Multi-valued having a set of values rather than a single
value. Examples:
• CoursesEnrolled attribute for student• EmailAddress attribute for student• PreviousDegree attribute for student.
COMPANY LOGO
Types of Attributes
Attributes can be: simple single-valued, simple multi-valued, composite single-valued or composite multi-
valued.
COMPANY LOGO
Diagrammatic Notation for Entities
entity rectangle
attribute ellipse connected to rectangle
multi-valued attribute double ellipse
composite attribute ellipse connected to ellipse
derived attribute dashed ellipse
COMPANY LOGO
Diagrammatic Notation for Entities
COMPANY LOGO
Key Attributes
Key an attribute or a collection of attributes whose
value(s) uniquely identify an entity in the entity set.
Examples:• RollNumber - Key for Student entity set• EmpID - Key for Faculty entity set• HostelName, RoomNo - Key for Student entity set
(assuming that each student gets to stay in a single room)
COMPANY LOGO
Key Attributes
The different types of KEY attribute are: Primary Key
• Composite Primary Key
Foreign Key
COMPANY LOGO
Key Attributes
Primary Key: One attribute whose value can uniquely
identify a complete record (one row of data) within an entity.
COMPANY LOGO
Key Attributes
Composite Primary Key A primary key that consists of two or more
attribute within an entity. When two or more columns are used as a
primary key, they are called a composite key.
COMPANY LOGO
Key Attributes
Foreign Key A copy of a primary key that exists in another
entity for the purpose of forming a relationship between the entities involved.
COMPANY LOGO
Entity Categories
Strong Entity Type Entity type that is not existence-
dependent on some other entity type.
Weak Entity Type any entity that depends on another
entity for its existence.
COMPANY LOGO
Entity Categories
Strong Entity Type Entity type that is not existence-
dependent on some other entity type.
Weak Entity Type any entity that depends on another
entity for its existence.
COMPANY LOGO
Examples:
COMPANY LOGO
Relationships
When two or more entities are associated with each other, we have an instance of a Relationship.
Example: Student Ramesh enrolls in Discrete
Mathematics course Relationship enrolls has Student and Course
as the participating entity sets.
COMPANY LOGO
Examples:
COMPANY LOGO
Degree of Relationship
Set of meaningful associations among entity types.
Degree of a Relationship Number of participating entities in
relationship.Relationship of degree
two is binary three is ternary four is quaternary.
COMPANY LOGO
Degree of Relationship
Binary Relationship
COMPANY LOGO
Degree of Relationship
Ternary Relationship
COMPANY LOGO
Degree of Relationship
Quaternary Relationship
COMPANY LOGO
Binary Relationships and Cardinality Ratio
The most common degree for relationships is binary.
The number of entities from E2 that an entity from E1 can possibly be associated thru R (and vice-versa) determines the cardinality ratio of R.
COMPANY LOGO
Binary Relationships and Cardinality Ratio
Cardinality Describes maximum number of possible
relationship occurrences for an entity participating in a given relationship type.
Four possibilities are usually specified: one-to-one (1:1) one-to-many (1:N) many-to-one (N:1) many-to-many (M:N)
COMPANY LOGO
Binary Relationships and Cardinality Ratio
one-to-one (1:1)
COMPANY LOGO
Binary Relationships and Cardinality Ratio
one-to-many (1:N) / many-to-one (N:1)
COMPANY LOGO
Binary Relationships and Cardinality Ratio
many-to-many (N:M)
COMPANY LOGO
ERD Development Process
Identify the entitiesDetermine the attributes for each
entitySelect the primary key for each entityEstablish the relationships between
the entitiesDraw an entity modelTest the relationships and the keys
COMPANY LOGO
ERD Development Process –Example
In an educational institute, there are several departments and students belong to one of them. Each department has a unique department number, a name, a location, phone number and is headed by a professor. Professors have a unique employee Id, name, phone number.
We like to keep track of the following details regarding students: name, unique roll number, sex, phone number, date of birth, age and one or more email addresses. Students have a local address consisting of the hostel name and the room number. They also have home address consisting of house number, street, city and PIN. It is assumed that all students reside in the hostels.
COMPANY LOGO
ERD Development Process – Example
A course taught in a semester of the year is called a section. There can be several sections of the same course in a semester; these are identified by the section number.
Each section is taught by a different professor and has its own timings and a room to meet. Students enroll for several sections in a semester. Each course has a name, number of credits and the department that offers it. A course may have other courses as pre-requisites i.e, courses to be completed before it can be enrolled in.
COMPANY LOGO
ERD Development Process – Example
Professors also undertake research projects. These are sponsored by funding agencies and have a specific start date, end date and amount of money given. More than one professor can be involved in a project. Also a professor may be simultaneously working on several projects. A project has a unique projectId.
COMPANY LOGO
Identify the entities
StudentDepartmentCourseProfessorProjectSection
COMPANY LOGO
Determine the attributes for each entityand Select the primary key for each entity
Student
COMPANY LOGO
Determine the attributes for each entityand Select the primary key for each entity
Department and Course
COMPANY LOGO
Determine the attributes for each entityand Select the primary key for each entity
Professor, Project and Sections
COMPANY LOGO
Establish the relationships between the entities and Draw an entity model
COMPANY LOGO
END OF PRESENTATIONThank you…
COMPANY LOGO
Conference centre booking system
The centre contains a number of facilities which may be required by clients making bookings as follows:
A. There are 400 bedrooms for clients who will be resident during the Course or conference.
B. A maximum of 250 catered people can be handled at any one time.
C. Six main lecture theatres providing seating for 200 people.
D. Twenty seminar rooms each able to accommodate 25 people.
E. Video conference facilities. The video conference facilities consist of four separate
Video conference networks. Each video conference network has a large screen based
in one of the main lecture theatres, along with 3 satellite screens each of which is based in one of the seminar rooms.
Draw an entity relationship diagram for the case, stating any assumptions you deem necessary.