Modeling Data in The Organization: Modern Database Management 6 Edition
Modeling Data in The Organization: Modern Database Management 6 Edition
Student
Student ID Student Name Student Address Student Contact
00-01234-1 ABCD EFGH 123 XYZ 123456987
Row: Record 00-01235-1 IJKL MNOP 345 PQR 234569800
(Each row is an 00-01236-1 QRST UVQX 456 X Z MNO 234569870
00-01237-1 YXAB CDEF 123 P Q MNO 456987123
Entity Instance) 00-01238-1 GHIJ KLMN 789 AB CDE 001234569
00-01239-1 OPQR STUV 45 XYZ 012345698
Relationship
Couse Registration
Course ID Course Name Credit Hour Reg_ID Student ID Course_ID Date
C0001 Computing 3 R0100115 00-01234-1 C0001 01-Jun-2015
C0002 Marketing 3 R0100215 00-01235-1 C0001 01-Jun-2015
C0003 Accounting 2 R0100315 00-01234-1 C0002 02-Jun-2015
C0005 Management 1 R0100415 00-01237-1 C0005 02-Jun-2015
C0007 English 3 R0100515 00-01235-1 C0007 02-Jun-2015
C0009 Programming 2 R0100615 00-01238-1 C0009 03-Jun-2015
Relationship
Figure 3-22:
Sample E-R Diagram
Figure 3-2: Basic E-R Notation
Name
Multivalued
Attribute
Contact
No. Age
Birthdate Postcode
Day House Address
District
Month Road
Year Area
Impact of COMPOSITE attribute
Birthdate Postcode
Day House Address
District
Month Road
Year Area
Birthdate Address
Customer
Customer_ID Name Day Month Year House Road Area District Postcode
Figure 3-7: multivalued attribute (examples)
Student Major
Contact Customer
No. Age Customer_ID Name Contact No.
1 ABCD 123456, 456789
2 EFGH 123456 456789
Customer_ 234567
Customer Name
ID 3 IJKL
987654
Customer Customer_Contacts
Customer_ID Name Customer_ID Contact No.
1 ABCD 1 123456
2 EFGH 1 456789
3 IJKL 2 345678
2 567890
3 234567
3 987654
Figure 3-7: derived attribute (examples)
Date_of
Student Age
_Birth
Derived Multivalued:
from date employed and an employee can have
current date more than one skill
Figure 3-9b: Composite key attribute
This is an
example of
time-stamping
Degree of Relationships
• Degree of a Relationship is the
number of entity types that
participate in it
–Unary Relationship
–Binary Relationship
–Ternary Relationship
Cardinality of Relationships
(Applicable to Unary and Binary degrees only)
• One – to – One
– Each entity in the relationship will have exactly one
related entity
• One – to – Many
– An entity on one side of the relationship can have
many related entities, but an entity on the other side
will have a maximum of one related entity
• Many – to – Many
– Entities on both sides of the relationship can have
many related entities on the other side
Degree-Cardinality Combination
Degree Cardinality Combination
Unary One-to-one Unary One-to-one
Unary One-to-many Unary One-to-many
Unary Many-to-many Unary Many-to-many
Binary One-to-one Binary One-to-one
Binary One-to-many Binary One-to-many
Binary Many-to-many Binary Many-to-many
Ternary Not applicable Ternary
Unary Relationship
Course Employee Person
Prereq super Marri
uisite vise ed to
Works in
Employee Department
Supervise
Manage
Practice: Building an ER Diagram
The attributes of EMPLOYEE include Employee_ID (identifier), Name,
Address, Birthdate, Age and Contact Number. Address is composed of
House, Road, Area, District, Postcode. Birthdate has three components –
Day, Month and Year. Age is calculated from Birthdate. There can be
more than one contact number of one employee.
Employee
Practice: Building an ER Diagram: Entity with attributes
The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate,
Age and Contact Number. Address is composed of House, Road, Area, District, Postcode.
Birthdate has three components – Day, Month and Year. Age is calculated from Birthdate.
There can be more than one contact number of one employee.
Employee_ID Employee
Postcode
House Address
District
Road
Area
Practice: Building an ER Diagram: Entity with attributes
The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and Year.
Age is calculated from Birthdate. There can be more than one contact number of one employee.
• ‘Birthdate’ is also COMPOSITE attribute with 3 components – Day, Month, Year (draw
an oval, write ‘Birthdate’ and extend it with its 3 components drawing 3 ovals for Day,
Month, Year)
Birthdate Postcode
Day House Address
District
Month Road
Year Area
Practice: Building an ER Diagram: Entity with attributes
The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and Year.
Age is calculated from Birthdate. There can be more than one contact number of one employee.
• ‘Age’ is DERIVED attribute (draw an oval with dashed boundary, write ‘Age’)
Age
Birthdate Postcode
Day House Address
District
Month Road
Year Area
Practice: Building an ER Diagram: Entity with attributes
The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and Year.
Age is calculated from Birthdate. There can be more than one contact number of one employee.
• ‘Contact No.’ is MULTIVALUED attribute (draw an oval with double line, write ‘Contact
No.’)
Contact
No. Age
Birthdate Postcode
Day House Address
District
Month Road
Year Area
Practice: Building an ER Diagram: Relationship
• The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and
Year. Age is calculated from Birthdate. There can be more than one contact number of one employee.
• The attributes of PROJECT are Project_ID (identifier), Name, StartDate, EndDate, Duration and Location. Duration is
calculated from StartDate and EndDate. There can be more than one Location of a project.
• An employee may work in many projects. One projects can have many employees working in it.
• One employee may be assigned to supervise many projects. One project can have only one employee assigned as
the supervisor.
Work
Location
Age
Contact
No. Duration
Project_ID
District
Month Road
Year Area
Practice: Building an ER Diagram: Relationship
• The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and
Year. Age is calculated from Birthdate. There can be more than one contact number of one employee.
• The attributes of PROJECT are Project_ID (identifier), Name, StartDate, EndDate, Duration and Location. Duration is
calculated from StartDate and EndDate. There can be more than one Location of a project.
• An employee may work in many projects. One projects can have many employees working in it.
• One employee may be assigned to supervise many projects. One project can have only one employee assigned as
the supervisor.
Work
Location
Age
Contact
No. Duration
Project_ID
District
Month Road
Year Area
Practice: Building an ER Diagram: Relationship
• The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and
Year. Age is calculated from Birthdate. There can be more than one contact number of one employee.
• The attributes of PROJECT are Project_ID (identifier), Name, StartDate, EndDate, Duration and Location. Duration is
calculated from StartDate and EndDate. There can be more than one Location of a project.
• An employee may work in many projects. One projects can have many employees working in it.
• One employee may be assigned to supervise many projects. One project can have only one employee assigned as
the supervisor.
Work
Location
Age
Contact
No. Duration
Project_ID
District
Month Road
Year Area
Practice: Building an ER Diagram: Relationship
• The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and
Year. Age is calculated from Birthdate. There can be more than one contact number of one employee.
• The attributes of PROJECT are Project_ID (identifier), Name, StartDate, EndDate, Duration and Location. Duration is
calculated from StartDate and EndDate. There can be more than one Location of a project.
• An employee may work in many projects. One projects can have many employees working in it.
• One employee may be assigned to supervise many projects. One project can have only one employee assigned as
the supervisor.
Example continued:
There is another relationship between Employee and Project. One employee may be
assigned to supervise many projects. So, supervise is another relationship. (draw another
diamond ‘supervise’ between employee and project)
Work
Location
Age
Contact
No. Name
Duration
supervise
Employee_ID Employee Start
Project
Date
Project_ID
District
Month Road
Year Area
Practice: Building an ER Diagram: Relationship
• The attributes of EMPLOYEE include Employee_ID (identifier), Name, Address, Birthdate, Age and Contact Number.
Address is composed of House, Road, Area, District, Postcode. Birthdate has three components – Day, Month and
Year. Age is calculated from Birthdate. There can be more than one contact number of one employee.
• The attributes of PROJECT are Project_ID (identifier), Name, StartDate, EndDate, Duration and Location. Duration is
calculated from StartDate and EndDate. There can be more than one Location of a project.
• An employee may work in many projects. One projects can have many employees working in it.
• One employee may be assigned to supervise many projects. One project can have only one employee assigned as
the supervisor.
Example continued:
Identify the cardinality of ‘supervise’ relationship. One employee may be assigned to supervise many
projects. So, cardinality on the project side is MANY (crow’s feet). One project can have ONLY ONE
employee assigned as the supervisor. So, the cardinality on the employee side is ONE (straight line).
Work
Location
Age
Contact
No. Name
Duration
supervise
Employee_ID Employee Start
Project
Date
Project_ID
District
Month Road
Year Area
Practice Case 1:
A company has a number of Employees. The attributes of
EMPLOYEE include Employee_ID (identifier), Name, Address,
and Birthdate. The company also has several projects.
Attributes of PROJECT include Project_ID (identifier),
Project_Name, and Start_Date. Each employee may be
assigned to one or more projects; or may not be assigned to
a project. A project must have at least one employee
assigned, and may have any number of employees assigned.
An employee’s billing rate may vary by project, and the
company wishes to record the applicable billing rate
(Billing_Rate).
Practice Case 1: Solution
Practice Case 2:
A university has a large number of courses in its catalog. Attributes of
COURSE include Course_Number (identifier), Course_Name, and Units.
Each course may have one or more different courses as prerequisites or
may have no prerequisites. Similarly, a particular course may be a
prerequisite for any number of courses, or may not be prerequisite of any
other course.
Practice Case 3:
A hospital has a large number of registered physicians.
Attributes of PHYSICIAN include Physician_ID (identifier),
Name and Specialty. Patients are admitted to the hospital by
physicians. Attributes of a PATIENT include Patient_ID
(identifier) and Patient_Name. Any patient who is admitted
must have exactly one admitting physician. A physician may
optionally admit any number of patients. Once admitted, a
given patient must be treated by at least one physician. A
particular physician may treat any number of patients or
may not treat any patients. Whenever a patient is treated by
a physician the hospital wishes to record the details of the
treatment (Treatment_Details). Components of
Treatment_Details include Date, Time and Results.
Practice Case 3: Solution
Practice Case 4:
• A firm has a number of Sales Offices in several states. Attributes of Sales
Office include Office_Number (identifier) and Location.
• Each Sales Office is assigned one or more employees. Attributes of
Employee include Employee_ID (identifier) and Name. An employee
must be assigned to only one sales office.
• For each Sales Office, there is always one employee assigned to manage
that office. An employee may manage only one sales office to which
he/she is assigned, or may not manage any office.
• The firm lists property for sales. Attributes of Property include
Property_ID (identifier) and Location. Components of Location are
Address, City, State, and Zip Code.
• Each unit of property must be listed with only one Sales Office. A sales
office may have any number of properties listed; or may have none.
• Each unit of property has one or more owners. Attributes of Owners are
Owner_ID (identifier) and Owner_Name. An owner may own one of
more units of property. An attribute of the relationship between
property and owner is Percent_Owned.
Practice Case 4: Solution
Practice Case 6:
CONCERT SEASON: The season during which a series of concerts will be performed. Identifier is
the Opening_Date which includes Month, Day and year.
CONCERT: A given performance of one or more compositions. Identifier is Concert_Number.
Another important attribute is Concert_Date, which consists of the following: Month, Day, Year
and Time. Each concert typically has more than one concert date.
COMPOSITION: Compositions to be performed at each concert. Identifier is Composition_ID,
which consists of the following: Composer_Name and Composition_Name. Another attribute is
Movement_ID which consists of Movement_Number and Movement_Name. Many but not all,
compositions have multiple movements.
CONDUCTOR: Person who will conduct the concert. Identifier is Conductor_ID. Another
Attribute is Conductor_Name.
SOLOIST: Solo artist who performs a given composition on a particular concert. Identifier is
Soloist_ID. Another attribute is Soloist_Name.
• A concert season schedules one or more concerts. A particular concert is scheduled for
only one concert season.
• A concert includes the performance of one or more compositions. A composition may be
performed at one or more concerts, or may not be performed.
• For each concert there is one conductor. A conductor may conduct any number of concerts,
or may not conduct any concerts.
• Each composition may require one or more soloist, or may not require a soloist. A soloist
may perform one or more compositions at a given concert, or may not perform any
composition. The symphony orchestra wishes to record the date when a soloist last
performed a given composition (Date_Last_Performed).
Practice Case 6: Solution
Practice Case 7:
The entity type STDUENT has the following attributes: Student_ID
(Identifier), Stduent_Name, Address, Phone, Age, Activity and No_of_Years.
Activity represents some campus based student activities, while
No_of_Years represents the number of years the student has engaged in this
activity. A given student may engage in more than one activity.
Exam Case 1:
A doctor’s chamber requires a database for effective
patient and vaccine management. Each doctor treats
more than one patient. One patient can be treated by
many doctors. During treatment a doctor advises a
patient in a prescription. A prescription is combined
of date, symptoms and advice. One patient may take
many vaccines. One vaccine may be taken by many
patients. Besides doctors there are also general
employees in the chamber. One employee assists
more than one doctor. One doctor may be assisted by
only one employee. Whenever a patient takes a
vaccination the date of vaccination is stored along
with the employee information who vaccinated the
patient.
Exam Case 2:
Every employee has a unique number. One
employee may be married to one other
employee. If an employee is married to another
employee, the marriage date is also stored. There
are 10 departments. An employee reports to only
one department. One department can have many
employees. An employee can work on many
projects. One project has many employees. An
employee can have many skills but he can use
only one skill in one project. The skill that an
employee uses in a project is only stored.
Exam Case 3:
There are members in bands. One member is member of
exactly one band. One band must have at least one member.
Bands release albums. An album is released by one band. A
band may release as many albums they wish. A song may be
included in many albums. One album must have at least one
song. One member of the band works as a band leader of the
band. Each band can have only one band leader. The date when
a member is appointed as the leader of a band is also needs to
be stored. A song is identified by a songid and can have a title
and a category. Members’ identifiers are memberid and they
have name, dateofbirth and age (is derived from dateofbirth).
An album is identified by albumid and can have albumtitle and
year released (can be multiple values if the album is re-
released). A band is identified by bandid. A band also has
bandname and yearestablished attributes.
Exam Case 3: Solution
Exam Case 4:
In a hospital, attributes of a doctor are Doc_ID
(identifier), Name, Specialty (can be multiple), Joining
Date and Duration (calculated from Joining date). One
doctor can treat many patients. Attributes of a patient
are Patient_ID (identifier), Name, Registration Date and
Address (composed of Street, PO, City and Post Code).
A patient can be treated by many doctors. During the
treatment, the date of visit and doctor’s advice are also
stored. A patient can be admitted by only one doctor. A
doctor may admit any number of patients. At the time
of admission the date of admission is also stored. A
patient can have multiple admission dates.
Exam Case 5:
Employee:
• Employee No (Key)
• Employee Name (Composed of First Name, Last Name, Middle Name)
• Employee Address
• Employee Designation (Can be more than one)
• Employee Salary
Project:
• Project No (Key)
• Project Name
• Project Location (Can be multiple)
• Start Date
• End Date
• Duration (Calculated from Start and End date)
Department:
• Department Identifier (Key)
• Department Name
• Department Location
Relationships:
• One employee can work in only one department. One department can have many employees.
• One employee is assigned to manage a department. One department can have only one employee assigned as
the manager.
• One employee may be assigned in multiple projects. One project can have many employees assigned.
• One employee may be assigned to lead many projects. One project can have only one employee as the project
leader.
• A project runs under many departments. One department may run many projects.
• Employees are supervised by other employees. One employee may supervise many other employees. One
employee may be supervised by only one employee.