Logical Database Design Reading: C&B, Chap 17. Dept. of Computer Science, University of Aberdeen2 In this lecture you will learn What is logical database.

Slides:



Advertisements
Similar presentations
Dept. of Computing Science, University of Aberdeen1 Writing SELECT SQL Queries Nigel Beacham based on materials.
Advertisements

Access Control & Views Reading: C&B, Chap 7. Dept of Computing Science, University of Aberdeen2 In this lecture you will learn the principles of object.
Database Design: ER Modelling
Query Processing Reading: CB, Chaps 5 & 23. Dept of Computing Science, University of Aberdeen2 In this lecture you will learn the basic concepts of Query.
Data Definition and Integrity Constraints
Database Design: Normalization
Database Design: ER Modelling (Continued)
File Organization & Indexing Reading: C&B, Ch 18 & 23.
Data Modeling (CB 12) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Logical Database Design
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Modeling the Data: Conceptual and Logical Data Modeling
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Database Design (Data Modeling) DCO11310 Database Systems and Design By Rose Chang.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
1 Methodology : Conceptual Databases Design © Pearson Education Limited 1995, 2005.
Methodology Logical Database Design for the Relational Model
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
Modeling & Designing the Database
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
LOGICAL DATABASE DESIGN
Database Design & ER Diagrams
Logical Database Design Nazife Dimililer. II - Logical Database Design Two stages –Building and validating local logical model –Building and validating.
Mapping ERM to relational database
Chapter 3 Relational Model Chapter 4 in Textbook.
Chapter 7 Data Modeling with Entity Relationship Diagrams Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
CSC271 Database Systems Lecture # 29. Summary: Previous Lecture  The normalization process  1NF, 2NF, 3NF  Inference rules for FDs  BCNF.
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.
1/26/2004TCSS545A Isabelle Bichindaritz1 Database Management Systems Design Methodology.
Team Dosen UMN Database Design Connolly Book Chapter
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Chapter 8 Methodology - Conceptual Database Design Chapter 15 in Textbook.
Chapter 4 Entity Relationship (ER) Modeling.  ER model forms the basis of an ER diagram  ERD represents conceptual database as viewed by end user 
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
1 Chapter 17 Methodology - Local Logical Database Design.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Database Design – Lecture 4 Conceptual Data Modeling.
Chapter 17 Logical Database Design for the Relational Model Pearson Education © 2009.
Conceptual Databases Design Step 1 © Pearson Education Limited 1995, 2005.
Modelling Methodologies Chapter 16, 17, 18. Modeling Methodologies2 Database Design Physical DB design Logical DB design Conceptual DB design Hardware.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
CSC271 Database Systems Lecture # 23. Summary: Previous Lecture  Database design using ER modeling  Concepts of ER model  Entities  Relationships.
DBMS ER model-2 Week 6-7.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
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.
Chapter 4 The Relational Model Pearson Education © 2009.
Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant EPS
Decision Analysis Fall Term 2015 Marymount University School of Business Administration Professor Suydam Week 10 Access Basics – Tutorial B; Introduction.
April 20022/CS/3X1 Database Design Design method John Wordsworth Department of Computer Science The University of Reading Room.
Methodology Logical Database Design for the Relational Model
TMC2034 Database Concept and Design
Logical Database Design for the Relational Model
Logical Database Design for the Relational Model
Chapter Design Methodology Pearson Education © 2009.
Database Design – Lecture 4
Chapter 7: Entity-Relationship Model
The Relational Database Model
Conceptual Database Design
Chapter 4+17 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model Pearson Education © 2009.
Logical Database Design
Presentation transcript:

Logical Database Design Reading: C&B, Chap 17

Dept. of Computer Science, University of Aberdeen2 In this lecture you will learn What is logical database design Step-by-step procedure for logical database design –Focusing mainly on making decisions about posting foreign keys in designed tables

Dept. of Computer Science, University of Aberdeen3 Logical database design Derive a logical model from the information represented in the ER model (conceptual model) Validate the logical model to check if it fulfils clients –data and –transaction requirements We focus on one type of logical model which is relational model –In this course, Logical model = relational model Recall the notion of relational model from lecture 2 –Collection of connected tables

Dept. of Computer Science, University of Aberdeen4 From ER Model to Relational Model Our method of designing relational (logical) model uses information from ER Model –We assume that ER modelling is performed before relational modelling Informally, ER Model –Partitions information in a domain into Entities (boxes) and attributes –Links entities up into a network to reflect the relationships from the real world domain –The network of entities represents the real world domain Informally, relational model –Partitions information into tables (relations) –Links tables up into a network to reflect the relationships existing among data –The network of tables store data from the real world domain We can notice similarities between ER Models and Relational Models –Entities correspond to Tables (relations) –Network of entities correspond to network of tables We exploit these similarities to carry out relational database design

Dept. of Computer Science, University of Aberdeen5 Step-by-step procedure for Logical database design Derive relations for logical data model Validate relations using normalization Validate relations against user transactions Check integrity constraints Review logical data model with user Merge logical data models into global model (optional) Check for future growth We focus on the first two steps

Dept. of Computer Science, University of Aberdeen6 Entities & their Attributes Individual tables are derived from strong entities (entities with a clear Primary key) Fields in the tables are derived from attributes associated with entities –Define the data types of the fields Define the primary key of the table –Criteria discussed in the previous lecture Foreign keys are decided later while modelling the relationships –Not all tables (relations) have foreign keys –At this stage, however, bear in mind that relation model is incomplete without deciding foreign keys

