Database Design Using Entity-Relationship Models zMapping E-R models into relations zFour common data structures.

Slides:



Advertisements
Similar presentations
Relational Database Design : ER- Mapping
Advertisements

Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Temple University – CIS Dept. CIS616– Principles of Database Systems
Chapter 6: Entity-Relationship Model (part I)
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Huiswerk Lees delen 3.2, 3.3 van hoofdstuk 3. opgaven voor hoofdstuk 2: modelleeropgave 5.
(wrapping up from last week)
Enhanced Entity-Relationship Modeling. Strong and Weak Entity Types Strong entity: Each object is uniquely identifiable using primary key of that entity.
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Logical Database Design
1 Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – EER Model –21th June.
Data Modeling and Relational Database Design ISYS 650.
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen1 ER-to-Relational Mapping Principles Specialization/Generalization -Superclass/Subclass Relationship.
Methodology Logical Database Design for the Relational Model
Enhanced Entity-Relationship Modeling
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
LOGICAL DATABASE DESIGN
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Mapping ERM to relational database
Chapter 3 Relational Model Chapter 4 in Textbook.
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Ref. Chapter3 Lecture4 1.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
Database Design Using Entity-Relationship Models Transformation of Entity-Relationship Models into Relational Database Design Trees, Networks, and Bills.
Database Design IST210 Class Lecture
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Chapter 7: Modeling Data in the Organization Dr. Taysir Hassan Abdel Hamid IS Department Faculty of Computer and Information Assiut University March 8,
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
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.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Entity Relationship Diagram (2)
Mapping from conceptual model (EER-M)
1 Chapter 17 Methodology - Local Logical Database Design.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
ER/EER to Relational Data Model 1 Database Design.
Relational Model E.F. Codd at IBM 1970 Chapter 3 (ed. 7 – Chap. 5)
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences The Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts - 6 th Edition Chapter 7: Entity-Relationship Model.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Introduction to Database Systems
Methodology - Logical Database Design. 2 Step 2 Build and Validate Local Logical Data Model To build a local logical data model from a local conceptual.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Chapter 2: Entity-Relationship Model
Entity Relationship (E-R) Model
COP Introduction to Database Structures
Database Constraints Ashima Wadhwa.
Chapter 5 Database Design
Methodology Logical Database Design for the Relational Model
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Entity-Relationship Model
Database EER.
Outline of the ER Model By S.Saha
Outline: Database Basics
Chapter 4+17 The Relational Model Pearson Education © 2014.
Entity-Relationship Model
Session 2 Welcome: The seventh learning sequence
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
EER to Relational Mapping
Chapter 7: Entity-Relationship Model
Mapping an ERD to a Relational Database
Presentation transcript:

Database Design Using Entity-Relationship Models zMapping E-R models into relations zFour common data structures

Mapping E-R Models to Tables zWe may not be familiar with all notations zThere may be E-R constructs that cannot be translated directly yMulti-valued attributes yTernary relationships zWe may need to change the data model yChange a relationship into an entity yChange an entity into an attribute yCollapse two entities yMake a strong entity weak

Basic Conversion Rules z A database conforming to an E-R diagram can be represented by a collection of tables. zConverting an E-R diagram to a table format is the basis for deriving a relational database design from an E-R diagram. yPrimary keys allow entities and relationships to be expressed uniformly as tables. y For each entity and many-to-many relationship there is a unique table, named after it. yEach table has columns (generally corresponding to attributes) with unique names.

Representing Entities as Tables zA strong entity set reduces to a table with the same attributes CUSTOMER (CustNumber, CustName, Address, City, State, Zip, ContactName, PhoneNumber)

Representing Entities zWe then may need to normalize the table if it is not in DK/NF zDe-normalize? CUSTOMER (CustomerNumber, Address, Zip, ContactName) ZIP-TABLE (Zip, City, State) CONTACT (ContactName, PhoneNumber) Interrelation (integrity) constraints: CUSTOMER[Zip] ZIP-TABLE[Zip] CUSTOMER[ContactName] CONTACT[ContactName] CUSTOMER (CustNumber, CustName, Address, City, State, Zip, ContactName, PhoneNumber)

Representing Weak Entities zWeak entity sets must be documented by referential integrity constraints zAn ID-dependent weak entity set becomes a table that includes a column for the primary key of the identifying strong entity zThe table corresponding to the weak relationship is redundant

Representing HAS-A Relationships z1:1 - Place key of one relation into other yPerhaps they should be combined! z1:N - Place key of parent into child Foreign key!

Representing HAS-A Relationships M:N - Build a table with columns for primary keys of two participating entity sets May add descriptive attributes of relationship set Intersection relation Error!

Recursive Relationships zSame as non-recursive relationships zOne participant instead of two zE.g., 1:1 yRemember two alternatives yForeign key can have NULL values (when?)

Recursive Relationships zWhat about 1:N and M:N recursive? yGive an example of each, not from book :) yHow many tables do you end up with, in each case? yHow is this different from the non-recursive case? yWhat is the domain of the foreign key?

Higher-order Relationships zTreat as combination of binary relationships zBinary constraints must be enforced with business rules zTypes of constraints: yMUST (ORDER:CUSTOMER:SALESPERSON) xORDER(OrdNo, CustNo, SalespersonNo,...) xCUSTOMER(CustNo, SalespersonNo,...) xSALESPERSON(SalespersonNo,...) yMUST NOT (PRESCRIPTION:DRUG:PATIENT) yMUST COVER (AUTO:REPAIR:TASK)

Representing IS-A Relationships zSpecialization method yForm a table for each sub-type entity No table for generalized (super-type) entity Common attributes are repeated

Representing IS-A Relationships zGeneralization method yForm a table for the super-type entity yForm a table for each sub-type entity (include primary key of generalized entity set, 1:1) yCommon attributes are inherited Need this? Usually same key

Trees (hierarchies) zNodes are entities zOnly 1:N relationships (branches) zEach child has a unique parent yRoot: unique node without parent ySiblings: children sharing parent zObvious relational representation Root

Simple Networks zOnly 1:N relationships zBut a child can have more than one parent (of different types) zObvious relational representation

Complex Networks zA child can have multiple parents of the same type zAt least one N:M relationship zNeed intersection relations(s)

Bills of Materials zA special case of networks zM:N recursive relationships zForeign keys in intersection relation have same domain

Example: Practice!...

Another Example: Overhead zEMPLOYEE: SSN, Fname, Minit, Lname, BirthDate, Address, JobType SECRETARY: SSN, TypingSpeed TECHNICIAN: SSN, TGrade ENGINEER: SSN, EngType zEMPLOYEE: SSN, Fname, Minit, Lname, BirthDate, Address, JobType, TypingSpeed, Tgrade, EngType

Another Example: Overhead zCAR: VehicleID, LicensePlateNo, Price MaxSpeed, NoOfPassengers TRUCK: VehicleID, LicensePlateNo, Price, NoOfAxles, Tonnage zPART: PartNo, Description, MFlag, DrawingNo, ManufactureDate, BatchNo, PFlag, SupplierName, ListPrice

Another Example: Overhead zPERSON: SSN, Fname, Minit, Lname, BDate, No, Street, AptNo, City, State, Zip EMPLOYEE: SSN, Salary, Rank, Office, Phone STUDENT: SSN, Class, Gflag GRAD_DEGREES: SSN, Year, Degree, College INSTRUCTOR_RESEARCHER: SSN