University of Milano Bicocca Carlo Batini Course on Data Base Design

Slides:



Advertisements
Similar presentations
Three-Step Database Design
Advertisements

Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Systems Development Life Cycle
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Modern Systems Analysis and Design Third Edition
Entity/Relationship Modelling
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
Data Modeling Using the Entity-Relationship Model
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
CIS 210 Systems Analysis and Development Week 6 Part II Designing Databases,
IE 423 – Design of Decision Support Systems Data modeling and database development.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Data Modelling Using Entity-Relationship (ER) Model
Lecture 03 Entity-Relationship Diagram. Chapter Outline.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
Data modeling Process. Copyright © CIST 2 Definition What is data modeling? –Identify the real world data that must be stored on the database –Design.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Logical Database Design and the Relational Model.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
April 20022/CS/3X1 Database Design Design method John Wordsworth Department of Computer Science The University of Reading Room.
Data Modeling Using the Entity- Relationship (ER) Model
Universita’ di Milano Bicocca Carlo Batini Course in Data Base Design
Entity/Relationship Modelling
Data Modeling Using the ERD
Database Development Lifecycle
Data Modeling Using the Entity- Relationship (ER) Model
University of Milano Bicocca, Italy Carlo Batini
Entity- Relationship (ER) Model
ER model Ashima Wadhwa.
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
University of Milano Bicocca, Italy Carlo Batini
Chapter 5: Logical Database Design and the Relational Model
Chapter -3- Data Modeling Using the Entity-Relationship Model
Entity-Relationship Modelling
Chapter 7 Entity-Relationship Model
Relational Database Design by ER- and EER-to-Relational Mapping
Modern Systems Analysis and Design Third Edition
بسم الله الرحمن الرحيم.
Conceptual data modeling
EDUOPEN Carlo Batini University of Milano Bicocca, Italy
Translation of ER-diagram into Relational Schema
CIS 336 Teaching Effectively-- snaptutorial.com
Entity-Relationship Model and Diagrams (continued)
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Chapter 3 The Relational Model.
Translation of ER-diagram into Relational Schema
Chapter 10 Designing Databases
Entity-Relationship Modelling
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Data Modeling for Database Design 2
Database Modeling using Entity Relationship Model (E-R Model)
Faloutsos - Pavlo C. Faloutsos - A. Pavlo Lecture#2: E-R diagrams
Conceptual Data Modeling Using Entities & Relationships
Introduction to modeling
CS4222 Principles of Database System
Chapter 3 The Relational Model
Presentation transcript:

University of Milano Bicocca Carlo Batini Course on Data Base Design Part 5 – Logical Design

© Carlo Batini, 2015 This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/

Low level conceptual map

Logical design as a black box Conceptual schema Queries Transactions Application load Logical design Logical model Logical schema

Logical design in the relational model Conceptual schema Logical design Relational schema Query load Relational model

Notation simplification

Diagrammatic notation for ER diagrams adopted so far Student Id B Course Student Name Exam (1,n) Foreing Chinese Surname Grade Date Course Id Country

Simplified notation adopted in this chapter Student Id Surname Identifier of Entity B Course Student Course Id Name Exam (1,n) Foreing Chinese Grade Date Country Attribute of Entity Attributes of Relationship

Translation of entities and relationships into relational tables

How to translate generalizations? Student Id Surname B Student Foreing Chinese Country ?

Optimization design issues - Computer structure: CPU and memories Student Id Surname B Student Course Course Id Name Exam (1,n) Grade Student (Student Id, Surname) Exam (Student Id, Course Id, Grade) Course (Course Id, Name) Central Processing Unit Main memory Secondary Memory Channels 10-8/10-9 seconds 10-2

An example of partitioning Employee Id Place of Birth Date of Birth Level Salary Taxes B Employee Employee Id Level Salary Taxes B Empl1 Empl2 Place of Birth Date of Birth splitted (1,n)

Transformation for achieving efficiency Student Id Surname B Student Course Course Id Name Exam (1,n) Grade Student Id Course Id Surname Grade B Student Course

An entity with two groups of attributes accessed separately by queries

The three steps of logical design Conceptual schema in the ER model Simplification and optimization Simplified and optimized conceptual schema in the ER model Translation Relational schema

An ER schema with redundancies Student Id Surname # of Exams passed (1,n) (1,n) Course Id Name Student B Course Exam Grade Date

An entity with two identifiers and the two possible choices as primary keys Student Id Social Security Number Given Name Last Name B Student Student (Student Id, Social Security Number, Given Name, Last Name)

