Chapter 17 Logical Database Design for the Relational Model Pearson Education © 2009.

Slides:



Advertisements
Similar presentations
The transformation of an ER or EER model into a relational model
Advertisements

Week 5 Relational Database Design by ER- -to-Relational Mapping.
Assignment Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the.
Logical Database Design
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
1 Methodology : Conceptual Databases Design © Pearson Education Limited 1995, 2005.
Methodology Logical Database Design for the Relational Model
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
Entity-Relationship (E-R) Model
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
LOGICAL DATABASE DESIGN
Mapping ERM to relational database
Enhanced Entity-Relationship Model (EER) 1. Enhanced-ER (EER) Model Concepts Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses,
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
ER- and EER-to-Relational Mapping
Chapter 3 Relational Model Chapter 4 in Textbook.
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Ref. Chapter3 Lecture4 1.
Entity-Relationship modeling Transparencies
1 Web-Enabled Decision Support Systems Entity-Relationship Modeling Prof. Name Position (123) University Name.
Chapter 2 Entity-Relationship Model Chapter 11 & 12 in Textbook.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
Entity-Relationship Model
Chapter 5 Entity–Relationship Modeling
Chapter 9 Methodology - Logical Database Design Chapter 16 in Textbook.
CSCI 3140 Module 3 – Logical Database Design for the Relational Model Theodore Chiasson Dalhousie University.
Team Dosen UMN Database Design Connolly Book Chapter
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
CS 3630 Database Design and Implementation. 2 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
Chapter 11 & 12 Entity-Relationship (E-R) Model Characteristics of E-R Model Components of E-R Model Example of E-R Model Enhanced E-R Model.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
Mapping from conceptual model (EER-M)
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
1 Chapter 17 Methodology - Local Logical Database Design.
Data Analysis 3 Chapter 2.3 V3.0 Napier University Dr Gordon Russell.
Entity Relationship Modeling
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
ER/EER to Relational Data Model 1 Database Design.
ER/EER to Relational Mapping Chapter 9. STEP 1 ENTITY TYPE E (non weak) -> NEW RELATION T RELATION T: – includes all simple attributes (non composite,
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences The Relational.
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Prepared by L. Nouf Almujally Ref. Chapter3 Lecture4 1.
Quiz Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
Methodology - Logical Database Design. 2 Step 2 Build and Validate Local Logical Data Model To build a local logical data model from a local conceptual.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Methodology Logical Database Design for the Relational Model
Relational Database Design by ER- and EER-to- Relational Mapping
Logical Database Design for the Relational Model
Logical Database Design for the Relational Model
Chapter Design Methodology Pearson Education © 2009.
Chapter -3- Data Modeling Using the Entity-Relationship Model
CS 3630 Database Design and Implementation
Relational Database Design by ER- and EERR-to-Relational Mapping
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter 4+17 The Relational Model Pearson Education © 2014.
Chapter Entity-Relationship Modeling & Enhanced Entity- Relationship Modeling.
Relational Database Design (Top Down)
Chapter Entity-Relationship Modeling & Enhanced Entity- Relationship Modeling.
Mapping an ERD to a Relational Database
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Mapping an ERD to a Relational Database
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Chapter 17 Logical Database Design for the Relational Model Pearson Education © 2009

2 Chapter 17 - Objectives u How to derive a set of relations from a conceptual data model. u To create relations for the logical data model to represent the entities, relationships, and attributes that have been identified. Pearson Education © 2009

3 Build Logical Data Model Pearson Education © 2009

4 Conceptual data model for Staff view showing all attributes Pearson Education © 2009

5 Derive relations for logical data model u (1)Strong entity types –For each strong entity in the data model, create a relation that includes all the simple attributes of that entity. For composite attributes, include only the constituent simple attributes. (2)Weak entity types –For each weak entity in the data model, create a relation that includes all the simple attributes of that entity. –A weak entity must include its Partial key and its owner entity type PK as a FK. The combination of the two keys form the PK of the weak entity. Pearson Education © 2009

6 Example Pearson Education © 2009 Employee Emp_NO{PK} Name Fname Mname Lname Sex Salary Dep NO Dependent Name Sex Relationship * Dependents of Employee (Emp_NO, Fname,Mname,Lname, Sex, Salary) Primary Key Emp_NO DEPENDENT (DepNo, EmpNo, Name, Sex, Relationship ) Primary Key DepNo, EmpNo Partial Key of Week entity

7 Derive relations for logical data model u (3)One-to-many (1:*) binary relationship types –For each 1:* binary relationship, the entity on the ‘one side’ of the relationship is designated as the parent entity and the entity on the ‘many side’ is designated as the child entity. To represent this relationship, post a copy of the Primary Key attribute(s) of parent entity into the relation representing the child entity, to act as a foreign key. OR –Entity with many cardinality in relationship is designated as parent entity, and entity with one cardinality is designated as child entity. Pearson Education © 2009

8 Example Pearson Education © 2009 Employee Emp_NO{PK} Name Sex Salary Branch Branch_No {PK} Branch Name 1..* 0..1 Allocates Employee (Emp_NO, Name, Sex, Salary, Branch No) Primary Key Emp_NO Branch (Branch_No, Branch Name) Primary Key Branch_No Child entity Parent entity

9 Derive relations for logical data model u (4)One-to-one (1:1) binary relationship types –Creating relations to represent a 1:1 relationship is more complex as the cardinality cannot be used to identify the parent and child entities in a relationship. Instead, the participation constraints are used to decide whether it is best to represent the relationship by combining the entities involved into one relation or by creating two relations and posting a copy of the Primary Key from one relation to the other. –Consider the following »(a) mandatory participation on both sides of 1:1 relationship; »(b) mandatory participation on one side of 1:1 relationship; »(c) optional participation on both sides of 1:1 relationship. Pearson Education © 2009

10 Derive relations for logical data model u (a)Mandatory participation on both sides of 1:1 relationship –Combine entities involved into one relation and choose one of the primary keys of original entities to be Primary Key of the new relation, while the other (if one exists) is used as an alternate key. Pearson Education © 2009

11 Example Pearson Education © 2009 Employee SSN{PK} Name Fname Mname Lname Employee Info Emp_NO{PK} Sex Salary DOB 1..1 has Employee (Emp_NO, SSN, Fname,Mname,Lname, Sex, Salary, DOB) Primary Key Emp_NO OR Employee (SSN, Emp_NO, Fname,Mname,Lname, Sex, Salary,DOB) Primary Key SSN

12 Derive relations for logical data model u (b)Mandatory participation on one side of a 1:1 relationship –Identify parent and child entities using participation constraints. Entity with optional participation in relationship is designated as parent entity, and entity with mandatory participation is designated as child entity. A copy of Primary Key of the parent entity is placed in the relation representing the child entity. If the relationship has one or more attributes, these attributes should follow the posting of the Primary Key to the child relation. Pearson Education © 2009

13 Example Pearson Education © 2009 Employee Emp_NO{PK} Name Sex Salary Branch Branch_No {PK} Branch Name Manages Employee (Emp_NO, Name, Sex, Salary) Primary Key Emp_NO Branch(Branch_No, Branch Name,_Emp_NO Sdate,Edate) Primary Key Branch_No Parent entity Child entity Sdate Edate

14 Derive relations for logical data model u (c)Optional participation on both sides of a 1:1 relationship »In this case, the designation of the parent and child entities is arbitrary unless we can find out more about the relationship that can help a decision to be made one way or the other. Pearson Education © 2009

15 Example Pearson Education © 2009 Operation Op_NO{PK} Surgery_Material SM_No {PK} Statues 0..1 Uses Operation (Op_NO, ……) Surgery_Material (SM_No, Statues,Op_NO) Child entity Parent entity Operation (Op_NO, ……, SM_No) Surgery_Material (SM_No, Statues) Parent entity We have the choice to post a copy of the Primary Key of Operation entity to Surgery_Material entity or vice versa.

16 Example Pearson Education © 2009 Employee Emp_NO{PK} Name Sex Salary Car Car_No {PK} Statues 0..1 Uses Parent entity Child entity Employee (Emp_NO, Name, Sex, Salary) Primary Key Emp_NO Car (Car_NO, Statues, Emp_NO) Primary Key Car_NO If we assume the majority of cars but not all, are used by employee and that minority of employee use cars. Therefore: - The care entity is closer to begin mandatory than employee entity.

(5)Recursive relationships Mapping conclusion a) One-to-one (1:1) recursive relationships Single relation with two copies for the primary key with different names. b) One-to-many (1:*) recursive relationships Single relation with two copies for the primary key with different names. c) Many-to-many (*:*) recursive relationships Tow relations »One relation for the entity type. »And create a new relation to represent the relationship. The new relation would only have two attributes, both copies of the primary key. 17

