Entity-Relationship Model: CST203-2 Database Management Systems
Entity-Relationship Model: CST203-2 Database Management Systems
Conceptual design
Descriptions on entity types, relationships and constraints
Choose a DBMS
An entity is an object that exists and is distinguishable from other objects.
Example: specific person, company, event, plant
An entity type is a collection of entries that have the same attributes
An entity set is a collection of entities of a particular entity type in the database at any
point in time
Entity Sets
customer and loan
Attributes
Particular properties of an entity that describe it
Example:
customer = (customer-id, customer-name, customer-street, customer-city)
loan = (loan-number, amount)
Domain – the set of permitted values for each attribute (value set)
Attribute types:
Simple and composite attributes.
Single-valued and multi-valued attributes
E.g. multivalued attribute: phone-numbers
Stored and derived attributes
Can be computed from other attributes
E.g. age, given date of birth
Complex attributes
Key attributes
An attribute A of entity type E whose value set is V
A:E P(V)
PROJECT
Name, Number, Location, ControllingDepartment
EMPLOYEE
Name(Fname, Initial, LName), ENO, Sex, Address, Salary, DOB, Department,
Supervisor, {WorksOn(Project, Hours)}
DEPENDENT
Employee, DependentName, Sex, DOB, Relationship
Relationship Sets
A relationship is an association among several entities
Example:
Hayes depositor A-102
customer entity relationship set account entity
A relationship set is a set of associations among entities from these entity types
mathematical relation among n 2 entities, each taken from entity sets
Relationship types that involve two entity types are binary (or degree two)
Relationships as attributes
E-R Diagram with a Ternary Relationship
Converting Non-Binary Relationships to
Binary Form
In general, any non-binary relationship can be represented using binary
relationships by creating an artificial entity set.
Replace R between entity sets A, B and C by an entity set E, and three relationship sets:
1. RA, relating E and A 2.RB, relating E and B
3. RC, relating E and C
Create a special identifying attribute for E
Add any attributes of R to E
For each relationship (ai , bi , ci) in R, create
1. a new entity ei in the entity set E 2. add (ei , ai ) to RA
3. add (ei , bi ) to RB 4. add (ei , ci ) to RC
Mapping Cardinalities
Express the number of entities to which another entity can be associated via a relationship set.
For a binary relationship set the mapping cardinality must be one of the following types:
One to one
One to many
Many to one
Many to many
Cardinality ratio
Maximum number of relationship instances that an entity can participate in
1:1
1:N
N:1
N:N
Some elements in A and B may not be mapped to any elements in the other set
Mapping Cardinalities affect ER Design
Can make access-date an attribute of account, instead of a relationship attribute, if
each account can have only one customer
I.e., the relationship from account to customer is many to one, or equivalently,
customer to account is one to many
E-R Diagrams
The labels “manager” and “worker” are called roles; they specify how employee
entities interact via the works-for relationship set.
Roles are indicated in E-R diagrams by labeling the lines that connect diamonds
to rectangles.
Role labels are optional, and are used to clarify semantics of the relationship
Cardinality Constraints
We express cardinality constraints by drawing either a directed line (), signifying
“one,” or an undirected line (—), signifying “many,” between the relationship set and the
entity set.
Partial participation: some entities may not participate in any relationship in the
relationship set
E.g. participation of customer in borrower is partial