Simplification and optimization in Atzeni’s book and in this Part 5 Four steps Course Student Id Surname # of Exams passed B Student Course Id Name Exam (1,n) Grade Date 1. Redundancy analysis 2. Removing generalizations Simplification step Optimization step Merging Partitioning 3. Partitoning and/or merging of entities/relationships 4. In case of multiple identifiers, choice of identifier to be translated into the primary key

Restructuring of Generalizations example IdA A1 A2 B A C C1 B1 D A-D (1,n) E C-E B1

Relevant cases of generalization restructurings B A C ABC Case 1 Case 2 Case 3

First case of restructuring IdA A1 A2 B A C C1 B1 D A-D (1,n) E C-E

First case of restructuring

Corresponding assignment of properties to new constructs in case 1 IdA A1 A2 B A C C1 B1 D A-D (1,n) E C-E Type (0,n) ABC B1

Case 2

Corresponding assignment of properties to new constructs in case 2 IdA A1 A2 B A C C1 B1 D A-D (1,n) E C-E (0,1) (1,1) A-B A-C B1

Restructuring of Generalizations third case IdA A1 A2 IdA A1 A2 B1 D A-D (1,n) (1,n) (1,n) B A B A-D D D A-D (1,n) (1,n) (1,n) IdA A1 A2 C1 C B C C-E E B1 C1 C-E (1,n) E B1

Third case of restructuring

The schema of the motivating example after the simplification step Course Course Id Name Exam (1,n) Grade Date Student Id Surname B Student Foreing Chinese Country Type

Entity partitioning B Course B Student Student- Exam-Course Student Id Surname Type Country (1,n) (1,n) Course Id Name Student B Course Exam Grade Date Student Id Surname Course Id Name Type Country Grade Date Student- Exam-Course B

The three cases of entity (and related relationship) merging KE1 KE2 E3 E4 B E12 E1 many E2 one or

Result of merging in the motivating example

Transaltion of Entity B Student Student ID Given Name Surname Place of Birth B Student Student (Student Id, Given Name, Surname, Place of Birth)

Applying the translation in the motivating example Student Id Surname Course Id Name Type Country Grade Date Student- Exam-Course B Student-Exam-Course (Student Id, Course Id, Surname, Name, Type, Country, Grade, Date)

Example considered in the translation of many to many binary relationship

Translation of many to many relationships Student Id Given Name Surname Place of Birth B Student Course Exam (1,n) Grade Date Course Id Name # of Hours Student (Student Id, Given Name, Surname, Place of Birth) Exam (Student Id, Course Id, Grade, Date) Course (Course Id, Name, # of hours)

Translation of many to many relationships Student Id Given Name Surname Place of Birth B Student Course Exam (1,n) Grade Date Course Id Name # of Hours Student (Student Id, Given Name, Surname, Place of Birth) Exam (Student Id, Course Id, Grade, Date) Course (Course Id, Name, # of hours)

Do not forget referential integrity constraints… Student Id Given Name Surname Place of Birth B Student Course Exam (1,n) Grade Date Course Id Name # of Hours Student (Student Id, Given Name, Surname, Place of Birth) Exam (Student Id, Course Id, Grade, Date) Course (Course Id, Name, # of hours)

Translation of ternary relationships IdA A1 A2 B A A-B-C (1,n) C IdB B1 IdC C1 C2 C3 ABC1 ABC2 A (IdA, A1, A2) B (IdB, B1, B2) A-B-C (IdA, IdB, IdC, ABC1, ABC2) C (IdC, ABC1, ABC2)

Example of many to many recursive relationship Person Id Given Name Surname Person B (1,n) (1,n) Person A Person B Relative Type of parental Relationship Person (Person Id, Given Name, Surname) Relative (Person IdA, Person IdB, Type of parental relationship)

Translation of one to many relationships Student Id Given Name Surname Place of Birth B Student Country Born (1,1) (1,n) Country Id Name Continent Student (Student Id, Given Name, Surname, Place of Birth, Country) Country (Country Id, Name, Continent)

Translation of entity with external identifier Student Id B Student University St-Un (1,1) (1,n) Surname Name City Student (Student Id, University, Surname) University (Name, City)

(1,1) to (1,1) Relationships A B Solution 1 A (KA, A1, KB) B (KB, B1, B2) Solution 2 A (KA, A1) B (KB, B1, B2, KA) A KA A1 A-B B (1,1) KB B1 B2

Translation of (0,1) to (1,1) Relationships Solution 1 A (KA, A1) B (KB, B1, B2, KA) A KA A1 A-B B (0,1) (1,1) KB B1 B2 Solution 2 A (KA, A1, KB) B (KB, B1, B2)

