Logical Design. Readings: Elmasri&Navathe: Chapter Relational Database Design by ER- and EER-to-relational mapping

Similar documents
not necessarily strictly sequential feedback loops exist, i.e. may need to revisit earlier stages during a later stage

Designing a Database Schema

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

2. Conceptual Modeling using the Entity-Relationship Model

Chapter 2: Entity-Relationship Model. E-R R Diagrams

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Relational Schema Design

Chapter 2: Entity-Relationship Model

CSC 742 Database Management Systems

Information Systems Analysis and Design CSC John Mylopoulos Database Design Information Systems Analysis and Design CSC340

Database Design Methodology

Review: Participation Constraints

The Entity-Relationship Model

IV. The (Extended) Entity-Relationship Model

XV. The Entity-Relationship Model

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

ER & EER to Relational Mapping. Chapter 9 1

Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Conceptual Design Using the Entity-Relationship (ER) Model

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

Lecture 12: Entity Relationship Modelling

Lesson 8: Introduction to Databases E-R Data Modeling

Database Management Systems

A Tool for Generating Relational Database Schema from EER Diagram

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

Data Modeling. Database Systems: The Complete Book Ch ,

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method

Converting E-R Diagrams to Relational Model. Winter Lecture 17

Chapter 3. Data Modeling Using the Entity-Relationship (ER) Model

Introduction to normalization. Introduction to normalization

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

The Entity-Relationship Model

7.1 The Information system

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

Entity-Relationship Model

CIS 631 Database Management Systems Sample Final Exam

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

Foundations of Information Management

Relational Databases

Database Design Process

The Entity-Relationship Model

Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

Relational Database Basics Review

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

Lecture 6. SQL, Logical DB Design

How To Write A Diagram

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Database Design Methodology

Database Design Process. Databases - Entity-Relationship Modelling. Requirements Analysis. Database Design

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Data Analysis 1. SET08104 Database Systems. Napier University

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

We know how to query a database using SQL. A set of tables and their schemas are given Data are properly loaded

IT2304: Database Systems 1 (DBS 1)

AVOIDANCE OF CYCLICAL REFERENCE OF FOREIGN KEYS IN DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL

Relational Database Concepts

Modern Systems Analysis and Design

TIM 50 - Business Information Systems

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

