Fundamentals of Database Systems

Similar documents
Relational Schema Design

ER & EER to Relational Mapping. Chapter 9 1

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

CSC 742 Database Management Systems

Chapter 8 The Enhanced Entity- Relationship (EER) Model

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

A Tool for Generating Relational Database Schema from EER Diagram

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

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

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

Chapter 2: Entity-Relationship Model

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

ER modelling, Weak Entities, Class Hierarchies, Aggregation

XV. The Entity-Relationship Model

Database Design Methodology

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

Data Modeling. Database Systems: The Complete Book Ch ,

2. Conceptual Modeling using the Entity-Relationship Model

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

Grocery Store Project

Data Analysis 1. SET08104 Database Systems. Napier University

Review: Participation Constraints

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

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

IV. The (Extended) Entity-Relationship Model

The Entity-Relationship Model

Fundamentals of Database System

RELATIONSHIP STRENGTH

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

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

IT2305 Database Systems I (Compulsory)

Modern Systems Analysis and Design

Conceptual Design Using the Entity-Relationship (ER) Model

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

Lecture 12: Entity Relationship Modelling

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

IT2304: Database Systems 1 (DBS 1)

Database Systems. Session 3 Main Theme. Enterprise Data Modeling Using The Entity/Relationship (ER) Model. Dr. Jean-Claude Franchitti

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

Database Design Methodology

Part 7: Object Oriented Databases

Lesson 8: Introduction to Databases E-R Data Modeling

Chapter 10 Practical Database Design Methodology and Use of UML Diagrams

Chapter 10. Practical Database Design Methodology. The Role of Information Systems in Organizations. Practical Database Design Methodology

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

The Entity-Relationship Model

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

Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Entity-Relationship Model

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

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

Umbrello UML Modeller Handbook

Chapter 10 Functional Dependencies and Normalization for Relational Databases

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

Databases and BigData

Information Systems Modelling Information Systems I: Databases

A Comparative Analysis of Entity-Relationship Diagrams 1

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


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

Normal Form vs. Non-First Normal Form

Database Design and the E-R Model

DATABASE SYSTEMS. Chapter 7 Normalisation

1. Physical Database Design in Relational Databases (1)

Relational Databases

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

7.1 The Information system

Enhanced-ER Data Model

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

Databases What the Specification Says

Relational Database Basics Review

Entity Relationship Model

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

Foundations of Information Management

Section of DBMS Selection & Evaluation Questionnaire

Entity - Relationship Modelling

Introduction to normalization. Introduction to normalization

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Exercise 1: Relational Model

Logical Schema Design: The Relational Data Model

Agile Software Development

The Relational Data Model and Relational Database Constraints

The Entity-Relationship Model

Designing a Database Schema

Fundamentals of Database Design

3. Database Design Functional Dependency Introduction Value in design Initial state Aims

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

Normalization in OODB Design

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Polymorphic Data Modeling

Database Design. Adrienne Watt. Port Moody

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

Physical Database Design and Tuning

Chapter 6. Database Tables & Normalization. The Need for Normalization. Database Tables & Normalization

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

An Example: Video Rental System

Transcription:

204222 - Fundamentals of Database Systems Chapter 9 Relational Database Design by ER and EERto-Relational Mapping Adapted for 204222 by Areerat Trongratsameethong Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 9 Outline Relational Database Design Using ER-to- Relational Mapping Relational Database Design Using EER-to- Relational Mapping 2

Relational Database Design by ER- and EER-to-Relational Mapping Design a relational database schema Based on a conceptual schema design Seven-step algorithm to convert the basic ER model constructs into relations 3

Relational Database Design Using ERto-Relational Mapping 4

5

ER-to-Relational Mapping Algorithm COMPANY database example Assume that the mapping will create tables with simple single-valued attributes Step 1: Mapping of Regular Entity Types For each regular entity type, create a relation R that includes all the simple attributes of E Called entity relations Each tuple represents an entity instance 6

ER-to-Relational Mapping Algorithm (cont d.) Step 2: Mapping of Weak Entity Types For each weak entity type, create a relation R and include all simple attributes of the entity type as attributes of R Include primary key attribute of owner as foreign key attributes of R 7

ER-to-Relational Mapping Algorithm (cont d.) 8