The two cases of translation in the case (0,1) to (1,1) and corresponding instances B KA A1 KB ka1 a11 null ka2 a12 kb1 ka3 a13 ka4 a14 kb2 ka5 a15 kb3 ka6 a16 kb4 KB B1 B2 kb1 b11 b21 kb2 b12 b22 kb3 b13 b23 kb4 b14 b24 Solution 1 A (KA, A1, KB) B (KB, B1, B2) A KA A1 A-B B (0,1) (1,1) KB B1 B2 A B KA A1 ka1 a11 ka2 a12 ka3 a13 ka4 a14 ka5 a15 ka6 a16 KB B1 B2 KA kb1 b11 b21 ka2 kb2 b12 b22 ka4 kb3 b13 b23 ka5 kb4 b14 b24 ka6 Solution 2 A (KA, A1) B (KB, B1, B2, KA)

The three solutions for the (0,1) and (0,1) case KA A1 A-B B (0,1) KB B1 B2 Solution1 A (KA, A1) B (KB, B1, B2, KA) Solution 2 A (KA, A1, KB) Solution 3 B (KB, B1, B2) A-B (KA, KB)

Exercise 5.1

Exercise 5.1: Output of simplification and optimization RBG (0,1) KB B1 (1,n) (1,1) KA A1 B B RAB A (0,1) (1,n) G KG G1 RAGL (1,n) H (1,n) C1 C2 D1 D2 E E1 E2 L KL L1 C D RCD (0,n) (0,n)

Exercise 5.1: Output of simplification and optimization B A C D KB B1 D1 D2 E1 E2 KA A1 RBG RAB RAGL L G E RCD KG G1 KL L1 (0,n) H (1,1) (0,1) (1,n)

Exercise 5.1: Output of simplification and optimization B A BCDE KB B1 C1 C2 D1 D2 E1 E2 TYPE KA A1 RBG RAB RAGL L G KL L1 (0,n) H (1,1) (0,1) (1,n) RCD

Exercise 5.1: Steps of translation B A BCDE KB B1 C1 C2 D1 D2 E1 E2 TYPE KA A1 RBG RAB RAGL L G KG G1 KL L1 (0,n) H (1,1) (0,1) (1,n) RCD Legenda many to many relationships one to many relationships one to one relationships entities

Exercise 5.1: Output of transation RBCDE (KB, B1, C1, C2, D1, D2, E1, E2, TYPE) RA (KA, A1) RG (KG, G1) RL (KL, L1) RCD (KBC, KBD) RBG (KB, KG) RAGL (KA, KG, KL, H)

Exercise 5.1: Adding referential integrity constraints RBCDE (KB, B1, C1, C2, D1, D2, E1, E2, TYPE) RA (KA, A1) RG (KG, G1) RL (KL, L1) RCD (KBC, KBD) RBG (KB, KG) RAGL (KA, KG, KL, H)

Exercise 5.1: Adding referential integrity constraints RBCDE (KB, B1, C1, C2, D1, D2, E1, E2, TYPE) RA (KA, A1, KB) RG (KG, G1) RL (KL, L1) RCD (KBC, KBD) RBG (KB, KG) RAGL (KA, KG, KL, H)

Exercise 5.2

Exercise 5.2 A B D C E F G B1 KA A1 E1 EF1 KD D1 RAB (0,1) REF (1,n) KG G1 G2 G3 G4 G5 RFG F1

Exercise 5.2: Output of simplification B DEF KA A1 B1 KD D1 E1 F1 RBD (0,1) (0,n) REF EF1 C1 C RCD E F G KG G1 G2 G3 G4 G5 (1,n) RFG

Exercise 5.2: Output of optimization B DEF KA A1 B1 KD D1 E1 F1 RBD (0,1) (0,n) REF EF1 C1 C G1 KG1 G11 G21 RFG1 (1,n) RCD E G2 RFG2 KG2 G3 G4 G5 F G12 (1,1)

Exercise 5.1: Output of transation B (KA, A1, B1, KD) C (KA, A1, B1, KD) DEF (KD, D1, E1, F1, KG1, KG2) G1 ( KG1, G11, G21, KG2) G2 (KG2, G3, G4, G5) REF (KD1, KD2, EF1)

Exercise 5.2: Adding referential integrity constraints B (KA, A1, B1, KD) C (KA, A1, B1, KD) DEF (KD, D1, E1, F1, KG1,KG2) G1 ( KG1, G1, G2, KG2) G2 (KG2, G3, G4, G5) REF (KD1, KD2, EF1)

University Database Example

Exercise 5.3 Course Student Foreign St. Chinese St. Department Country ID Last Name First Name Name Year of Enrollment Passed Enrolled in Course (1,n) (0,n) Student Grade Date (1,1) Teach Foreign St. Chinese St. Professor First Name Last (1,n) Born Country Name Continent (1,n) (1,1) Born (1,n) (1,1) Department (1,1) (1,n) Belongs to Associate Professor Full Professor Name Address Name Region City Born in (1,1) (1,n)