18 Example a) One-to-one (1:1) recursive relationships Pearson Education © Contains Main Project(Pro_No,SubPro_No, Statues) OR Project(Pro_No,MainPro_No, Statues) Project Pro_No {PK} Statues Sub Business rule: Each project must contain anther project, no more. This case occurs rarely in real life applications.

19 Example a) One-to-one (1:1) recursive relationships Pearson Education © Contains Main Project(Pro_No,MainPro_No, Statues) Project Pro_No {PK} Statues Sub Business rule: Each project may contain anther project, no more.

20 Example b) One-to-many (1:*) recursive relationships Pearson Education © * 1..1 Has Parts Item(Item_No,Base_No, Size) Item Item No{PK} Size Base

21 Example c) Many-to-many (*:*) recursive relationships Pearson Education © * Contains Parts Item(Item_No, Size) Parts(Item_No, Parts_No ) Item Item No{PK} Size Base

22 Derive relations for logical data model u (6)Superclass/subclass relationship types –Identify superclass entity as parent entity and subclass entity as the child entity. There are various options on how to represent such a relationship as one or more relations. –The selection of the most appropriate option is dependent on a number of factors such as the disjointness and participation constraints on the superclass/subclass relationship, whether the subclasses are involved in distinct relationships, and the number of participants in the superclass/subclass relationship. Pearson Education © 2009

