Transform an ER Model into a Relational Database Schema

Slides:



Advertisements
Similar presentations
The transformation of an ER or EER model into a relational model
Advertisements

Data Modeling. What are you keeping track of? You begin to develop a database by deciding what you are going to keep track of. Each thing that you are.
Transformation of an ER Model into a Relational Database Schema Translating to Software.
Relational Database Design Via ER Modelling
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
1 Assignment 4 Map entities with relationships to relational schemas. Use DBDL to describe the table schemas.
Review Indra Budi Fakultas Ilmu Komputer UI 2 Database Introduction Database vs File Processing Main purpose of database Database Actors.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 5/1 Copyright © 2004 Please……. No Food Or Drink in the class.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
Methodology Logical Database Design for the Relational Model
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
Chapter 4 Entity Relationship (ER) Modeling
CS424 PK, FK, FD Normalization Primary and Foreign Keys Primary and foreign keys are the most basic components on which relational theory is based. Primary.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
Database – Part 2a Dr. V.T. Raja Oregon State University.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Database Architecture The Relational Database Model.
Chapter 91 ER & EER to Relational Mapping. Chapter 92 ER to Relational Mapping Step 1: For each regular entity type E in the ER schema, create a relation.
ER- and EER-to-Relational Mapping
3 The Relational Model MIS 304 Winter Class Objectives That the relational database model takes a logical view of data That the relational model’s.
Module Title? DBMS E-R Model to Relational Model.
1 Introduction to modeling Relational modelling Slides for this part are based on Chapters 11 from Halpin, T. & Morgan, T. 2008, Information Modeling and.
DATA MODELING AND DATABASE DESIGN
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
1.  An introduction to data modelling  The purpose of data modelling  Modelling data relationships 2.
IS 475/675 - Introduction to Database Design
Chapter 4 Entity Relationship (ER) Modeling.  ER model forms the basis of an ER diagram  ERD represents conceptual database as viewed by end user 
CS 370 Database Systems Lecture 9 The Relational model.
IE 423 – Design of Decision Support Systems Data modeling and database development.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Jozef Kuper.  Describe a Database  Entities  Atributes  Relationships.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Week 7-8 DBMS ER-Relational Mapping. ER-Relational Mapping.
Entity Relationship Diagram (ERD). Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
ER- Relational Mapping (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
Chapter 3: Relational Databases
Lecture 03 Constraints. Example Schema CONSTRAINTS.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Ch 05. Basic Symbols ( manino ). Cardinalities Cardinality Notation.
FEN Introduction to the database field: The development process Seminar: Introduction to relational databases Development process: Analyse.
Chapter 5 Understanding Entity Relationship Diagrams.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Transformation of an ER Model into a Relational Database Schema Translating to Software.
Logical Database Design and the Rational Model
Relational Database Design by ER- and EER-to- Relational Mapping
Tables and Their Characteristics
Translation of ER-diagram into Relational Schema
Data Modelling Introduction
Relational Database.
The Relational Model Textbook /7/2018.
Mapping an ERD to a Relational Database
INSTRUCTOR: MRS T.G. ZHOU
Database Dr. Roueida Mohammed.
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Mapping an ERD to a Relational Database
Presentation transcript:

Transform an ER Model into a Relational Database Schema

2 into 1 won’t go? ER model has 2 major concepts Entities Relationships Relational model has 1 major concept Relation (table) There are general rules for translation good implementations come from these and experience/inventiveness inventiveness requires clear understanding of the relational model

How we do it Entities Relationships all become relations (tables) some become relations (tables) some are implemented by use of PK, FK some need additional coding using DBMS facilities using application code if necessary we know which by their cardinality signatures

Notation Primary key attribute(s): underline & bold Foreign key attributes: *

Entities to Relations Start off by representing each entity class as a relation Add the attributes Indicate primary key Operator (Code, Name, Tel) Tour (Id, Start, Visiting)

Relationships to Relations Three Simple Cases B A 1..1 0..* One to many Optional on the “many side” Many to many Optional on both sides 1:N Optional on both sides

Simple Case 1 - example

Simple Case 2 - example

Simple Case 2 - comments The existence of a tuple in the “intersection” relation is the relationship instance The key is joint because a student can only take a module once SID as PK would let a student do only 1 module CODE as PK would let a module have only 1 student

Simple Case 3 - example

Simple Case 3 - comments Again, the existence of a tuple in the “intersection” relation is the relationship instance The intersection PK is only one FK (student) SID is PK so each student can have max 1 Sponsoring CO not PK, Sponsor could have many Sponsorings

Relationships to Relations Two problem cases 1..1 1..* One to many Mandatory on both sides B A 0..* 1..* Many to many Mandatory on one sides

Problem Case 1 - example Can do no better than the optional case Module Lecturer 1..1 1..* Can do no better than the optional case Plant the key of the ‘one’ side in the ‘many’ side

Problem case 1 - comments How can we ensure that every instance of A is involved in at least one relationship with a B? i.e. every A appears in B Cannot enforce it Can check if rule is obeyed (rel. algebra) A[A] == B[A] Can query for As not found in B could query for operators not found in tours could list lecturers not teaching

Problem case 2 Can do no better than the optional case R(A*, B*) 0..* 1..* Many to many Mandatory on one of the sides Can do no better than the optional case Plant both keys in a new relation with joint PK R(A*, B*) A(A, …) B(B, …)

Problem case 2 - comments How can we ensure that every instance of A (every A) is involved in at least one relationship with a B? (same question) Cannot enforce it (same problem!) Every A must appear in R at last once Can check if rule is obeyed (rel. algebra) A[A] == R[A] Can query for As not found in R etc.

Problem cases - general These cases are the less common ones Often the constraints cannot be implemented for all time modules and students before registration? Often left unimplemented but with a mechanism to list breaches a query, run regularly or on demand Enforcing participation may just not be important

Comprehensive list of signatures Reference material

1:N Relationships A(A,…) B(B,…) R(A*,B*) A(A,…) B(B, A*,…) A(A,…) 0..1 1..* R(A*,B*) A(A,...) B(B, A*,...) B A 1..1 1..*

Binary (M:N) Relationships A(A,…) B(B,…) R(A*,B*) A(A,…) B(B,…) R(A*,B*) B A 1..* 0..* A(A,…) B(B,...) B A 0..* 1..* R(A*,B*) A(A,...) B(B,...) B A 1..* R(A*,B*)

Binary (1:1) Relationships R(A*,B*) or A(A,…) B(B,…) A(A,…) B(B, A*…) No Duplicates c.f. above A  B Not Null & No Duplicates A(A,…) B(B, A*…) B A 1..1