Download - DBMS_Entity-Relationship Data Model
![Page 1: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/1.jpg)
Entity-Relationship Model
![Page 2: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/2.jpg)
Entity sets
• A database can be modeled as:a collection of entities, relationship among entities.
• Entity:-set of attributesEg:- specific person, company
• Entity set:-set of same type of EntitiesEg:- set of all persons, companies
• Entities have attributesEg: people have names and addresses
![Page 3: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/3.jpg)
Entity Sets customer and loan custome _id customer- customer- customer- loan- amount name street city number
![Page 4: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/4.jpg)
Attributes
• Attribute types
Simple and composite attributes. Eg:- composite attribute: Name Eg:- Simple attribute: Roll no
Single-valued and multi-valued attributes
E.g. singlevalued attribute: age of a person E.g. multivalued attribute: phone-numbers
Derived attributes E.g. age, given date of birth
![Page 5: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/5.jpg)
Composite Attributes
![Page 6: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/6.jpg)
Relationship Sets• A relationship is an association among several entities• A relationship set is a set of relationship of the same
type.
If E1,E2,E3……En are entity set then a relationship set R is a subset of
{(e1, e2, … en) | e1 E1, e2 E2, …, en En}
where (e1, e2, …, en) is a relationship
![Page 7: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/7.jpg)
Relationship Set borrower
![Page 8: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/8.jpg)
Mapping Cardinalities
• It is the no. of entities to which another entity can be associated through a relationship.
One to oneOne to manyMany to oneMany to many
![Page 9: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/9.jpg)
Mapping Cardinalities
One to one One to many
![Page 10: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/10.jpg)
Mapping Cardinalities
Many to one Many to many
![Page 11: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/11.jpg)
E-R Diagrams
Rectangles represent entity sets.
Diamonds represent relationship sets.
Lines link attributes to entity sets and entity sets to relationship sets.
Ellipses represent attributes
Double ellipses represent multivalued attributes.
Dashed ellipses denote derived attributes.
Underline indicates primary key attributes
![Page 12: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/12.jpg)
E-R Diagram With Composite, Multivalued, and Derived Attributes
![Page 13: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/13.jpg)
Relationship Sets with Attributes
![Page 14: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/14.jpg)
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.
![Page 15: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/15.jpg)
One-To-One Relationship
![Page 16: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/16.jpg)
One-To-Many Relationship
• 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
![Page 17: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/17.jpg)
Many-To-One Relationships
• 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
![Page 18: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/18.jpg)
Many-To-Many Relationship
![Page 19: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/19.jpg)
Roles• Entity sets of a relationship need not be distinct
• 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
![Page 20: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/20.jpg)
E-R Diagram with a Ternary Relationship
![Page 21: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/21.jpg)
Participation of an Entity Set in a Relationship Set
Total participation (indicated by double line): all entity participates in relationship
E.g. participation of loan in borrower is total
every loan must have a customer associated to it via borrower
Partial participation: some entities may not participate in any relationship in the relationship set
E.g. participation of customer in borrower is partial
![Page 22: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/22.jpg)
Keys
• A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity.
• A candidate key of an entity set is a minimal super key– Customer-id is candidate key of customer– account-number is candidate key of account
• Although several candidate keys may exist, one of the candidate keys is selected to be the primary key.
![Page 23: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/23.jpg)
Weak Entity Sets
• An entity set that does not have a primary key is referred to as a weak entity set.
• We depict a weak entity set by double rectangles.
• The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set.
• Primary key for payment – (loan-number, payment-number) .
![Page 24: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/24.jpg)
Strong Entity Sets
An entity set that have a primary key is referred to as a weak entity set
![Page 25: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/25.jpg)
Extended E-R Features
• Specialization
• Generalization
• Aggregation
![Page 26: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/26.jpg)
Specialization
• Top-down design process.• Depicted by a triangle component labeled ISA (E.g. customer “is
a” person).• Attribute inheritance – a lower-level entity set inherits all the
attributes and relationship participation of the higher-level entity set to which it is linked.
![Page 27: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/27.jpg)
Specialization Example
![Page 28: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/28.jpg)
Generalization
• A bottom-up design process – combine a number of entity sets that share the same features into a higher-level entity set.
• Specialization and generalization are simple inversions of each other; they are represented in an E-R diagram in the same way.
• The terms specialization and generalization are used interchangeably.
![Page 29: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/29.jpg)
Specialization and Generalization
(Contd.)• Can have multiple specializations of an entity set based
on different features. • E.g. permanent-employee vs. temporary-employee, in
addition to officer vs. secretary vs. teller• Each particular employee would be
– a member of one of permanent-employee or temporary-employee,
– and also a member of one of officer, secretary, or teller
• The ISA relationship also referred to as superclass - subclass relationship
![Page 30: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/30.jpg)
Aggregation Consider the ternary relationship works-on, which we saw earlier
Suppose we want to record managers for tasks performed by an employee at a branch
![Page 31: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/31.jpg)
E-R Diagram With Aggregation
![Page 32: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/32.jpg)
Aggregation (Cont.)• Relationship sets works-on and manages represent overlapping
information– Every manages relationship corresponds to a works-on relationship– However, some works-on relationships may not correspond to any
manages relationships • So we can’t discard the works-on relationship
• Eliminate this redundancy via aggregation– Treat relationship as an abstract entity– Allows relationships between relationships – Abstraction of relationship into new entity
• Without introducing redundancy, the following diagram represents:– An employee works on a particular job at a particular branch – An employee, branch, job combination may have an associated
manager
![Page 33: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/33.jpg)
Summary of Symbols Used in E-R Notation
![Page 34: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/34.jpg)
Summary of Symbols (Cont.)
![Page 35: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/35.jpg)
E-R Design Decisions• The use of an attribute or entity set to represent an
object.• Whether a real-world concept is best expressed by an
entity set or a relationship set.• The use of a ternary relationship versus a pair of binary
relationships.• The use of a strong or weak entity set.• The use of specialization/generalization – contributes to
modularity in the design.
• The use of aggregation – can treat the aggregate entity set as a single unit without concern for the details of its
internal structure.
![Page 36: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/36.jpg)
E-R Diagram for a Banking Enterprise
![Page 37: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/37.jpg)
Alternative E-R Notations
![Page 38: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/38.jpg)
End of Chapter 2
![Page 39: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/39.jpg)
E-R Diagram for Exercise 2.10
![Page 40: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/40.jpg)
E-R Diagram for Exercise 2.15
![Page 41: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/41.jpg)
E-R Diagram for Exercise 2.22
![Page 42: DBMS_Entity-Relationship Data Model](https://reader033.vdocuments.net/reader033/viewer/2022061118/546a0426b4af9f09638b4ce0/html5/thumbnails/42.jpg)
E-R Diagram for Exercise 2.15