Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICOM 5016 – Introduction to Database Systems Lecture 4 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,

Similar presentations


Presentation on theme: "ICOM 5016 – Introduction to Database Systems Lecture 4 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,"— Presentation transcript:

1 ICOM 5016 – Introduction to Database Systems Lecture 4 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico, Mayagüez

2 ©Silberschatz, Korth and Sudarshan2.2Database System Concepts Objectives Describe Entity Relationship Model (E-R) Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database Schema Reduction of an E-R Schema to Tables

3 ©Silberschatz, Korth and Sudarshan2.3Database System Concepts Relationship Mapping Cardinalities Express the number of entities to which another entity can be associated via a relationship set. Most useful in describing binary relationship sets. 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

4 ©Silberschatz, Korth and Sudarshan2.4Database System Concepts Mapping Cardinalities One to oneOne to many Note: Some elements in A and B may not be mapped to any elements in the other set

5 ©Silberschatz, Korth and Sudarshan2.5Database System Concepts One-to-Many Relationship e 1 e 2 e 3 e 4 e 5 e 6 e 7 EMPLOYEE r1r2r3r4r5r6r7r1r2r3r4r5r6r7 WORKS_FOR d 1 d 2 d 3 DEPARTMENT

6 ©Silberschatz, Korth and Sudarshan2.6Database System Concepts Mapping Cardinalities Many to oneMany to many Note: Some elements in A and B may not be mapped to any elements in the other set

7 ©Silberschatz, Korth and Sudarshan2.7Database System Concepts Many-Many Relationship e 1 e 2 e 3 e 4 e 5 e 6 e 7 r1r2r3r4r5r6r7r1r2r3r4r5r6r7 d 1 d 2 d 3 r8r8 r9r9

8 ©Silberschatz, Korth and Sudarshan2.8Database System Concepts E-R Diagram with a Ternary Relationship

9 ©Silberschatz, Korth and Sudarshan2.9Database System Concepts 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

10 ©Silberschatz, Korth and Sudarshan2.10Database System Concepts 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 (will study later)

11 ©Silberschatz, Korth and Sudarshan2.11Database System Concepts E-R Diagram With Composite, Multivalued, and Derived Attributes

12 ©Silberschatz, Korth and Sudarshan2.12Database System Concepts Relationship Sets with Attributes

13 ©Silberschatz, Korth and Sudarshan2.13Database System Concepts 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

14 ©Silberschatz, Korth and Sudarshan2.14Database System Concepts 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. E.g.: 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

15 ©Silberschatz, Korth and Sudarshan2.15Database System Concepts 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

16 ©Silberschatz, Korth and Sudarshan2.16Database System Concepts 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

17 ©Silberschatz, Korth and Sudarshan2.17Database System Concepts Many-To-Many Relationship A customer is associated with several (possibly 0) loans via borrower A loan is associated with several (possibly 0) customers via borrower

18 ©Silberschatz, Korth and Sudarshan2.18Database System Concepts Participation of an Entity Set in a Relationship Set Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set 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

19 ©Silberschatz, Korth and Sudarshan2.19Database System Concepts Alternative Notation for Cardinality Limits Cardinality limits can also express participation constraints


Download ppt "ICOM 5016 – Introduction to Database Systems Lecture 4 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,"

Similar presentations


Ads by Google