ER to Relational Mapping

Similar documents
Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

ER-to-Relational Mapping

Relational DB Design by ER- and EER-to-Relational Mapping Design & Analysis of Database Systems

Database Management

Topic 5: Mapping of EER Diagrams to Relations

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

Chapter 9 Outline. Relational Database Design by ER and EERto-Relational. Mapping Fundamentals of Database Systems

Outline. Note 1. CSIE30600 Database Systems ER/EER to Relational Mapping 2

Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping

Relational Model: History

Chapter 17. Methodology Logical Database Design for the Relational Model

CMP-3440 Database Systems

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

How to translate ER Model to Relational Model

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 8 Data Modeling Advanced Concepts

Chapter 2: Entity-Relationship Model

SVY2001: Databases for GIS

MIT Database Management Systems Lesson 03: ER-to-Relational Mapping

Objectives of logical design... Transforming the ERD diagram into relations. Relational database components. Mapping a composite attribute

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

Sarajane Marques Peres, Ph.D. University of São Paulo Based on Elsmari, Navathe / Silberschatz, Korth, Sudarshan s books

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

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 6. Advanced Data Modeling. Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Database Design Process

Roadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*

SE 4DB3 TUTORIAL 2: REDUCTION TO RELATIONAL SCHEMAS

Chapter 6: Entity-Relationship Model

Translation ER/EER to relational

Chapter 7: Entity-Relationship Model

Chapter 6: Entity-Relationship Model

LELCTURE 4: ENHANCED ENTITY-RELATIONSHIP MODELING (EER)

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

Conceptual Modeling in ER and UML

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

DATABASE DESIGN I - 1DL300

4. Entity Relationship Model

Translating an ER Diagram to a Relational Schema

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

DATABASDESIGN FÖR INGENJÖRER F

Chapter 6: Entity-Relationship Model

Chapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model

Database Management System 6 ER Modeling...

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

OBJECTIVES. How to derive a set of relations from a conceptual data model. How to validate these relations using the technique of normalization.

DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL. 1 Powered by POeT Solvers Limited

DATABASE DESIGN I - 1DL300

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Lecture 2. Database design. The Entity-Relationship model

High Level Database Models

Chapter 8: Enhanced ER Model

Database Design Process. Requirements Collection & Analysis

Objectives Definition iti of terms List five properties of relations State two properties of candidate keys Define first, second, and third normal for

Intro to DB CHAPTER 6

The Entity-Relationship Model

Chapter 2 ENTITY RELATIONSHIP MODEL

A l Ain University Of Science and Technology

THE ENHANCED ER (EER) MODEL CHAPTER 8 (6/E) CHAPTER 4 (5/E)

The Entity Relationship Model

Introduction to Databases

Conceptual Database Design (ER modeling) Chapter Three

DATABASTEKNIK - 1DL116

Sahaj Computer Solutions. Data Modeling using the Entity Relationship Model

The Entity-Relationship (ER) Model

COSC344 Database Theory and Applications. σ a= c (P) S. Lecture 4 Relational algebra. π A, P X Q. COSC344 Lecture 4 1

Database Design Phases. History. Entity-relationship model. ER model basics 9/25/11. Entity-relationship (ER) model. ER model basics II

Database Management System 10 Conversion of ER model to Relational Model

OVERVIEW OF DATABASE DEVELOPMENT

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Advance Database Management System

Essentials of Database Management

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

A l Ain University Of Science and Technology

Entity-Relationship Model

High-Level Database Models (ii)

Contents. Database. Information Policy. C03. Entity Relationship Model WKU-IP-C03 Database / Entity Relationship Model

Database Design and the E-R Model (7.4, )

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

DATABASE MANAGEMENT SYSTEMS

Database Applications (15-415)

This chapter discusses how to design a relational

Part I: Structured Data

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

MTAT Introduction to Databases

Informatics 1: Data & Analysis

System Analysis And Design Methods ENTITY RELATIONSHIP DIAGRAM (ERD) Prof. Ali Khaleghi Eng. Hadi Haedar

Relational Database Systems Part 01. Karine Reis Ferreira

Lecture 10 - Chapter 7 Entity Relationship Model

Informatics 1: Data & Analysis

Chapter (4) Enhanced Entity-Relationship and Object Modeling

CSE 880:Database Systems. ER Model and Relation Schemas

Chapter 2: Entity-Relationship Model. Entity Sets. Entity Sets customer and loan. Attributes. Relationship Sets. A database can be modeled as:

Course Notes on From Entity-Relationship Schemas to Relational Schemas

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

CMPT 354 Database Systems I

From ER to Relational Model. Book Chapter 3 (part 2 )

E-R Model. Hi! Here in this lecture we are going to discuss about the E-R Model.

Transcription:

ER to Relational Mapping 1 / 19

ER to Relational Mapping Step 1: Strong Entities Step 2: Weak Entities Step 3: Binary 1:1 Relationships Step 4: Binary 1:N Relationships Step 5: Binary M:N Relationships Step 6: Multivalued Attributes Step 7: N-ary Relationships (not covered) Step 8: Class Hierarchies 2 / 19

