You are on page 1of 4

Example

Database Technology
A taxi company needs to model their activities.
There are two types of employees in the company: drivers
and operators. For drivers it is interesting to know the date
Topic 3: Enhanced Entity- of issue and type of the driving license, and the date of
issue of the taxi drivers certificate. For all employees it is
Relationship (EER) Modeling interesting to know their personal number, address and the
available phone numbers.
The company owns a number of cars. For each car there is
Olaf Hartig a need to know its type, year of manufacturing, number of
olaf.hartig@liu.se places in the car and date of the last service.
The company wants to have a record of car trips. A taxi
may be picked on a street or ordered through an operator
who assigns the order to a certain driver and a car.
Departure and destination addresses together with times
should also be recorded.

Database Technology
Topic 3: Enhanced Entity-Relationship (EER) Modeling 2

Recall: DB Design Process Entity-Relationship (ER) Model


High-level conceptual data model
An overview of the database
Easy to discuss with non-database experts
Easy to translate to data model of DBMS

ER diagram
Diagrammatic notation associated with the ER model

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 3 Topic 3: Enhanced Entity-Relationship (EER) Modeling 4

Entities and Entity Types Attributes


Entity: a thing in the real world with an simple versus composite
independent existence single-valued versus multivalued
Attributes: Properties that describe an entity stored versus derived
Entity type: A collection of entities that have Street City
the same set of attributes
Name
Model Address
SSN Name RegNumber
Year SSN

Owner Owner PhoneNumber


Car
Age

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 5 Topic 3: Enhanced Entity-Relationship (EER) Modeling 6
Constraints on Attributes Relationship Types
Value sets (domains) of attributes Relationship type: Association among entity types
Key attributes

Street Model
City
RegNumber
Year
Name SSN Name
Address
1 N
SSN Owner owns Car

Owner PhoneNumber
Age

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 7 Topic 3: Enhanced Entity-Relationship (EER) Modeling 8

Constraints on Relationship Types Constraints on Relationship Types


Cardinality ratio: Maximum number of Participation constraint
relationships an entity can participate in Total participation: Every entity participates
Possible cardinality ratio: 1:1, 1:N, N:1, and N:M in at least one relationship with another entity

1 N
Owner owns Car

Every car must be owned by at least one owner.


N 1 SSN
Owner Car N M RegNumber
owns Owner Car
owns

N M
Owner owns Car

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 9 Topic 3: Enhanced Entity-Relationship (EER) Modeling 10

Attributes of Relationship Types n-ary Relationships


Example: A person works as an engineer at one
company and as a gym instructor at another
Store information on who owned which car and during which period of time company

Company
SellDate Model Employee JobType
N N M
Name works at
BuyDate RegNumber works as
Year
M
SSN Employee
K
Ternary
N M N
Owner owns Car Company
works as
M
JobType

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 11 Topic 3: Enhanced Entity-Relationship (EER) Modeling 12
Weak Entity Types ER Notation
Identified by their relationship to a specific
entity from another entity type
Do not have key attributes of their own
Only partial key
The identifying entity has the rest of the key

name

name number
1 N
Team plays_in Player

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 13 Topic 3: Enhanced Entity-Relationship (EER) Modeling 14

Enhanced ER (EER) Model


Why more?
To support more complex data requirements
Example: Only some employees can use a company
Enhanced car, only managers have to write a monthly report,
but all employees have assigned personal number,
Entity-Relationship (EER) Model salary account and a place in the office.
What more?
Specialization / generalization
Subtype / supertype
Union subtypes
Attribute and relationship inheritance

Database Technology
Topic 3: Enhanced Entity-Relationship (EER) Modeling 16

Subtype / Supertype Constraints on Subtypes


specialization

generalization

Surname
FirstName
Disjointness constraint
PN
Name Specifies that the subclasses of the specialization must be disjoint
Otherwise overlapping
process of Completeness constraint (or totalness constraint)
Employee
defining
types Specifies that every superclass entity must be in a subclass
Otherwise partial
d o
U

Commission Disjointness and completeness are independent constraints


U

Salesman Engineer Manager ProjectLeader i.e., four cases are possible


1 1
disjoint and total
disjoint and partial
uses writes
overlapping and total
1 N
overlapping and partial
Car MonthlyReport

RegNumber
ReportID
Database Technology Database Technology
Topic 3: Enhanced Entity-Relationship (EER) Modeling 17 Topic 3: Enhanced Entity-Relationship (EER) Modeling 18
Example
A taxi company needs to model their activities.
There are two types of employees in the company: drivers
and operators. For drivers it is interesting to know the date
of issue and type of the driving license, and the date of
issue of the taxi drivers certificate. For all employees it is
interesting to know their personal number, address and the
Example available phone numbers.
The company owns a number of cars. For each car there is
a need to know its type, year of manufacturing, number of
places in the car and date of the last service.
The company wants to have a record of car trips. A taxi
may be picked on a street or ordered through an operator
who assigns the order to a certain driver and a car.
Departure and destination addresses together with times
should also be recorded.

Database Technology
Topic 3: Enhanced Entity-Relationship (EER) Modeling 22

Example Example (cont'd)


TaxiCertifDate
Street
Address PN
DrivingLicenseDate
PostNumber
Phone
A driver may have many Driver
Town driving licenses (types)
Employee DrivingLicenseType

TaxiCertifDate o
U

Date Type
DrivingLicenseDate
Driver Operator
Id TaxiCertifDate
DrivingLicenseType 1 1
N 1
drives assign Krkort
DrivingLicense belongsTo Driver
N
DepTime Type
N TaxiCertifDate
YearOfManuf
DeparturePlace Trip
RegNumber Type
Destination ServiceDate N M
DestTime N DrivingLicense belongsTo Driver
Places
ID made_by 1 Car Date

Database Technology Database Technology


Topic 3: Enhanced Entity-Relationship (EER) Modeling 23 Topic 3: Enhanced Entity-Relationship (EER) Modeling 24

Summary
Entity-relationship (ER) model: a graphical way to
model the world
Main concepts:
Entity type

Summary Relationship type


Attributes
Different types of constraints
Enhanced ER model

Database Technology
Topic 3: Enhanced Entity-Relationship (EER) Modeling 26

You might also like