ER-to-Relational Mapping Algorithm (cont d.) Step 3: Mapping of Binary 1:1 Relationship Types For each binary 1:1 relationship type Identify relations that correspond to entity types participating in R Possible approaches: Foreign key approach: e.g. Employee manages department (total participation : every department has a manager, PK Employee FK in Department, otherwise a lot of NULL in Employee) Merged relationship approach: when both entities are total participation Cross reference or relationship relation approach: create third relation and keeps PK of both entities, disadvantage: have one more table and join is needed to join data from both 9

ER-to-Relational Mapping Algorithm (cont d.) Step 4: Mapping of Binary 1:N Relationship Types For each regular binary 1:N relationship type Identify relation that represents participating entity type at N-side of relationship type Include primary key of other entity type as foreign key in S Include simple attributes of 1:N relationship type as attributes of S Alternative approach Use the relationship relation (cross-reference) option as in the third option for binary 1:1 relationships 10

ER-to-Relational Mapping Algorithm (cont d.) Step 5: Mapping of Binary M:N Relationship Types For each binary M:N relationship type Create a new relation S Include primary key of participating entity types as foreign key attributes in S Include any simple attributes of M:N relationship type 11

ER-to-Relational Mapping Algorithm (cont d.) Step 6: Mapping of Multivalued Attributes For each multivalued attribute Create a new relation Primary key of R is the combination of A and K If the multivalued attribute is composite, include its simple components 12

ER-to-Relational Mapping Algorithm (cont d.) Step 7: Mapping of N-ary Relationship Types For each n-ary relationship type R Create a new relation S to represent R Include primary keys of participating entity types as foreign keys Include any simple attributes as attributes 13

Discussion and Summary of Mapping for ER Model Constructs 14

Discussion and Summary of Mapping for ER Model Constructs (cont d.) In a relational schema relationship, types are not represented explicitly Represented by having two attributes A and B: one a primary key and the other a foreign key 15

16

Mapping EER Model Constructs to Relations Extending ER-to-relational mapping algorithm Step 8: Options for Mapping Specialization or Generalization, Convert each specialization with m subclasses {S1, S2,..., Sm} and (generalized) superclass C, where the attributes of C are {k, a1,...an} and k is the (primary) key, into relation schemas using one of the following 4 options: 8A 8D 17

Mapping of Specialization or Generalization Option 8A: Multiple relations superclass and subclasses. Create a relation L for C with attributes Attrs(L) = {k, a1,..., an} and PK(L) = k. Create a relation Li for each subclass Si,1 i m, with the attributes Attrs(Li) = {k} {attributes of Si} and PK(Li) = k. This option works for any specialization (total or partial, disjoint or overlapping). Option 8B: Multiple relations subclass relations only. Create a relation Li for each subclass Si, 1 i m, with the attributes Attrs(Li) = {attributes of Si} {k, a1,..., an} and PK(Li) = k. This option only works for a specialization whose subclasses are total (every entity in the superclass must belong to (at least) one of the subclasses). Additionally, it is only recommended if the specialization has the disjointedness constraint. If the specialization is overlapping, the same entity may be duplicated in several relations. 18

Mapping of Specialization or Generalization Option 8C: Single relation with one type attribute Create a single relation L with attributes Attrs(L) = {k, a1,..., an} {attributes of S1}... {attributes of Sm} {t} and PK(L) = k. The attribute t is called a type (or discriminating) attribute whose value indicates the subclass to which each tuple belongs, if any. This option works only for a specialization whose subclasses are disjoint, and has the potential for generating many NULL values if many specific attributes exist in the subclasses. Option 8D: Single relation with multiple type attributes Create a single relation schema L with attributes Attrs(L) = {k, a1,..., an} {attributes of S1}... {attributes of Sm} {t1, t2,..., tm} and PK(L) = k. Each ti, 1 i m, is a Boolean type attribute indicating whether a tuple belongs to subclass Si. This option is used for a specialization whose subclasses are overlapping (but will also work for a disjoint specialization). Mflag, Pflag 19

Mapping of Shared Subclasses (Multiple Inheritance) Apply any of the options discussed in step 8 to a shared subclass 20

Mapping of Categories (Union Types) Step 9: Mapping of Union Types (Categories) Defining superclasses have different keys Specify a new key attribute Surrogate key 21

Surrogate key 22

Summary Map conceptual schema design in the ER model to a relational database schema Algorithm for ER-to-relational mapping Illustrated by examples from the COMPANY database Include additional steps in the algorithm for mapping constructs from EER model into relational model 23