©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.

Slides:



Advertisements
Similar presentations
Chapter 2: Entity-Relationship Model
Advertisements

Temple University – CIS Dept. CIS616– Principles of Database Systems
Chapter 6: Entity-Relationship Model (part I)
Entity-Relationship Model
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Text-Book Chapters (7 and 8) Entity-Relationship Model
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS157A Lecture 3 ER Diagram Prof. Sin-Min Lee Department of Computer Science San Jose State University.
1 Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Chapter 2: Entity-Relationship Model (Continued)
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com The following slides are.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
©Silberschatz, Korth and Sudarshan1.1Database System Concepts Wat gaan wij leren? Data Bases Data modelleren  Hoe kan ik zien wat voor informatiesysteem.
Entity-Relationship Model
the Entity-Relationship Model
ICOM 5016 – Introduction to Database Systems Lecture 4 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Notes by Ankur Shukla Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys.
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Entity-Relationship Model
Chapter 2: Database Design and Entity-Relationship Model  Database Design  Entity Sets  Relationship Sets  Design Issues  Mapping Constraints  Keys.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Chapter 6: Entity-Relationship Model. Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
6.1 Chapter 6: Database Design and the ER Model Skip 6.5.3, 6.10, 6.11.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapter 6: Entity-Relationship Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Computing & Information Sciences Kansas State University Wednesday, 24 Sep 2008CIS 560: Database System Concepts Lecture 12 of 42 Wednesday, 24 September.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model ([S] Chp. 6) Entity Sets Relationship Sets Design Issues.
Entity Relationship Diagram (2)
ITTelkom Entity Relationship Diagram (1) CS2343 Perancangan Basisdata Relasional.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Database and Information Retrieval System
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
 Design Process  Modeling  Constraints  E-R Diagram  Design Issues  Weak Entity Sets  Extended E-R Features  Design of the Bank Database  Reduction.
Database System Concepts, 5th Ed. Bin Mu at Tongji University Chapter 6: Entity-Relationship Model.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Chapter 6: Entity-Relationship Model. Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the.
CST203-2 Database Management Systems Lecture 4. Student entity NIDFNameLNameRegNoExamIdBirthdate.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS157A Lecture 4 ER Model 2 Prof. Sin-Min Lee Department of Computer Science San Jose State University.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts - 6 th Edition Chapter 7: Entity-Relationship Model.
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
Topic 3: ER – Entity Relationship Model (ERM) 6/12/
Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Chapter 2: Entity-Relationship Model
COP Introduction to Database Structures
Entity Relationship Model
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Presentation transcript:

©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys Participation Constraints E-R Diagram Extended E-R Features Design of an E-R Database Schema Reduction of an E-R Schema to Tables Objective: conceptual DB design using ER diagrams

©Silberschatz, Korth and Sudarshan2.2Database System Concepts Overview of Database Design Conceptual design  Use ER diagrams  Pictorial representation of DB schema  What are the entities and relationships in the enterprise?  E.g. customer & account entity; deposit relationship  What information about the entities and relationships should we store in DB?  What are the integrity constraints or business rules that hold? Logical design  Transform conceptual schema into implementation model  e.g., map an ER diagram into a relational schema Physical design and database tuning

©Silberschatz, Korth and Sudarshan2.3Database System Concepts Entity Sets A database can be modeled as:  a collection of entities,  relationship among entities. An entity is an object that exists and is distinguishable from other objects.  E.g. an individual customer, account Entities have attributes  E.g. people have names and addresses An entity set is a set of entities of the same type that share the same properties.  Example: set of all customers, accounts

©Silberschatz, Korth and Sudarshan2.4Database System Concepts Entity Sets customer and loan customer-id customer- customer- customer- loan- amount name street city number

©Silberschatz, Korth and Sudarshan2.5Database System Concepts Attributes Descriptive properties possessed by all members of an entity set. Domain  set of permitted values for each attribute Attribute types:  Simple and composite attributes.  Single-valued and multi-valued attributes  E.g. multivalued attribute: phone-numbers  Derived attributes  Can be computed from other attributes  E.g. age, given date of birth

©Silberschatz, Korth and Sudarshan2.6Database System Concepts Composite Attributes

©Silberschatz, Korth and Sudarshan2.7Database System Concepts Relationship Sets A relationship is an association among several entities Example: HayesdepositorA-102 customer entityrelationship setaccount entity A relationship set is a mathematical relation among entities {(e 1, e 2, … e n ) | e 1  E 1, e 2  E 2, …, e n  E n } where (e 1, e 2, …, e n ) is a relationship  Example: (Hayes, A-102)  depositor

©Silberschatz, Korth and Sudarshan2.8Database System Concepts Relationship Set borrower

©Silberschatz, Korth and Sudarshan2.9Database System Concepts Degree of a Relationship Set Refers to number of entity sets that participate in a relationship set. Binary Relationship sets  Involve two entity sets  Most relationship sets in DB N-ary Relationships  Not common  Can be converted to binary relations  E.g. Two binary relationships, mother and father, relating a child to her farther and mother vs. one ternary relationship parent

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

©Silberschatz, Korth and Sudarshan2.11Database System Concepts Mapping Cardinalities One to one Customer to SSN One to many Customer to Accounts

©Silberschatz, Korth and Sudarshan2.12Database System Concepts Mapping Cardinalities Many to one More than one customer may share a loan Many to many Also, one customer may have several loans

©Silberschatz, Korth and Sudarshan2.13Database System Concepts Does cardinality affect ER design? Access-date: an attribute in a relationship set  If depositor relationship is one-to-one (many), access date can be an attribute of account entity

