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.

Slides:



Advertisements
Similar presentations
Chapter 2: Entity-Relationship Model
Advertisements

Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
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.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Database Management Systems I Alex Coman, Winter 2006 Entity-Relationship.
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.
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.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Entity-Relationship Model
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.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
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.
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
©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.
©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.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Entity Relationship Diagram (2)
DATABASE MANAGEMENT SYSTEM Entity-Relationship Model.
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,
International Computer Institute, Izmir, Turkey E-R Model Asst.Prof.Dr.İlker Kocabaş UBİ502 at
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 Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Chapter 2: Entity-Relationship Model. 3.2 Chapter 2: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity.
©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.
Database System Concepts, 5th Ed. ©Sang Ho Lee Chapter 6: Entity-Relationship Model.
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
Entity-Relationship Model
Chapter 7 Entity-Relationship Model
Outline of the ER Model By S.Saha
Chapter 6: Entity-Relationship Model
Chapter 6: 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.
Chapter 2: Entity-Relationship Model
Presentation transcript:

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 are specific objects in the real world that are represented in the DB. n Definition An entity is represented by a set of attributes whose properties are used to describe an entity. n Definition The domain of an attribute is a set of permitted values for that attribute. n Definition A relationship relates two or more (distinct) entities with a specific meaning.  the degree (binary, ternary, …) of a relationship is the number of participating entities.  may have its own attributes, called descriptive attributes  can relate 2 entities of the same type (in a recursive relationship), and thus each entity plays a different role in the relationship.

3 Entity-Relationship Model Symbol Meaning Entity Set Weak Entity Set Relationship Set Attribute Key Attribute

4 Entity-Relationship Model Symbol Meaning Mapping Cardinality 1:1 for E 1 :E 2 in R R E1E1 E2E2 R E1E1 E2E2 Mapping Cardinality 1:n for E 1 :E 2 in R R E1E1 E2E2 Mapping Cardinality n:m for E 1 :E 2 in R R E2E2 A B Roles (A and B)

5 Attributes n An entity is represented by a set of attributes, which 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) n Domain – the set of permitted values for each attribute n Attribute types:  Simple and composite attributes (e.g., name: first, middle, last).  Single-valued and multi-valued attributes (e.g., phone-numbers)  Derived attributes can be computed from other attributes (e.g., age, given date of birth)

6 Composite Attributes Example.

7 Composite, Multivalued & Derived Attributes Example.

8 Relationship Sets with Attributes Example

9 Mapping Cardinality r 1 r 2 r 3 r 4 r 5 r 6 r 7 e 1 e 2 e 3 e 4 e 5 e 6 e 7 d1d1 d 2 d3d3 Employee Works_for Department Figure. An instance of the m:1 relationship set Works_for Employee Manages Department e 1 e 2 e 4 e 5 e 7 e 3 e 6 r 1 r 2 r 3 d1d1 d 2 d3d3 Figure. The 1:1 relationship set Manages

10 Mapping Cardinality Figure The M:N relationship set Works_on Employee Works_on Project r 1 r 2 r 3 r 4 r 5 r 6 r 7 e 1 e 2 e 3 e 4 p1p1 p 2 p3p3 p4p4 Figure The recursive relationship set Supervision-Employee plays 2 roles. ‘1’: Supervisor ‘2’: Supervisee Employee e 1 e 2 e 4 e 5 e 7 e 3 e 6 r 1 r 2 r 3 r 4 r 5 r 6 Supervision

11 Participation of an Entity Set in a Relationship Set n 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 n Partial participation: some entities may not participate in any relationship in the relationship set (default)  e.g., participation of customer in borrower is partial

12 Alternative Notation for Cardinality Limits n Cardinality limits can also express participation constraints, but not vice versa (due to the explicit min..max constraint specification)

13 Weak Entity Sets n The existence of a weak entity set depends on the existence of an identifying (strong) entity set  Must relate to the identifying entity set via a total, many-to-one relationship set from the weak to the identifying entity set  Identifying relationship depicted using a double diamond n An entity set that does not have a primary key is referred to as a weak entity set. n The discriminator (or partial key) of a weak entity set is the set of attributes that (along with the primary key of its owner entity set) distinguishes among all the entities of a weak entity set. n The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence dependent, plus the weak entity set’s discriminator.

14 Weak Entity Sets  We depict a weak entity set by double rectangles.  We underline the discriminator of a weak entity set with a dashed line.  e.g., payment-number – discriminator of the payment entity set n Primary key: for payment (loan-number, payment-number)

15 Weak Entity Sets n A weak entity set can participate  in (regular) relationships other than the identifying relationship  as owner in an identifying relationship with another weak entity set.  with more than one identifying entity set and each weak entity is identified by a combination of the identifying entities. n A weak entity set can be expressed as a multivalued, composite attribute of the strong entity set  More appropriate if  Less appropriate if it participates in relationships other than the identifying relationship. (i) it participates in only the identifying relationship, or (ii) its content can never be null.

16 Weak Entity Sets n Note: the primary key of the strong entity set is not explicitly stored with the weak entity set, since it is implicit in the identifying relationship.  If loan-number were explicitly stored, payment could be made a strong entity, but then the relationship between payment and loan would be duplicated by an implicit relationship defined by the attribute loan-number common to payment and loan n A weak relationship set should have no descriptive attributes, since any required attributes can be associated with the weak entity set