23 Guidelines for representation of superclass / subclass relationship Pearson Education © 2009

24 Representation of superclass / subclass relationship based on participation and disjointness Pearson Education © 2009

25 Representation of superclass / subclass relationship based on participation and disjointness Pearson Education © 2009

26 Representation of superclass / subclass relationship based on participation and disjointness Pearson Education © 2009

27 Representation of superclass / subclass relationship based on participation and disjointness Pearson Education © 2009

28 Derive relations for logical data model u (7)Many-to-many (*:*) binary relationship types –Create a relation to represent the relationship and include any attributes that are part of the relationship. We post a copy of the Primary Key attribute(s) of the entities that participate in the relationship into the new relation, to act as foreign keys. These foreign keys will also form the Primary Key of the new relation, possibly in combination with some of the attributes of the relationship. Pearson Education © 2009

29 Example Pearson Education © 2009 Employee Emp_NO{PK} Name Sex Salary Project Proj_No {PK} Project Name 1..* 0..* Works on Employee (Emp_NO, Name, Sex, Salary, Branch No) Primary Key Emp_NO Project (Proj_No, ProjectName) Primary Key Proj_No Work-on(EmpNo,ProjNo, hours) Primary Key Emp_NO Proj_No, Hours

30 Derive relations for logical data model u (8)Complex relationship types –Create a relation to represent the relationship and include any attributes that are part of the relationship. Post a copy of the Primary Key attribute(s) of the entities that participate in the complex relationship into the new relation, to act as foreign keys. Any foreign keys that represent a ‘many’ relationship (for example, 1..*, 0..*) generally will also form the Primary Key of this new relation, possibly in combination with some of the attributes of the relationship. Pearson Education © 2009

31 Example Pearson Education © 2009 Business BizNo {PK} Supplier SupNo {PK} Contracts Business (BizNo., ……) Supplier(SupNo, ……..) Lawyer(LawNo,…….…) Contract(BizNo, SupNo, LawNo, StDate, EDate) Lawyer LawNo, {PK}Sdate Edate

32 Derive relations for logical data model u (9)Multi-valued attributes –Create a new relation to represent multi-valued attribute and include Primary Key of entity in new relation, to act as a foreign key. Unless the multi-valued attribute is itself an alternate key of the entity, the Primary Key of the new relation is the combination of the multi-valued attribute and the Primary Key of the entity. Pearson Education © 2009

33 Example Pearson Education © 2009 Employee Emp_NO{PK} Name Sex Salary Tel_no [1..*] Employee (Emp_NO, Name, Sex, Salary) Primary Key Emp_NO Telephone(Tel_no, EmpNo) Primary Key Tel_no OR Telephone(Tel_no, EmpNo) Primary Key Tel_no, EmpNo The Primary Key of new relation: - the multi-valued attribute if itself an alternate key. ( e.g. we sure that there are no duplicated tel_nos for employees ). -OR the combination of the multi- valued attribute and the Primary Key of the entity. ( e.g. 2 brothers work in same company).

34 Summary of how to map entities and relationships to relations Pearson Education © 2009