Top Banner
Entity-Relationship Modeling COMP313 – Database Management System
49
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Entity Relationship Modeling

Entity-Relationship Modeling

COMP313 – Database Management System

Page 2: Entity Relationship Modeling

COMPANY LOGO

a technique used to analyze & model the data in organizations using an Entity Relationship (E-R) diagram.

Page 3: Entity Relationship Modeling

COMPANY LOGO

E-R MODEL

Page 4: Entity Relationship Modeling

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.

Page 5: Entity Relationship Modeling

COMPANY LOGO

CONCEPTS OF E-R MODEL

Page 6: Entity Relationship Modeling

COMPANY LOGO

Entity types

Attributes

Relationship types

Page 7: Entity Relationship Modeling

COMPANY LOGO

ENTITY TYPE

Page 8: Entity Relationship Modeling

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)

Page 9: Entity Relationship Modeling

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.

Page 10: Entity Relationship Modeling

COMPANY LOGO

ATTRIBUTES

Page 11: Entity Relationship Modeling

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.

Page 12: Entity Relationship Modeling

COMPANY LOGO

Types of Attributes

Simple Attributes having atomic or indivisible values. examples:

• Dept – a string• PhoneNumber – an eight digit number

Page 13: Entity Relationship Modeling

COMPANY LOGO

Types of Attributes

Composite Attributes having several components in the value. example:

• Qualification with components (DegreeName, Year, UniversityName)

Page 14: Entity Relationship Modeling

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.

Page 15: Entity Relationship Modeling

COMPANY LOGO

Types of Attributes

Single-valued having only one value rather than a set of

values. Example:

• PlaceOfBirth – single string value.

Page 16: Entity Relationship Modeling

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.

Page 17: Entity Relationship Modeling

COMPANY LOGO

Types of Attributes

Attributes can be: simple single-valued, simple multi-valued, composite single-valued or composite multi-

valued.

Page 18: Entity Relationship Modeling

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

Page 19: Entity Relationship Modeling

COMPANY LOGO

Diagrammatic Notation for Entities

Page 20: Entity Relationship Modeling

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)

Page 21: Entity Relationship Modeling

COMPANY LOGO

Key Attributes

The different types of KEY attribute are: Primary Key

• Composite Primary Key

Foreign Key

Page 22: Entity Relationship Modeling

COMPANY LOGO

Key Attributes

Primary Key: One attribute whose value can uniquely

identify a complete record (one row of data) within an entity.

Page 23: Entity Relationship Modeling

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. 

Page 24: Entity Relationship Modeling

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.

Page 25: Entity Relationship Modeling

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.

Page 26: Entity Relationship Modeling

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.

Page 27: Entity Relationship Modeling

COMPANY LOGO

Examples:

Page 28: Entity Relationship Modeling

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.

Page 29: Entity Relationship Modeling

COMPANY LOGO

Examples:

Page 30: Entity Relationship Modeling

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.

Page 31: Entity Relationship Modeling

COMPANY LOGO

Degree of Relationship

Binary Relationship

Page 32: Entity Relationship Modeling

COMPANY LOGO

Degree of Relationship

Ternary Relationship

Page 33: Entity Relationship Modeling

COMPANY LOGO

Degree of Relationship

Quaternary Relationship

Page 34: Entity Relationship Modeling

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.

Page 35: Entity Relationship Modeling

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)

Page 36: Entity Relationship Modeling

COMPANY LOGO

Binary Relationships and Cardinality Ratio

one-to-one (1:1)

Page 37: Entity Relationship Modeling

COMPANY LOGO

Binary Relationships and Cardinality Ratio

one-to-many (1:N) / many-to-one (N:1)

Page 38: Entity Relationship Modeling

COMPANY LOGO

Binary Relationships and Cardinality Ratio

many-to-many (N:M)

Page 39: Entity Relationship Modeling

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

Page 40: Entity Relationship Modeling

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.

Page 41: Entity Relationship Modeling

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.

Page 42: Entity Relationship Modeling

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.

Page 43: Entity Relationship Modeling

COMPANY LOGO

Identify the entities

StudentDepartmentCourseProfessorProjectSection

Page 44: Entity Relationship Modeling

COMPANY LOGO

Determine the attributes for each entityand Select the primary key for each entity

Student

Page 45: Entity Relationship Modeling

COMPANY LOGO

Determine the attributes for each entityand Select the primary key for each entity

Department and Course

Page 46: Entity Relationship Modeling

COMPANY LOGO

Determine the attributes for each entityand Select the primary key for each entity

Professor, Project and Sections

Page 47: Entity Relationship Modeling

COMPANY LOGO

Establish the relationships between the entities and Draw an entity model

Page 48: Entity Relationship Modeling

COMPANY LOGO

END OF PRESENTATIONThank you…

Page 49: Entity Relationship Modeling

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.