Bordoloi CMIS 450: Database Design Dr. Bijoy Bordoloi Transforming E/R Diagrams to Relations.

Slides:



Advertisements
Similar presentations
Entity-Relationship (ER) Modeling
Advertisements

BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
1 Logical Database Design and the Relational Model Modern Database Management.
Modeling the Data: Conceptual and Logical Data Modeling
Database Design & Mapping
Systems Development Life Cycle
1 Translation of ER-diagram into Relational Schema Prof. Sin-Min Lee Department of Computer Science.
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
Chapter 4: Logical Database Design and the Relational Model
Information Resources Management February 13, 2001.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
Database Systems: Design, Implementation, and Management Tenth Edition
APPENDIX C DESIGNING DATABASES
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Logical Database Design Nazife Dimililer. II - Logical Database Design Two stages –Building and validating local logical model –Building and validating.
Introduction to Databases
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
1 © Prentice Hall, 2002 CMIS564: E/R Modeling Dr. Bordoloi Based on Chapter 3; Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Web-Enabled Decision Support Systems
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Concepts and Terminology Introduction to Database.
Mapping from Data Model (ERD) to Relational Model
Bordoloi CMIS 450 Database Design Dr. Bijoy Bordoloi Entity Relationship (E-R) Model.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
PLUG IT IN 3 Fundamentals of Relational Database Operations.
Fundamentals of Relational Database Operations
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
BIS 360 – Lecture Eight Ch. 12: Database Design and Normalization.
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.
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
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)
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
Description and exemplification of entity-relationship modelling.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
In this session, you will learn to: Map an ER diagram to a table Objectives.
1 CS 430 Database Theory Winter 2005 Lecture 15: How to Convert an ER Model to Relations.
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.
Software School of Hunan University Database Systems Design Part III : Mapping ER Diagram to Relational Schema.
Logical Database Design and the Relational Model.
Bordoloi CMIS 450 Database Design Dr. Bijoy Bordoloi Enhanced E-R Modeling (EER)
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
CMIS 450 Database Design Dr. Bijoy Bordoloi Entity Relationship (E-R) Modeling: Additional Notes.
Logical Database Design and the Relational Model.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
IST 220 – Intro to DB Lecture 4 Database Design thru ER Modeling.
1 Information System Analysis Topic-3. 2 Entity Relationship Diagram \ Definition An entity-relationship (ER) diagram is a specialized graphic that illustrates.
Lecture 4: Logical Database Design and the Relational Model 1.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Logical Design & the Relational Model
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Chapter 4: Part B Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Design: Relational Model
Presentation transcript:

Bordoloi CMIS 450: Database Design Dr. Bijoy Bordoloi Transforming E/R Diagrams to Relations

Bordoloi Represent Entities Each entity-type in E/R Diagram becomes a Relation (Table)Each entity-type in E/R Diagram becomes a Relation (Table) The identifier of the entity-type becomes the PK of the corresponding relation (provided the PK meets all the necessary criteria discussed earlier)The identifier of the entity-type becomes the PK of the corresponding relation (provided the PK meets all the necessary criteria discussed earlier) Each non-key attribute of the entity-type becomes a non-key attribute of the relationEach non-key attribute of the entity-type becomes a non-key attribute of the relation

Bordoloi Represent Entities QuestionQuestion –What happens if you allow (non-identifying) multi-valued attributes in an entity-type? Can the identifier of an entity-type then also be the PK of the corresponding relation?

Bordoloi Attributes Cardinality Describes association between attribute and owner entityDescribes association between attribute and owner entity Single-valued attribute has at most one value for each entity instanceSingle-valued attribute has at most one value for each entity instance Multi-valued attribute has many values for some entity instancesMulti-valued attribute has many values for some entity instances

Bordoloi Attributes Cardinality EMPLOYEE EMP-ID SS-NUM SEX EXTENSION**

Bordoloi Multi-valued Attributes Either redefine the Primary Key* or make a separate relation with a foreign key taken from the superior entity Either redefine the Primary Key* or make a separate relation with a foreign key taken from the superior entity * Refer to class notes on Relational Model – Primary Key

Bordoloi Multi-valued Attributes Multi-valued attributes become new characteristic tablesMulti-valued attributes become new characteristic tables EMPLOYEE EMP# E-NAME DATE TITLE M M N N EMPLOYEEHISTORY EMP#E-NAME EMP# TITLEDATE 1 11 N N N

Bordoloi Multi-valued Attributes Characteristic table is necessary because relational model is normalizedCharacteristic table is necessary because relational model is normalized EMP#E-NAMETITLE HISTORY DATEEMP#E-NAME EMPLOYEENOT IN 2NF MA TABLE EMP # DATE TITLE E JANITOR E TECHNICIAN E MANAGER E EMPLOYER E DOGCATCHER