©Silberschatz, Korth and Sudarshan2.14Database System Concepts Keys A super key of an entity set  A set of one or more attributes whose values uniquely determine each entity  E.g. customer id & customer name A candidate key  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.  The DB designer has chosen to identify entities  Can customer id be the primary key in customer entity?  Can customer name be the primary key?

©Silberschatz, Korth and Sudarshan2.15Database System Concepts Keys for Relationship Sets The combination of primary keys of the participating entity sets forms a super key of a relationship set.  (customer-id, account-number) is the super key of depositor  Primary-key(E1) U primary-key(E2) … U primary-key(En)  A pair of entity sets can have at most one relationship in a particular relationship set.  E.g. if we wish to track all access-dates to each account by each customer, we cannot assume a relationship for each access. We can use a multivalued attribute though.  Primary-key(E1) U … primary-key(En) U {A1, A2, …, An} when the relationship set has attributes A1, A2, … An

©Silberschatz, Korth and Sudarshan2.16Database System Concepts Participation Constraints Given a relationship set borrower, defined between customer and loan, do you expect every loan entity to be related to at least one customer?  Total participation of loan in the relationship set borrower Is each customer related to a loan entity through the borrower relationship?  Partial participation

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

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

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

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

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

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

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

©Silberschatz, Korth and Sudarshan2.24Database System Concepts Participation of an Entity Set in a Relationship Set Total participation: indicated by double line Partial participation

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

How about doing an ER design interactively on the board? Suggest an application to be modeled.

©Silberschatz, Korth and Sudarshan2.27Database System Concepts E-R Diagram with a Ternary Relationship works-on: naturally non-binary Compare to the case of parent vs. father & mother relations

©Silberschatz, Korth and Sudarshan2.28Database System Concepts 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. R A, relating E and A 2.R B, relating E and B 3. R C, relating E and C  Create a special identifying attribute for E  Add any attributes of R to E  For each relationship (a i, b i, c i ) in R, create 1. a new entity e i in the entity set E 2. add (e i, a i ) to R A 3. add (e i, b i ) to R B 4. add (e i, c i ) to R C

©Silberschatz, Korth and Sudarshan2.29Database System Concepts Weak Entity Sets An entity set that does not have a primary key The existence of a weak entity set depends on the existence of a identifying entity set  it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set  Identifying relationship depicted using a double diamond The discriminator (or partial key) of a weak entity set The primary key of a weak entity set  primary key of the strong entity set + weak entity set’s discriminator.

©Silberschatz, Korth and Sudarshan2.30Database System Concepts Weak Entity Sets (Cont.) Double rectangles Underline the discriminator with a dashed line. payment-number – discriminator of the payment entity set Primary key for payment – (loan-number, payment-number)

©Silberschatz, Korth and Sudarshan2.31Database System Concepts Specialization: ISA Top-down design process 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. Lower-level entity sets can also have attributes or participate in relationships that do not apply to the higher-level entity set.

©Silberschatz, Korth and Sudarshan2.32Database System Concepts Specialization Example

©Silberschatz, Korth and Sudarshan2.33Database System Concepts Design Constraints on a Specialization Constraint on which entities can be members of a given lower-level entity set.  condition-defined  E.g. all customers over 65 years are members of senior- citizen entity set; senior-citizen ISA person.  user-defined Constraint on whether or not entities may belong to more than one lower-level entity set within a single generalization.  Disjoint  an entity can belong to only one lower-level entity set  Noted in E-R diagram by writing disjoint next to the ISA triangle  Overlapping  an entity can belong to more than one lower-level entity set

©Silberschatz, Korth and Sudarshan2.34Database System Concepts Design Constraints on a Specialization (Contd.) Completeness constraint -- specifies whether or not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within a generalization.  Total  An entity must belong to one of the lower-level entity sets  Double line  Partial  An entity need not belong to one of the lower-level entity sets  Default

©Silberschatz, Korth and Sudarshan2.35Database System Concepts Aggregation Used when we have to model a relationship involving (entitity sets and) a relationship set.  Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships.

©Silberschatz, Korth and Sudarshan2.36Database System Concepts Summary of Symbols Used in E-R Notation

©Silberschatz, Korth and Sudarshan2.37Database System Concepts Summary of Symbols (Cont.)

©Silberschatz, Korth and Sudarshan2.38Database System Concepts Summary of Conceptual Design Conceptual design follows requirements analysis,  Yields a high-level description of data to be stored ER model popular for conceptual design  Constructs are expressive, close to the way people think about their applications. Basic constructs: entities, relationships, and attributes (of entities and relationships) Some additional constructs: weak entities, ISA hierarchies, and aggregation

©Silberschatz, Korth and Sudarshan2.39Database System Concepts Summary of ER (Contd.) Several kinds of integrity constraints can be expressed in the ER model: key constraints, participation constraints, and disjoint/overlapping constraints for ISA hierarchies. Some constraints (notably, functional dependencies) cannot be expressed in the ER model.  Constraints play an important role in determining the best database design for an enterprise.

©Silberschatz, Korth and Sudarshan2.40Database System Concepts Summary of ER (Contd.) ER design is subjective. There are often many ways to model a given scenario! Analyzing alternatives can be tricky, especially for a large enterprise. Common choices include: Entity vs. attribute, entity vs. relationship, binary or n-ary relationship, whether or not to use ISA hierarchies, and whether or not to use aggregation. Ensuring good database design: resulting relational schema should be analyzed and refined further. FD information and normalization techniques are especially useful.

End of Chapter 2