0% found this document useful (0 votes)
140 views53 pages

Modeling Data in The Organization: Modern Database Management 6 Edition

1) The document discusses key concepts in entity-relationship (E-R) modeling including entities, attributes, relationships, and how they map to tables, columns, and rows in a relational database. 2) It explains different types of attributes like simple, composite, multivalued, and derived attributes. It also discusses different types of relationships like unary, binary, ternary as well as cardinalities like one-to-one, one-to-many, many-to-many. 3) Examples and diagrams are provided to illustrate concepts like composite and multivalued attributes, and different relationship degrees and cardinalities.

Uploaded by

Jhon Kabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views53 pages

Modeling Data in The Organization: Modern Database Management 6 Edition

1) The document discusses key concepts in entity-relationship (E-R) modeling including entities, attributes, relationships, and how they map to tables, columns, and rows in a relational database. 2) It explains different types of attributes like simple, composite, multivalued, and derived attributes. It also discusses different types of relationships like unary, binary, ternary as well as cardinalities like one-to-one, one-to-many, many-to-many. 3) Examples and diagrams are provided to illustrate concepts like composite and multivalued attributes, and different relationship degrees and cardinalities.

Uploaded by

Jhon Kabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 53

Chapter 3:

Modeling Data in the


Organization
Modern Database Management
6th Edition
Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
E-R Model Constructs
• Entity
– Person, place, object, event, concept, etc.- about which data needs
to be stored.
– often corresponds to a table
– Anything about which we want to collect data
• Attribute
– property or characteristic of an entity
– Defines the entity
– Specific columns of Entity table
– Various types; different design for each type
• Relationship
– Connections between entities
– May have attributes
– Degree and cardinality must be identified
– Cardinality applies for Unary and Binary degrees
Relational Database Concept
Entity (Table) Column: Field (Attribute)

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 Entity Name Attribute

Name
Multivalued
Attribute

Name Relationship Name Derived Attribute


Attributes
• Classifications of attributes:
– Simple Attribute
– Composite Attribute
– Multivalued Attribute
– Derived Attributes
– Identifier Attributes (key)
• An attribute (or combination of attributes) that uniquely identifies
individual instances of an entity type
• Unique
• Not null
• Simple Key (one attribute)
• Like, Student ID, National ID, License #, etc.
• Composite Key (multiple attributes)
Figure 3-7: COMPOSITE attribute: An attribute broken into
component parts.
In the following example, Address, Birthdate are composite
attributes.

Contact
No. Age

Employee_ID Customer Name

Birthdate Postcode
Day House Address

District
Month Road
Year Area
Impact of COMPOSITE attribute

Contact No. Age

Customer_ID Customer Name

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)

One entity instance can have multiple values of an attribute

One student can take more than one major

Student Major

One customer can have more than one contact


Customer Contact
Impact of MULTIVALUED attribute

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)

Value of an attribute of an entity is calculated from the value


of another attribute. This type of attribute value are derived
when needed; rather than stored in the database.
Age of a student is calculated from his date of birth

Date_of
Student Age
_Birth

Years Employed value of an employee is calculated from


his joining date
Joining Years
Employee
Date Employed
Simple key attribute

The key is underlined


Entity with a Multivalued attribute (Skill) and Derived
attribute (Years_Employed)
Primary Key (Identifier)

Derived Multivalued:
from date employed and an employee can have
current date more than one skill
Figure 3-9b: Composite key attribute

The key is composed


of two subparts
Figure 3-19: an attribute that is both multivalued and composite

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

Unary many-to-many Unary one-to-many Unary one-to-one


Course Course Emp Emp Person Person
C1 C1 E1 E1 P1 P1
C2 C2 E2 E2 P2 P2
C3 C3 E3 E3 P3 P3
C4 C4 E4 E4 P4 P4
C5 C5 E5 E5 P5 P5
C6 C6 E6 E6 P6 P6
Binary Relationship
Figure 3-10a: Binary Relationship Explained

Figure 3-10b: Entity and Relationship instances


Ternary Relationships
More on Relationships
• Relationships can have attributes
– These describe features pertaining to the association
between the entities in the relationship
• Two entities can have more than one type
of relationship between them (multiple
relationships)
Figure 3-11a: A binary relationship with an attribute

Here, the date completed attribute pertains specifically to


the employee’s completion of a course…it is an attribute of
the relationship
Figure 3-13a: A unary relationship with an attribute.
This has a many-to-many relationship

Representing a bill-of -materials structure


Multiple relationships: entities can be related to one
another in more than one way

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.

Step 1: Draw the Entity ‘Employee’


• Draw a rectangle and write ‘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.

Step 2: Draw the Attributes:


• ‘Employee_ID’ is IDENTIFIER attribute (draw an oval, write ‘Employee_ID’ and
underline it)

Employee_ID Employee

• ‘Name’ is SIMPLE attribute (draw an oval and write ‘Name’)

Employee_ID Employee Name


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.

• ‘Address’ is COMPOSITE attribute with 5 components - House, Road, Area, District,


Postcode (draw an oval, write ‘Address’ and extend it with its 5 components drawing 5
ovals for House, Road, Area, District, Postcode)

Employee_ID Employee Name

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)

Employee_ID Employee Name

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

Employee_ID Employee Name

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

Employee_ID Employee Name

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.

Step 1: Identify the relationship(s)


Employee WORKS in project. So, work is the relationship between Employee and Project
(draw a diamond, write ‘work’ and connect with Employee and Project)

Work
Location
Age

Contact
No. Duration

Employee_ID Employee Name Start


Project
Date

Day Birthdate House Address Postcode End


Date Name

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.

Step 2: Identify the cardinality of the relationship(s), whether it is one-to-one OR


one-to-many OR many-to-many
One employee works in many projects. So, the cardinality at the project side is MANY.
(Draw crow’s feet symbol at the project side)

Work
Location
Age

Contact
No. Duration

Employee_ID Employee Name Start


Project
Date

Day Birthdate House Address Postcode End


Date Name

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.

Step 3: Identify the cardinality of the relationship(s), whether it is one-to-one OR


one-to-many OR many-to-many
One project can have many employees working in it. So, the cardinality at the employee
side is also MANY. (Draw crow’s feet symbol at the employee side)

Work
Location
Age

Contact
No. Duration

Employee_ID Employee Name Start


Project
Date

Day Birthdate House Address Postcode End


Date Name

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

Day Birthdate House Address Postcode End


Date Name

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

Day Birthdate House Address Postcode End


Date Name

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.

You might also like