Professional Documents
Culture Documents
2 Data Modeling Using Entity Relationship Model - 51
2 Data Modeling Using Entity Relationship Model - 51
ER Model
Data Modeling
Design Processing
Conceptual Models
01/26/24 2
Database Model
01/26/24 9
Translating Business Rules into
Data Model Components
Generally, nouns translate into entities.
Verbs translate into relationships among entities.
Relationships are bidirectional.
01/26/24 10
The Evolution of Data Models
01/26/24 11
Conceptual Model
01/26/24 13
Internal Model
01/26/24 14
Internal Model
01/26/24 15
Physical Model
01/26/24 16
Physical Model
01/26/24 17
Requirements Analysis
01/26/24 18
Conceptual Database Design
01/26/24 19
Entity-Relationship Model
01/26/24 20
Entity-Relationship Model
Each attribute has a value set (or data type) associated with it –
e.g. integer, string, subrange, enumerated type, …
01/26/24 21
Entity-Relationship Model
01/26/24 22
Types of Attributes
Simple:
Each entity has a single atomic value for the attribute.
For example, SSN or Sex.
Composite:
The attribute may be composed of several components.
For example: Address (Apt#, House#, Street, City, region,Country) or
Name (FirstName, MiddleName, LastName)..
Multi-valued:
An entity may have multiple values for that attribute. For example,
Color of a CAR or PreviousDegrees of a STUDENT. Denoted as
{Color} or {PreviousDegrees}.
01/26/24 23
Entity Types and Key Attributes
Entities with the same basic attributes are grouped or typed into
an entity type.
For example, the EMPLOYEE entity type or the PROJECT entity
type.
01/26/24 24
Entity Types and Key Attributes
An entity type may have more than one key. For example, the
CAR entity type may have two keys:
VehicleIdentificationNumber (popularly called VIN) and
VehicleTagNumber (Number, Region), also known as
license_plate number.
01/26/24 25
Entity Types and Key Attributes
Customer
Candidate Key 1: {first, last, birthday}*
01/26/24 Primary Key: {CID} 26
Relationship Sets
01/26/24 27
ER-Diagram Notation For ER
Schemas
01/26/24 28
Example: COMPANY Database
01/26/24 29
Example: COMPANY Database
01/26/24 30
Example: COMPANY Database
ER Diagram: - the entity types are Employee, Department, Project and Dependent.
01/26/24 31
Example: COMPANY Database
ER Diagram: - the entity types are Employee, Department, Project and Dependent.
01/26/24 32
Example: COMPANY Database
More than one relationship type can exist with the same participating
entity types. For example, MANAGES and WORKS_FOR are distinct
relationships between EMPLOYEE and DEPARTMENT, but with
different meanings and different relationship instances.
01/26/24 33
Degree of a relationship
01/26/24 35
Cardinality of a relationship
One-to-many (A to B):
An entity in A associates with any number of entities in B, an
entity in B associates with at most one entity in A,
Many-to-many:
An entity in A associates with any number of entities in B, an
entity in B associates with any number of entities in A,
01/26/24 36
Mapping Cardinalities Example
An entity that can not exist without the entity with which it has a
relationship–it is indicated by a double rectangle.
An entity that does not have a key attribute.
01/26/24 39
Weak Entity Types
01/26/24 40
Extended ER Model
01/26/24 41
Extended ER Model
Designing Subclasses:
The subclass relationship is sometimes referred to as an “ is a”
relationship:
A “is a” B (A is the subclass, B the superclass)
A specializes B or B generalizes A
Inheritance:
The attribute of parent entity sets are inherited by their
subclasses.
A subclass entity set is therefore described by its attributes and
the attributes of its superclass(es).
01/26/24 43
Why Use Class Hierarchies?
01/26/24 Subclasses 44
Exercise One
01/26/24 45
Exercise One
Each musician may play several instruments, and a given instrument may
be played by several musicians.
Each album has a number of songs on it, but no song may appear on more
than one album.
Each song is performed by one or more musicians, and a musician may
perform a number of songs.
Each album has exactly one musician who acts as its producer. A
musician may produce several albums, of course.
Design a conceptual schema for Nahom and draw an ER diagram
for your schema. Be sure to indicate all key and cardinality
constraints and any assumptions that you make. Identify any
constraints that you are unable to capture in the ER diagram and
briefly explain why you could not express them.
01/26/24 46
Exercise Two
Each pharmacy sells several drugs and has a price for each. A drug could
be sold at several pharmacies, and the price could vary from one pharmacy
to another.
Doctors prescribe drugs for patients. A doctor could prescribe one or
more drugs for several patients, Each prescription has a date and a quantity
associated with it.
Pharmaceutical companies have long-term contracts with pharmacies. A
pharmaceutical company can contract with several pharmacies, and a
pharmacy can contract with several pharmaceutical companies. For each
contract, you have to store a start date, an end date, and the text of the
contract.
Pharmacies appoint a supervisor for each contract. There must always be
a supervisor for each contract, but the contract supervisor can change over
the lifetime of the contract.
Draw an ER diagram that captures the above information.
48
Exercise Three
49
Question & Answer
01/26/24 50
Thanks !!!
01/26/24 51