Exercise 5.3 - Output of Simplification and Optimization First Name Last City Born in (1,1) ID Teach Region Full Professor Department many Address Year of Enrollment Passed Enrolled in Course (1,n) (0,n) Grade Date Born Country Continent Student (0,1) Works in Associate Professor Type

Exercise 5.3 - Output of Simplification and Optimization Student Student Foreign St. Chinese St. Professor Full Professor Associate Professor Full Professor Associate Professor

Exercise 5.3 - Output of Translation Student (Student Id, Last Name, First Name, Type, City, Country) Course (Course Id, Year of Enrollment) Enrolled in (Student Id, Course Id) Passed (Student Id, Course Id, Grade, Date) Full Professor (Last Name, First Name, Department Name, City) Associate Professor (Last Name, First Name, Department Name) Department (Name, Address) City (Name, Region) Foreign Student (Student Id, Country) Chinese Student (Student Id, City of Birth) Country (Name, Continent)

Exercise 5.3 - Adding referential integrity constraints Student (Student Id, Last Name, First Name, Type, City, Country) Course (Course Id, Year of Enrollment) Enrolled in (Student Id, Course Id) Passed (Student Id, Course Id, Grade, Date) Full Professor (Last Name, First Name, Department Name, City) Department (Name, Address) Associate Professor (Last Name, First Name, Department Name) City (Name, Region) Foreign Student (Student Id, Country) Chinese Student (Student Id, City of Birth) Country (Name, Continent)

Concepts introduced in Part 5 Part 5 - Logical Design Phase of Logical Design Simplification and Optimization Translation Simplification Phase Removing Generalizations Optimization Phase Partitoning of Entities/Relationships Merging of Entities/Relationships Translation Step (Translation of an) Entity Many to Many Relationship One to Many Relationship Ternary Relationship Recursive Relationship (1,1) to (1,1) Relationship (0,1) to (1,1) Relationship (0,1) to (0,1) Relationship

Resti

Normalization B City B City Country Student Student Student Id born (1,1) (1,n) Last Name City Name Country Continent Student Id B Student born (1,1) Last Name City (1,n) Name in Country Continent

Motivating Example B Course B Student Student Foreing Chinese Foreing Course Id Name Exam (1,n) Grade Date Student Id Surname B Student Foreing Chinese Country Student Id Surname B Student Foreing Chinese Country

Corresponding assignment of properties to new constructs in case 3

Restructuring generalizations in the motivating example

Translation of ER modeling constructs Student Id Surname B Student Course Course Id Name Exam (1,n) Grade Student Id Surname Student Id Course Id Grade Course Id Name Student Id Surname B Student Foreing Chinese Country ?

Choice among multiple identifiers Employee Id Place of Birth Date of Birth Level Salary Taxes B Employee

Simplification and optimization step Four steps Course Student Id Surname # of Exams passed B Student Course Id Name Exam (1,n) Grade Date 1. Redundancy analysis 2. Removing generalizations Simplification step Optimization step Merging Partitioning 3. Partitioning and/or merging of entities/relationships 4. In case of multiple identifiers, choice of identifier to be translated into the primary key

Simplification and optimization step Course Student Id Surname # of Exams passed B Student Course Id Name Exam (1,n) Grade Date 1. Redundancy analysis 2. Removing generalizations Simplification step 3. Partitioning or merging of entities 4. In case of multiple identifiers, choice of identifier to be translated into the primary key Optimization step Merging Partitioning

Removing generalizations Student Id Surname Student B ? Chinese Student Foreing Student Country

Simplification

Optimization – entity partitioning Employee Id Level Salary Taxes B Empl1 Empl2 Place of Birth Date of Birth Same as (1,n) Employee

(0,1) to (1,1) Relationships A B A B A B Solution 1 A (KA, A1) KB B1 B2 A B Solution 1 A (KA, A1) B (KB, B1, B2, KA) KA A1 ka1 a11 ka2 a12 ka3 a13 ka4 a14 KB B1 B2 KA kb1 b11 b21 ka1 kb2 b12 b22 ka2 kb3 b13 b23 ka3 kb4 b14 b24 ka4 A B A KA A1 A-B B (0,1) (1,1) KB B1 B2 Solution 2 A (KA, A1, KB) B (KB, B1, B2) KA A1 KB ka1 a11 null ka2 a12 kb1 ka3 a13 ka4 a14 kb2 KB B1 B2 kb1 b11 b21 kb2 b12 b22 kb3 b13 b23 kb4 b14 b24