IT2305 Database Systems I (Compulsory)

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Graham Kemp (telephone , room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

Files. Files. Files. Files. Files. File Organisation. What s it all about? What s in a file?

Databases What the Specification Says

Fundamentals of Database Design

A brief overview of developing a conceptual data model as the first step in creating a relational database.

Database Design Methodologies

How To Improve Performance In A Database

Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization

Database Design Process

Fundamentals of Database System

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

AS LEVEL Computer Application Databases

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

Once the schema has been designed, it can be implemented in the RDBMS.

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Exercise 1: Relational Model

Entity Relationship Diagram

Foundations of Information Management

The Relational Data Model: Structure

A Comparative Analysis of Entity-Relationship Diagrams 1

Data Modeling Basics

Section of DBMS Selection & Evaluation Questionnaire

Object Oriented Databases. OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar

OVERVIEW 1.1 DATABASE MANAGEMENT SYSTEM (DBMS) DEFINITION:-

Implementing evolution: Database migration


CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Tutorial on Relational Database Design

The E-R èentity-relationshipè data model views the real world as a set of basic objects èentitiesè and

SCHEMAS AND STATE OF THE DATABASE

Transcription:

Logical Design Readings: Elmasri&avathe: Chapter Relational Database Design by ER- and EER-to-relational mapping (Chapter 7 in the 7th and 5th edition, Chapter 9 in the 6th edition)

Conceptual Design Logical Design DMBS specific DBMS independent Physical Design

Aims of Logical Design the aim of this phase is to construct a logical schema, that correctly and efficiently represents all of the information described by the conceptual (e.g. ER) schema this is not always just a simple translation: in some cases there it no close correspondence between conceptual and logical schema e.g. if the conceptual schema is EER, and the logical schema is relational, a generalisation cannot be directly translated this is because the aim of conceptual design is to represent data accurately and naturally from a high level, computer-independent point of view, whereas logical design has to consider the performances of the final, computer based product

Decisions to take Analysis of redundancies decide whether to delete or retain possible redundancies Removing unsupported concepts e.g. replace all generalisations with other constructs (such as IS- A relationships) when using a relational logical model Partitioning and Merging partition of entity Employee to distinguish between Personal data (ame, YearOfBirth etc) and Professional data (Level, Salary, etc.) on the basis of frequency of access/modification Selection of Primary Identifiers e.g. adding new attributes to entities which do not have a natural primary key

Decisions to take decide how to deal with derived notions: e.g. derived attributes can be represented as virtual fields, as part of a form (visualisation phase), implemented as a query, or just ignored sometimes relations can be derived (cyclic relations) such as: TRAIEE ATTEDS COURSE TEACHES ISTRUCTOR ASSIGED TO need to decide whether ASSIGED TO can be derived from the other relationships, or is a relationship of its own

Step by step process After restructuring, it s just a straightforward process, which considers each concept in turn and with a specific order:. regular entities 2. weak entities 3. binary one-to-one relationships 4. binary one-to-many relationships 5. binary many-to-many relationships 6. multi-valued attributes 7. -ary relationships. (generalisations/specifications)

STEP : Regular entity types For each regular (non weak) entity type E in the ER schema, create a relation (table) that includes all the simple, primitive attributes of E all the simple components of composite attributes of E and choose one of the candidate key attributes as primary key YearBirth Code Age I ignore derived ISTRUCTOR Telephone umber ignore multivalued ame Firstame only consider components ISTRUCTOR I Firstame YearBirth

STEP 2: Weak entity types For each weak entity type W, create a relation (table) that includes all the simple, primitive attributes and all the simple components of composite attributes of W the primary key attribute(s) of the table T that corresponds to W s owner entity type and choose as primary key the combination of all attributes taken from T and the partial key of W (if any) Code I Age TRAIEE TRAIEE I Sex Age Sex IS A PROFESSIOAL PROFESSIOAL Area Title Area Title

STEP 3: Binary one-to-one rel. For each binary : relationship type R in the ER schema: identify T and S, relations corresponding to the entity types participating to R consider the relation T whose entity type has a total participation to R, if any, or choose any of the two if both have partial participation to R include the attribute(s) forming the primary key of S as foreign key in T include all the simple, primitive attributes and the simple components of attributes of R in T S ISTRUCTOR I Firstame YearBirth Telephone umber T COURSE TYPE ame StartDate I YearBirth Age DIRECTOR ISTRUCTOR Code ame COURSE TYPE Code COURSE TYPE ame DirectorCode StartDate Firstname ame

STEP 4: Regular Binary one-to-many rel. For each regular (non weak) binary : relationship type R: identify relation S that corresponds to the entity type at the Many side identify relation T that corresponds to the entity type at the One side include as foreign key in S the primary key of T include all the simple, primitive attributes and the simple components of attributes of R in S StartDate Code ame Address Telephone umber WORKS FOR EMPLOYER Level EMPLOYEE T S EMPLOYER ame Address Telephone umber EMPLOYEE Level EMPLOYEE Level EmployerCode StartDate

STEP 5: Binary many-to-many rel. For each binary :M relationship type R in the ER schema: identify the relations S and T that correspond to the entity types participating to R create a new relation and include as foreign keys all the attributes forming the primary key of S and all the attributes forming the primary key of T include in the new relation all the simple, primitive attributes and the simple components of attributes of R Code I TRAIEE Age TRAIEE I PAST EDITIO Sex Age Sex StartDate* EndDate HAS ATTEDED PAST EDITIO Mark HAS ATTEDED StartDate EndDate Participants CodeTrainee* CodeCourse* StartDate* Mark

STEP 6: Multivalued attributes For each multivalued attribute A of an entity type E in the ER schema: identify the relation T that correspond to E create a new relation S that include an attribute corresponding to A and all the attributes forming the primary key of T if the multivalued attribute is composite, include the simple components ISTRUCTOR I Firstame YearBirth YearBirth Code Age I ISTRUCTOR Telephone umber Firstame ame ISTR-TELEPHOE Telephone umber*

STEP 7: -ary relationships For each n-ary (n > 2) relationship type R in the ER schema: identify relations T, T 2,... T n that correspond to the entity types participating to R create a new relation including as foreign key the attributes forming the primary key of each of the tables T, T 2,... T n include all the simple, primitive attributes and the simple components of attributes of R Capacity Location Telephone umber StartDate Day Time Class EDITIO CLASSROOM TEACHES I YearBirth Age CLASSROOM Location* Capacity ISTRUCTOR I Firstame EDITIO StartDate* YearBirth ISTRUCTOR Code ame TEACHES Instructor Course StartDate* Location* Firstname

ame Address StartDate Code Telephone umber WORKS FOR EMPLOYER EndDate Code Age Sex Area Level I EMPLOYEE TRAIEE IS A IS A PROFESSIOAL Title Mark HAS WORKED FOR Date ATTEDS EDITIO Code ame HAS ATTEDED Class StartDate Time HELD I COURSE TYPE PAST EDITIO CLASSROOM TEACHES HAS BEE HELD I QUALIFIES Location HAS TAUGHT Telephone umber ISTRUCTOR Age Code StartDate EndDate Participants

TRAIEE I Sex Age HAS WORKED FOR Employer StartDate EndDate EMPLOYER ame Address Telephone umber ATTEDS PROFESSIOAL Area Title CodeTrainee* CodeCourse* StartDate* EMPLOYEE Level EmployerCode StartDate EDITIO CLASSES StartDate* Day Time HAS ATTEDED EDITIO StartDate* CodeTrainee* CodeCourse* StartDate* Mark COURSE TYPE ame DirectorCode StartDate PAST EDITIO StartDate* EndDate CLASSROOM Location* Capacity TEACHES Instructor Course StartDate* Location* QUALIFIES HAS TAUGHT CodeInstructor* CodeCourse* CodeInstructor* CodeCourse* StartDate* ISTRUCTOR I Firstame YearBirth ISTR-TELEPHOE Telephone umber*

TRAIEE I Sex Age (is a) ATTEDS (is a) PROFESSIOAL Area CodeTrainee* CodeCourse* StartDate* Title HAS WORKED FOR Employer StartDate EndDate EMPLOYEE Level EmployerCode StartDate EDITIO CLASSES StartDate* Day Time EMPLOYER ame Address Telephone umber (works for) HAS ATTEDED CodeTrainee* CodeCourse* StartDate* PAST EDITIO StartDate* EndDate TEACHES Mark (has been held in) EDITIO StartDate* (held in) CLASSROOM Location* Instructor Course StartDate* Location* COURSE TYPE ame DirectorCode StartDate Capacity (director) QUALIFIES HAS TAUGHT CodeInstructor* CodeCourse* StartDate* ISTRUCTOR I Firstame CodeInstructor* CodeCourse* YearBirth ISTR-TELEPHOE Telephone umber*

recursive relation

recursive relation

Remarks an alternative mapping of a One-to-One relationship type is possible by merging the two entity types and the relationship into a single relation (table) particularly appropriate when both participations are total the two entity types should not participate to other relationship types a One-to-One or a One-to-Many relationship type can always be mapped similarly to the method for Many-to-Many relationship types particularly useful when few relationship instances exist in order to avoid null values in foreign key

ER to Relational Mapping: Summary ER Entity Type Relational DB Relation (table) : relationship type foreign key or relationship relation : relationship type foreign key or relationship relation :M relationship type n-ary relationship type simple attribute composite attribute multivalued attribute key attribute relationship relation and two foreign keys relationship relation and n foreign keys attribute (column, field) set of attributes (fields) relation and foreign key primary key

Relational vs ER relational model does not allow relationship types to be represented explicitly: relationships are represented using primary keys and foreign keys as attributes in relations an operation called natural join allows combinations of all record pairs in order to materialise the relationship: binary : or : relationships require one join binary :M relationships require two joins n-ary relationships require n joins

Relational vs ER relational model does not allow multivalued attributes in relational schemas we create separate relations for each multivalued attribute key attribute of the relevant entity is repeated for each value need a join to relate the values of the multivalued attribute to values of other attributes of the entity or to relationship instances relational languages (e.g. SQL) also cannot explicitly handle set of values object-oriented, network and hierarchical models do support multivalued attributes seen as a flaw in normalised relational models

Mapping of EER constructs Extending ER-to-relational mapping algorithm with a STEP basically converting each specialisation with m subclasses S, S 2,... S m of a generalised superclass C into relation schemas several options available depending on the nature of the specialisation

STEP a: Multiple relations: superclass and subclasses works for any specialisation S, S 2,... S m of a class C (total or partial, disjoint or overlapping) create a relation for each subclass S and add the primary key of C to each equivalent to representing classes via weak entities ( IS-A rel.) Code I Sex Age TRAIEE Level U EMPLOYEE U Area PROFESSIOAL Title

STEP b: Multiple relations: Salary subclasses relations only only if: "Salaried" Subclasses are total Specialisation has disjointedness constraint DO T create a relation for the superclass, BUT add all of the superclass attributes to each subclass relations Level U "Employee" U EMPLOYEE d U o "Hourly" U Salaried "Professiona PROFESSIO PayScale Level Salary Hourly-paid Level Payscale SALARIED HOURLY-PAID can actually eliminate this

STEP c: single relation with one type attribute Salary only if: Specialisation has disjointedness constraint add all attributes to the superclass relation PROBLEM: many ULL values can be created "Salaried" Level U SALARIED "Employee" U EMPLOYEE d U o "Hourly" U HOURLY-PAID Employee "Professiona Level Salary Payscale PROFESSIO PayScale this will be empty if =Hourly this will be empty if =Salaried

STEP d: single relation with multiple type attributes to model overlapping subclasses (but also OK for disjoint) add all attributes to the superclass relation add a Boolean (flag) attribute for each subclass Code I Sex Level Age Trainee JobType = "Employee" U EMPLOYEE TRAIEE o U YOUG U Age < 30 JobType JobType = "Professional" PROFESSIOAL... EmplFlag Level YoungFlag ProfFlag Area Title Area Title Flags many empty/null fields, but controlled by the flags

Different tables for the upper classification Multiple strategies Flags for the lower classifications