ER Diagram - 1
ER Diagram - 1
ER DIAGRAM (1)
Modeling
– Entity, Relationship, Attributes
Attribute
Entity 1
Customer-Id Customer- Customer- Customer-City
name Street
Entity 2
321-12-3123 Jones Main Harison
019-28-3746 Smith North Rye Entity 3
677-89-9011 Hayes Main Harison
Entity 4
555-55-5555 Jackson Dupont Woodside
CUSTOMER
Entity Set
Relationship Sets
A relationship is an association among several entities
Example:
Hayes depositor A-102
customer entity relationship set account entity
L-17 1000
321-12-3123 Jones Main Harison
L-23 2000
019-28-3746 Smith North Rye
L-15 1500
CUSTOMER LOAN
Relationship Sets
An attribute can also be property of a relationship set.
For instance, the depositor relationship set between
entity sets customer and account may have the attribute
access-date
Degree of a Relationship Set
Refers to number of entity sets that participate
in a relationship set.
Relationship sets that involve two entity sets
are binary (or degree two). Generally, most
relationship sets in a database system are
binary.
Relationship sets may involve more than two
entity sets.
Example: Suppose employees of a bank may have jobs
(responsibilities) at multiple branches, with different jobs at
different branches. Then there is a ternary relationship set
between entity sets employee, job, and branch
Example : Degree of a Relationship Set
Binary Relationship
Student Teacher
Ternary Relationship
Employee Branch
Job
Attributes
An entity is represented by a set of attributes,
that is descriptive properties possessed by all
members of an entity set.
Example:
customer = (customer_id, customer_name,
customer_street, customer_city )
loan = (loan_number, amount )
Candidate Key :
– Customer-Id
Primary Key :
– Customer-Id
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.
Or, we can express cardinality constraints by
numbering the line with 1 (for “one”), and n /m (for
“many”)
One-to-one relationship:
– A customer is associated with at most one loan via the
relationship borrower
– A loan is associated with at most one customer via borrower
One-To-One Relationship (1 – 1)
In the one-to-one relationship a loan is
associated with only one customer via
borrower, a customer is associated with only
one loans via borrower
One-To-Many Relationship (1 – N)
In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with
several (including 0) loans via borrower
Many-To-One Relationships (N – 1)
In a many-to-one relationship a loan is
associated with several (including 0) customers
via borrower, a customer is associated with at
most one loan via borrower
Many-To-Many Relationship (N – M)
A customer is associated with several
(possibly 0) loans via borrower
A loan is associated with several (possibly 0)
customers via borrower
Design Issues
Use of entity sets vs. attributes
Choice mainly depends on the structure of the enterprise being
modeled, and on the semantics associated with the attribute in
question.