Bordoloi Transforming Relationships Mapping Binary Relationships –One-to-Many – and One-to-One relationships become foreign keys. –Many-to-Many - Create a new relation with the primary keys of the two entities as its primary key

Bordoloi Cont’d In N-1 relationship, always place foreign key at ‘N’ sideIn N-1 relationship, always place foreign key at ‘N’ side In 1-1 relationship, usually place foreign key in smaller table (results in fewer null values)In 1-1 relationship, usually place foreign key in smaller table (results in fewer null values)

Bordoloi Representing a (1:N) Relationship CUSTOMER ORDER Place s CUSTOMER NO. NAME CITY STATE ZIP ADDRESS DISCOUNT ORDER DATE PROMISED DATE ORDER NO. a) E-R Diagram

Bordoloi Representing a (1:N) Relationship b) Relations

Bordoloi Mapping a binary 1:1 relationship (a) Binary 1:1 relationship

Bordoloi Figure (b) Resulting relations

Bordoloi NULL Values in Foreign Keys Whether or not a Foreign Key can have NULL values depends on the minimum cardinality of the concerned relationshipWhether or not a Foreign Key can have NULL values depends on the minimum cardinality of the concerned relationship Minimum cardinality of 0 represented as NULL allowed for foreign key columnsMinimum cardinality of 0 represented as NULL allowed for foreign key columns Minimum cardinality of 1 represented as NULL disallowed for foreign key columnsMinimum cardinality of 1 represented as NULL disallowed for foreign key columns

Bordoloi Sub-tables Sub-entity - a subset of another entity, called the super-entitySub-entity - a subset of another entity, called the super-entity –Has 1-1 relationship to the super-entity (IS-A) –Are existence-dependent on the super-entity EMPLOYEE AGENT CLERK PROGRAMMER

Bordoloi Sub-entities become sub-tables in baseline logical design, but may merge with super-table in final design Any kind of table may have sub-table Sub-tables EMPLOYEE PROGRAMMER SYSTEM ASSIGNMENT PERMANENT TEMPORARY

Bordoloi Design of sub-table Foreign key identifies super-tableForeign key identifies super-table Primary key-foreign key with no qualifying columnsPrimary key-foreign key with no qualifying columns Foreign key rules reflect existenceForeign key rules reflect existence –Nulls not allowed –Delete cascades –Update cascades EMPLOYEE PROGRAMMER

Bordoloi Design of sub-table CREATE TABLEPROGRAMMER (EMP#, LANGUAGE, LEVEL) PRIMARY KEY(EMP#) FOREIGN KEY(EMP# IDENTIFIES EMPLOYEE NULLS NOT ALLOWED DELETE OF EMPLOYEE RESTRICTED UPDATE OF EMPLOYEE CASCADES) Optional class column in super-table improves performance, but is redundant to data in sub-tablesOptional class column in super-table improves performance, but is redundant to data in sub-tables

Bordoloi Representing IS-A Relationships PROPERTY MOUNTAIN PROPERTY BEACH PROPERTY CITY STATE ZIP STREET ADDRESS TYPICAL RENT NO. ROOMS STREET ADDRESS CITY STATE ZIP SKIING BLOCKS TO BEACH (a) E-R diagram IS-A

Bordoloi Representing IS-A Relationships (b) Relations

Bordoloi Associative Tables Associative Tables M-N relationship becomes associative table with two foreign keysM-N relationship becomes associative table with two foreign keys

Bordoloi Associative Tables Associative tables also known as association or intersection tableAssociative tables also known as association or intersection table EMPLOYEEPROJECT EMP#E-NAMEP-NAMEP# 1N EMPLOYEEPROJECT EMP#E-NAMEP-NAMEP# ASSIGNMEN T EMP#P# MN N1

Bordoloi Transforming Relationships Mapping Unary Relationships What do you do when the relationship is unary? What do you do when the relationship is unary? Rules are the same irrespective of whether the relationship is unary or binary. 1:N and 1:1 relationships be come foreign keys in the same table. M:N relationship becomes a separate (associative table). Rules are the same irrespective of whether the relationship is unary or binary. 1:N and 1:1 relationships be come foreign keys in the same table. M:N relationship becomes a separate (associative table).

Bordoloi In-Class Exercise: Transform the following ERD to a relational structure EMPLOYEE DIVISION DEPARTMENT SSN EMP# FNAMELNAMESALARY JOBCODE MARRIED-TO BLDGDIVNAME DEPT# DEPTNAME DIRECT WORK-IN MANAGE BELONG-TO

Bordoloi Reverse Engineering Modify the previous ERD to reflect the existence of the following five tables Modify the previous ERD to reflect the existence of the following five tables

Bordoloi More Example Tables

Bordoloi More Example Tables