06-Data Modeling Using The Entity-Relationship
06-Data Modeling Using The Entity-Relationship
• An Entity–relationship model (ER model) describes the structure of a database with the
help of a diagram, which is known as Entity Relationship Diagram (ER Diagram). An ER
model is a design or blueprint of a database that can later be implemented as a
database.
name dname
ssn lot did budget
• Entity maybe :
an object with a physical existence (a person, a car, house…) or
• Attributes:
The particular properties that describe the entity
name
ssn lot
Employees
Relationship
name dname
ssn lot did budget
Single-valued
• The attributes which have a single value for a particular entity are called single-
valued
Example : name, roll_number
Multivalued
• In some cases an attribute can have a set of value for the same entity Such
attributes are called Multivalued
Example:- degree(phd, mcs)
Stored vs. Derived
Stored attributes:
• The stored attribute are such attributes which are already stored in the database and
from which the value of another attribute is derived is called stored attribute.
Derived attributes
• Derived attributes are attributes whose values are generated from other attributes using
calculations, algorithms or procedures.
For example:
Age of a person can be calculated from person’s date of birth and present date.
Difference between these two dates gives the value of age. In this case, date of birth is a
stored attribute and age of the person is the derived attribute
Entity with a multivalued attribute (Skill)
&
derived attribute (Years_Employed)
Multivalued:
Derived an employee can have
from date employed and current date more than one skill
13
Identifying relationship
17
CID
PID
Date
Customer Product
Name
Name
Purchase
Customer
CID Name
1 A Purchase
2 B PID CID
1 1
1 2
2 2
Product
PID Name
1 X
2 y
EID DID
Since
Employee Dept
Name
Name
Works
Age for
Employee Dept
EID Name Age DID Name
Work
EID DID Since
Date PID Name
CID
Product
Customer Purchase
Price
Name
Date
Qty
Supplies
Qty
SID
Supplier
Name
SUPPLIER
STOCK
SID Name
1 E SID PID Qty Date
2 R 1 1 100 9
1 2 5000 20
Product
PID Name Price
1 A 10
PURCHASE 2 B 20
CID PID QTY Date
001 1 5 10
001 2 2 3
COUSTOMER
002 1 1 6
CID Name
001 X
002 y