Dept. of Computer Science, University of Aberdeen7 Example Consider the Staff entity in the DreamHome domain –Staff can be represented as a table at the relational level as Staff (staffNo, fName, lName, Position) Primary Key staffNo Or Staff StaffNo {PK} fName lName Position

Dept. of Computer Science, University of Aberdeen8 Relationships and their Attributes Modelling relationships at the relational (logical) level involves a good understanding of the nature of the relationships Recalll that relationships can have different degrees – the number of entities participating in the relationship –Binary relationships have two entities participating in the relationship –Complex relationships have greater than two entities participating in the relationship Binary relationships are modelled differently from complex relationships

Dept. of Computer Science, University of Aberdeen9 Binary Relationships Binary relationships can be –One-to-one(1:1) –One-to-many(1:*) –Many-to-many(*:*) Each of these is modelled differently Understanding 1:* type is particularly important –Many real world relationships are of type 1:*

Dept. of Computer Science, University of Aberdeen10 One-to-many (1:*) relationships These are the most common type of relationships Also known as parent:child relationship –One parent can have many children –The entity on the One side of the relationship is known as the Parent entity –The entity on the many side is known as the Child entity Our task: how 1:* relationship between two entities at ER Model level is represented in a relational model –We assume that both the participating entities are modelled as tables ( as explained earlier) –Do we make any changes to these tables to reflect the relationship between them? Yes, we use a foreign key to mark the relationship –Recall that while modelling entities (as explained earlier) we have postponed foreign key decision –We make foreign key decision while modelling 1:* relationship

Dept. of Computer Science, University of Aberdeen11 Foreign Key Design In a 1:* relationship –Foreign key is designed as a column in the child table (table one the * side) –Foreign key references the parent table (table on the 1 side) In other words, when you post a foreign key to a table it means –This table is the child table and –For every row in the parent table, this table may have more than one (many) corresponding rows Create a few rows of data in the tables participating in the 1:* relationship and check if the foreign key is acting as a link for information from the child table to the information from the parent table –Example data is always useful in designing foreign keys

Dept. of Computer Science, University of Aberdeen12 Example Consider the 1:* relationship Oversees between Staff and PropertyForRent In this case, –Staff is the Parent entity Because it is on the one side of the relationship –PropertyForRent is the child entity Because it is one the many side of the relationship When we model this relationship at the relational level –We assume that Staff and PropertyForRent are modelled as tables as discussed earlier –We post a copy of the PrimaryKey, StaffNo from the Parent entity, Staff as a foreign key in the child entity,PropertyForRent Our final tables are –Staff(StaffNo, lName, fName, Position) Primary key StaffNo –PropertyForRent(PropertyNo, Street, Town, StaffNo) Primary key ProperrtyNo Foreign key StaffNo references Staff(StaffNo) StaffPropertyForRent Oversees *

Dept. of Computer Science, University of Aberdeen13 Many-to-many (*:*) Relationships There are two methods to tackle *:* relationships First method:At the ER level, replace the *:* relationship to equivalent 1:* relationships –Then model the resulting 1:* relationships as explained earlier –In this method *:* relationship is reduced to two equivalent parent:child relationships Second method: Create a new table to represent the relationship –We assume that the two entities participating in the relationship are already modelled as tables as explained earlier –The third table is created to represent the relationship Both methods result in similar solutions –Three tables, where one of the tables (relationship table) links both the entity tables through foreign keys

Dept. of Computer Science, University of Aberdeen14 Example: First Method for modelling *:* relationship (a) in the above figure shows the *:* views relationship between PropertyForRent and Client (b) shows an equivalent ER model that creates –Viewing as a new entity representing the relationship and –Takes and Requests as two new relationships of the type 1:* Now model Viewing (entity), Takes and Requests (1:* relationships) as explained earlier

Dept. of Computer Science, University of Aberdeen15 Example: Second Method for modelling *:* relationship Here, the *:* relationship between Client and PropertyForRent is directly represented as a new table viewing Primary key for the new entity includes the two foreign keys from the two participating entities Note: Please check that both methods lead to the same tables

Dept. of Computer Science, University of Aberdeen16 One-to-one (1:1) relationships Generally, in relationship modelling we always identify the parent table –Then post a copy of its primary key as the foreign key in the child table In this case of 1:1, max (cardinality) constraints which are 1:1 do not help to identify the parent table Therefore we use min (participation) constraints to identify the parent table For example, we choose the entity with min value zero as the parent entity, if the other participating entity has min value of one –Similar rules can be found in C&B (16.1) for other cases of modelling 1:1 relationships

Dept. of Computer Science, University of Aberdeen17 Complex Relationships Complex relationships too can be simplified into simpler 1:1 or 1:* relationships first and then modelled at the logical level Alternatively, a new table can be created to represent a complex relationship and Foreign keys are posted in the new table from all the participating entities

Dept. of Computer Science, University of Aberdeen18 Example: Complex relationship A new table Registration is created and Foreign keys are posted in the Registration table from all the participating entities

Dept. of Computer Science, University of Aberdeen19 Superclass/subclass relationships In modelling the previous cases of relationships we focused on identifying the parent table in the relationship –Because its copy of the primary key is posted as the foreign key in the child table Modelling superclass/subclass relationship is not about identifying foreign key In this case, the focus is on deteriming the number of tables required to store the data corresponding to the classes and subclasses We once again use constraints defined on the superclass/subclass relationships –Please refer to C&B (16.1) for details

Dept. of Computer Science, University of Aberdeen20 Conclusion Mapping from conceptual model to logical model mainly involves –Designing tables with primary keys –And linking tables with foreign keys Quality of the relations (tables) derived from ER models is unknown We need notions that distinguish good designs from bad designs – Normalization!!