Step 1: Mapping Regular (Strong) Entity Types A strong entity type is modeled as a relation schema. Each simple attribute of the entity type becomes an attribute of the relation schema For composite attributes, only the simple component attributes are present in the relation schema Choose a key of the entity type to be the primary key of the relation schema A tuple of a relation is an entity instance. 3 / 19

Step 2: Mapping Weak Entity Types Map the attributes of the weak entity type to a relation schema as you wold do for a strong entity type. Add the primary key attribute(s) of the identifying relationship to the attributes of the weak entity type s relation schema. These attributes should be foreign keys to the identifying relation s primary key. The primary key of the weak entity types relation schema is a combination of the foreign keys to the identifying relation schema and the weak entity s partial key. If no partial key, then the whole attribute list is the primary key. 4 / 19

Step 3: Mapping Binary 1:1 Relationship Types Three approaches: 1. Foreign keys 2. Merged relation 3. Cross-reference or relationship relation Favor the foreign key approach 5 / 19

Binary 1:1 Relationships - Foreign Key Approach Include the primary key of one relation schema as a foreign key of the other relation schema, as well as all the simple attributes of the relationship type. If there is a total participation constraint on only one entity type, that entity type s relation schema should be the one with the foreign key (otherwise relation states with the foreign key could have many NULLs). This is the approach you should use. 6 / 19

Binary 1:1 Relationships - Merged Relation Schema Approach If the relationship type has a total participation constraint with both entity types in the relationship, then both entity types and the relationsip type can be merged into a single table. 7 / 19

Binary 1:1 Relationships - Cross-reference or Relationship Relation Schema Approach Set up a third relation schema to represent the relationship, with foreign keys to both participating relation schemas primary keys. One foreign key becomes the primary key of the relationship schema and the other is a unique key. This approach isn t necessary in 1:1 relationships but is required for M:N relationships. 8 / 19

Step 4: Mapping Binary 1:N Relationship Types Two approaches: 1. Foriegn keys 2. Relationship relation schema 9 / 19

Binary 1:N Relationships - Foreign Key Approach Give the relation schema on the N side of the relationship a foreign key to the primary key of the relation schema on the 1 side of the relationship. The relation schema on the N side of the relationship should also include all the simple attributes of the relationship. This is the approach you should use for binary 1:N relationships. 10 / 19

Binary 1:N Relationships - Relationship Relation Schema Approach Create a relationship relation schema whose attributes are the primary keys of the relation schemas representing the participating entity types, which are also foreign keys to the related relation schemas. This option avoids excessive NULL values if few of the tuples on the N side of the relationship participate in the relationship. 11 / 19

Step 5: Mapping Binary M:N Relationship Types Create a relationship relation schema with foreign keys that are the primary keys of the participating entity types. The combination of these foreign keys is the primary key of the relationship relation. Also include any simple attributes of the relationship. 12 / 19

Step 6: Mapping Multivalued Attributes Create a relation schema for each multivalued attribute which includes the multivalued attribute, A, and a foreign key, K, which is the primary key of the relation schema which represents the entity type from which the multivalued attribute comes. The primary key of the relation schema is the combination of A and K. 13 / 19

Step 8: Mapping Superclasses and Subclasses Two options: Multiple relation schemas Subclasses determined by relation schemas Single relation schema Subclasses determined by type attributes 14 / 19

Step 8A: Multiple relation schemas all classes Map the superclass and all subclasses to their own relation schemas. Each relation schema includes all the attributes that are part of their entity type, plus the same primary key, which comes from the superclass. In the subclass relation schemas the primary key is also a foreign key to the superclass s relation schema. This approach works for any class hierarchy but will result in single-attribute relation schemas for subclasses with no specialized attributes. 15 / 19

Step 8B: Multiple relation schemas subclasses Create relation schemas for each subclass with all the attributes of the subclass plus all the attributes of the superclass, and a primary key chosen from the superclass. This approach only works for superclasses that are totally specialized and is only recommended for specializations that are disjoint (overlapping specializations would lead to duplicate entities in subclass relations). 16 / 19

Step 8C: Single relation schema one type attribute Create a single relation schema with all the attributes of the superclass and all subclasses, plus a type attribute whose value indicates which class each tuple belongs to. This approach only works for subclasses that are disjoint and may result in many NULL values if subclasses have many attributes. 17 / 19

Step 8D: Single relation schema multiple type attributes Create a single table with all the attributes of the superclass and all subclasses, plus boolean type attributes for each subclass whose values indicate whether a tuple belongs to that subclass. This approach works for overlapping subclasses and disjoint subclasses. Like any single-table approach, it may result in many NULL values if subclasses have many attributes. 18 / 19

Class Hierarchy Modeling Summary Use the multiple relation schema approach for classes that have specialized attributes. Use single table approach for subclasses that don t have specialized attributes, unless subclass participates in a relationship on the N side that its superclass does not. Can use a combination of multiple- and single-schema mapping approaches. 19 / 19