Lecture 8 - Entity Relationship Modelling - Part II PDF
Lecture 8 - Entity Relationship Modelling - Part II PDF
Database Systems
Unit 8 :
Entity
Relationship
Modeling (ERM)
(Part 2)
Topic 8
Objective :
At the end of this unit, you should be able to:
Learn the ER modeling process.
Understand transformation of ER models to
Relational models; involving strong entities,
weak entities, recursive entities, one to one
relations, one to many relations, many to many
relations, super-types and sub-types.
Topic 8
Topic 8
E-R Model
Relational Model
Entities
Attributes
Identifier
Illustration:
CUSTOMER ( CustNum, CustName, Address, ContactName, PhoneNumber)
Cust Num
Address
CUSTOMER
CustNum
CustName
CustName
CUSTOMER
Address
ContactName
ContactName
IT1768 Database Systems
PhoneNumber
PhoneNumber
Topic 8
ER Modelling of Different
Relationships
-1:1
-1:N
-M:N
Topic 8
Entity : Car
Emp_ID
Registr_Num
EName
Model
EAge
Utilises
EPhone
Colour
Milage_current
(FK)
(FK)
Mapping
Topic 8
Option 2
(FK)
()
Preferred
Option
Given the fact that an employee may or may not own a car, but a car must belong
to one employee, option 1 is preferred. If option 2 is chosen, If a employee with
no car, the record should contain a null value in the Registr_Num field.
Entity : Employee
Entity : Car
Emp_ID
Registr_Num
EName
Model
EAge
EPhone
Utilises
Colour
Milage_current
Emp_ID
Topic 8
CustomerID
Order_Code
Name
Item_Description
Age
Email_Addr
places
Order_Date
SalesPrice
Topic 8
CustomerID
Order_Code
Name
Item_Description
Age
places
Email_Addr
Order_Date
SalesPrice
CustomerID
(PK)
Topic 8
Account_No
Name
Age
Email
Account_type
SetUp
Balance
N
Customer_ID
Telno
10
Topic 8
For the example below, one supplier can supply many products
and one product can be supplied by many suppliers.
Entity : SUPPLIER
Entity : PRODUCT
Supplier_ID
Product_Code
Name
Description
Address
supplies
Credit_term
Price
LeadTime
SalesDate
Supplier_ID
Name
Address
Credit_term
Product_Code
S-01
ABC Supplies
1, AMK Street 1
60 days
P-88
S-01
ABC Supplies
1, AMK Street 1
60 days
P-99
S-02
XYZ Supplies
9, AMK Street 9
60 days
P-88
In M:N relationship, a supplier (S-01) is suppose to supply more than one product,
in this case, with Supplier_ID as a Primary Key, it does not allow repeated value.
IT1768 Database Systems
11
Topic 8
Entity : PRODUCT
Supplier_ID
Product_Code
Name
Description
Address
Credit_term
supplies
Price
LeadTime
SalesDate
12
Topic 8
After Transformation !
Entity : SUPPLIER
Composite relation:
ITEM
Entity : PRODUCT
Supplier_ID
Product_Code
Product_Code
Name
Supplier_ID
Description
Address
SalesDate
Price
Credit_term
LeadTime
Product_Code
Supplier_ID
SalesDate
P-88
S-01
24-Aug-2009
P-99
S-01
24-Aug-2009
13
Topic 8
More Example :
A many-to-many relationship should be split into two 1: N relationships
with an intersection (Composite) entity.
STUDENT
N:M
MODULES
REGISTER
STUDENT
1:N
REGISTER
M:1
MODULES
14
Topic 8
15
Topic 8
16
Topic 8
Recursive Relationship
PERSON
1:1
EMPLOYEE
supervises
SPONSOR
is supervised by
IT1768 Database Systems
17
Topic 8
Recursive Relationship 2
Solutions:
1) Place the key of the person being sponsored in the row of
the sponsor, or
2) Place the key of the sponsor in the row of the person being
sponsored.
Person
Person -sponsored
Jones
Smith
Jones
Null
Smith
Parks
Smith
Jones
Parks
Null
Parks
Smith
Alternate (2)
18
Topic 8
Supertype/Subtype Entities
19
Topic 8
Supertype/Subtype entities
By Super-type/Sub-type entities:
CLIENT
Indiv_Client
Corp_Client
Overseas_Client
20
Topic 8
Supertype/Subtype entities
Profession
Address
Indiv_Client
IT1768 Database Systems
GstRegis_no
Country_id
Payment_class
Person_contact
Date_transact
Phone
Corp_Client
Overseas_Client
21
Topic 8
Summary
An ER diagram consists of entity types, attributes
and relationships.
Entity types can be classified as strong or weak.
Attributes can be a simple or composite attribute,
a single-valued or multi-valued attribute, or a
derived attribute.
A relationship type can involve
one(unary/recursive), two(binary), three (ternary)
or four (quarternary) entity types.
Subtypes inherit attributes from the super-type
Data models represent model of the users model
IT1768 Database Systems
22