17 Weak Entity Sets n Another Example.  In a university, a course is a strong entity and a course- offering can be modeled as a weak entity.  The discriminator of course-offering would be semester (including year) and section# (multi-sections).  If we model course-offering as a weak entity, we would model course# as an attribute. Then the relationship with course would be implicit in the course# attribute. Course Course-Offering #Enroll Offers Crhrs Semester Section# Course#

18 Entity-Relationship Model n Definition A weak entity set is a set of weak entities, each of which does not have a primary key of its own.  Each weak entity is existence-dependent on a strong entity n Definition The primary key of a weak entity set is formed by the primary key of its strong entity set + its partial key (discriminator).  A partial key is a set of attributes that can uniquely identify weak entities related to the same strong entity. n Definition (Keys for Relationship Sets) Let R be a relationship set relating entity sets E 1, E 2, …, E n. Let attr(R) = {a 1, …, a m }, m  0, be the set of (descriptive) attributes in R. Let fk(R) = primary_key(E 1 )  primary_key(E 2 )  …  primary_key(E n ) Case 1. Attr(R) =  If R is n-m, then primary_key(R) = fk(R). If R is 1-n, then primary_key(R) is the primary_key of the “n-side.” If R is 1-1, then primary_key(R) = primary_key(E i ), 1  i  n, i.e., one of the primary keys of the entity sets. Case 2. Attr(R)   Same as (1) except S  Attr(R) may become part of the primary key.

19 Entity-Relationship (E-R) Diagram n Graphically represents the overall logical structure of a DB n Representing E-R by tables

20 E-R RepresentationTable Strong entity set E: a 1, a 2, …, a n Table: E; Columns: a 1, a 2, …, a n ; Rows: entities of E. Weak entity set A: a 1, a 2, …, a n Table: A; depending on the strong entityColumns: a 1, …, a n, b 1, …, b m ; set B w/ primary key b 1, …, b m Row: entities of A Relationship set R: E 1, E 2, …, E m Table: R; and set of attrs fk(R) and Attr(R) Columns: fk(R) and Attr(R); Row: relationships of R Relationship set linking weak andNone strong entity sets Recursive relationship set R: E 1, E 1 Table: R; Columns: fk(R); Row: relationships of R Containment (ISA) relationship set None linking higher-level and lower- level entity sets

21 Specialization n Top-down design process: we designate subgroupings within an entity set that are distinctive from other entities in the set. n These subgroupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set. n Depicted by a triangle component labeled ISA (e.g., customer “is a” person). n 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.

22 An Entity-Relationship Diagram Advisor Assistantship Major Status SSNO Name Grad_Std STUDENT ISA Undergrad_Std College Minor Example

23 Specialization Another Example.

24 Generalization n A bottom-up design process – combine a number of entity sets that share the same features into a higher-level entity set. n Specialization and generalization are simple inversions of each other; they are represented in an E-R diagram in the same way. n The terms specialization and generalization are used interchangeably.

25 Constraints on a Specialization/Generalization n Constraints on which entities can be members of a given lower- level entity set.  Condition-defined (i.e., pre-defined constraint) e.g., all customers over 65 years are members of senior-citizen entity set; senior-citizen ISA person.  User-defined (default) n Constraints 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 in E-R diagram by writing disjoint next to the ISA triangle  Overlapping (default) an entity can belong to more than one lower-level entity set

26 Constraints on a Specialization/Generalization n 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  Partial (default): an entity need not belong to one of the lower-level entity sets

27 Symbols of E-R Model

28 Redundancy of Tables n Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the many side, containing the primary key of the one side  e.g.: Instead of creating a table for relationship account- branch, add an attribute branch to the entity set account

29 Redundancy of Tables n For one-to-one relationship sets, either side can be chosen to act as the “many” side  i.e., extra attribute can be added to either of the tables corresponding to the two entity sets n If participation is partial on the many side, replacing a table by an extra attribute in the relation corresponding to the “many” side could result in null values n The table corresponding to a relationship set linking a weak entity set to its identifying strong entity set is redundant.  e.g., the payment table already contains the information that would appear in the loan-payment table (i.e., the columns loan-number and payment-number).

30 Composite and Multivalued Attributes n Composite attributes are flattened out by creating a separate attribute for each component attribute  e.g., given entity set customer C with composite attribute name and component attributes first-name and last-name, the table corresponding to C has two attributes name.first-name and name.last-name n A multivalued attribute M of an entity E is represented by a separate table EM  Table EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M  e.g., multivalued attribute dependent-names of employee is represented by a table employee-dependent-names(employee-id, dname)  Each value of the multivalued attribute maps to a separate row of the table EM. e.g., (John, {Mary, Paul}) and maps to two rows: (John, Mary) and (John, Paul)

31 Representing Specialization as Tables n Method 1:  Form a table for the higher level entity  Form a table for each lower level entity set, include primary key of higher level entity set and local attributes  Example. Table Table Attributes person name, street, city customer name, credit-rating employee name, salary  Drawback: getting all information about, e.g., employee, requires accessing two tables

32 Representing Specialization as Tables n Method 2:  Form a table for each entity set with all local and inherited attributes Table Table Attributes person name, street, city customer name, street, city, credit-rating employee name, street, city, salary n Drawback: street and city may be stored redundantly for persons who are both customers and employees  If specialization is total, no need to create table for generalized entity (person)

33 An Entity-Relationship Diagram Title Fee

34 E-R Diagram for a Banking Enterprise