Database Systems Conceptual to Relational Modeling II Lecture # 11 Feb 25 th 2011.

Slides:



Advertisements
Similar presentations
ICS 434 Advanced Database Systems
Advertisements

Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Database Modeling: Methods, Techniques, and Symbols
4/15/2017 THE ENTITY–RELATIONSHIP MODEL AND EXTENSIONS (based on Ch. 3 and 4 in Fundamentals of Database Systems by Elmasri and Navathe)
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Systems Development Life Cycle
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 3- 1.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
CS34311 The Entity- Relationship Model Part II.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Slide 3- 1.
4/17/2017.
Translating ER Model into Relational Model. ER Model  Relational Model Considerations: Minimize the number of relations to reduce query- processing time.
Chapter 4 Entity Relationship (E-R) Modeling
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Slide 3- 1.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Ch 6: ER to Relational Mapping
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
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.
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
1  High-level conceptual model  Used for the conceptual design of DB applications  Many DB design tools employs its concepts  Chen MIT “The.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Data Modeling Using the Entity-Relationship (ER) Model CS 340: Introduction to Databases.
Topic 3 Data Modeling Using the Entity-Relationship (ER) Model
1 CSBP430 – Database Systems Chapter 3: Data Modeling Using the Entity-Relationship Model Elarbi Badidi College of Information Technology United Arab Emirates.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Slide 3- 1.
6.8 Case Study: E-R for Supplier-and-Parts Database
Data Modeling Using the Entity-Relationship (ER) Model
Entity-Relationship Model Ch. 3
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
Slide 3- 1 Notation for Constraints on Relationships Cardinality ratio (of a binary relationship): 1:1, 1:N, N:1, or M:N Shown by placing appropriate numbers.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
Data Modeling Using the Entity- Relationship (ER) Model.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
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.
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Slide 3- 1.
EER Model.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Entity Relationship Modeling
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
Many-to-many (M:N) RELATIONSHIP e 1 e 2 e 3 e 4 e 5 e 6 e 7 r1r2r3r4r5r6r7r1r2r3r4r5r6r7 p 1 p 2 p 3 r8r8 r9r9.
Database Systems Background Review (2) Dr. Muhammad Shafique
Software School of Hunan University Database Systems Design Part III : Mapping ER Diagram to Relational Schema.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 3- 1.
Entity-Relation Model. E-R Model The Entity-Relationship (ER) model was originally proposed by Peter in 1976 ER model is a conceptual data model that.
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model Copyright © 2004 Pearson Education, Inc.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Copyright © 2016 Ramez Elmasr and Shamkant B. Navathei CHAPTER 3 Data Modeling Using the Entity-Relationship (ER) Model Slide 1- 1.
Logical Database Design and the Relational Model.
1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006.
Data Modeling Using the Entity-Relationship (ER) Model
Lecture 4: Logical Database Design and the Relational Model 1.
CS3431: C-Term Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
Data Modeling Using the Entity-Relationship (ER) Model.
CS34311 Translating ER Schema to Relational Model.
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Slide 3- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
Database Design: Conceptual Modeling with ER Model CENG 351.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model تنبيه :
CS4222 Principles of Database System
Entity- Relationship (ER) Model
College of Arts & Science Computer Science Department
Relational Database Design by ER- and EER-to-Relational Mapping
Presentation transcript:

Database Systems Conceptual to Relational Modeling II Lecture # 11 Feb 25 th 2011

ER Model => Relational Model Step 1: Regular Entities (and Single-valued attributes). Step 2: Many-to-Many Relationships Step 3: Many-to-One Relationships Step 4: One-to-One Relationships Step 5: n-ary (m-way) relationships Step 6: Weak Entities Step 7: Multi-valued Attributes Step 8: Entity Subtypes and Super-types Step 9: Additional Constraints These steps may not be followed in the above sequence. You may have to do step 6 before step 2, and so on.

An Example

Step 1: Regular Entities Each regular entity type maps into a base table. Each simple attribute of the entity type maps to an attribute of the table. Each composite attribute will be broken into many simple attributes. We’ll treat Multi-valued attributes later. Derived attributes, by definition, can be derived, and therefore are not necessary to be represented. The primary key of the entity type maps to the primary key of the table.

Step 1: Example Department{D#, Dname, City}; Employee{E#, First, MI, Last, Salary, Manager}; Supplier{S#, Sname, City, Status}; Part{P#, Pname, Color, Weight, City}; Project{J#, Jname, City}; Primary keys are underlined. How about Employee Name and Phone?

Step 2: M-N Relationships Each Many-to-Many relationship type maps into a table. The primary key of this table is the combination of the primary keys of the participating entity types. These are also foreign keys. Attributes of the relationship type maps to attributes of the table, similar to those of regular entity types.

Step 2: Example Proj_Work{E#, J#} Foreign key {E#} References Employee, Foreign key {J#} References Project; SP{S#, P#, QTY} Foreign key {S#} References Supplier, Foreign key {P#} References Part; Contain{Cont_P#, Comp_P#, QTY} Foreign key {Cont_P#} References Part, Foreign key {Comp_P#} References Part;

Step 3: M-1Relationships For each regular Many-to-One relationship type, introduce a foreign key in the table on the “many” side that references the table on the “one” side. Do not need to introduce a separate table. We’ll treat the identifying relationship of each weak entity type later.

Step 3: Example Employee {Emp#, First, MI, Last, Salary, Manager, D#} Foreign key {D#} references Department; Project{J#, Jname, City, PrjMgr_E#} Foreign key {PrjMgr_E#} references Employee; Do we need tables for: Employee Prj_Manage Project Employee Work_In Department

Step 4: 1-1 Relationships We treat One-to-One relationship similarly as we treat Many-to-One relationship. We prefer to extend the entity type that has a “mandatory” participation in the relationship.

Step 4: Example For Manage Relationship: Department{Dept#, Dname, City, Manager_E#} Foreign key {Manager_E#} references Employee; However, both M-1 and 1-1 relationships can be treated as special cases of M-M relationships, so a separate table could be created for each relationship, no matter whether it’s M-M, M-1, or 1-1.

Step 5: M-Way relationships The primary key of this table is the combination of the primary keys of the participating entity types. These are also foreign keys. Attributes of the relationship type maps to attributes of the table, similar to those of regular entity types.

Step 5: Example SPJ {S#, P#, J#, QTY}

Step 6: Weak Entities The identifying relationship of a weak entity is of course a Many-to-One relationship, The weak entity type must have a “mandatory” participation in its identifying relationship. Each weak entity type maps into a base table. Attributes are treated as usual. Introduce a foreign key that references the primary key of its identifying entity type. The primary key is the primary key of its identifying entity type plus its own partial key.

Step 6: Example Dependent{E#, Dname, Gender} Foreign key {E#} References Employee;

Step 7: Multi-valued Attributes Each multi-valued attribute maps into a separate table. The table has an attribute for each simple attribute of the multi-valued attribute. Include also an attribute for the primary key of the entity or relationship type that the attribute belongs to. This is also a foreign key. The primary key of this table is the combination of all the attributes if the multi-valued attribute is simple. If the multi-valued attribute is composite, the primary key of this table may be a combination of some of the attributes.

Step 7: Example Emp_Phone{Emp#, Phone} Foreign key {Emp#} References Employee; E.g. Customer has Cust#, name, multiple Credit Cards that have Card # and Expiration Customer {Cust#, name}; Credit_Cards {Cust#, Card#, Expiration} Foreign key {Cust#} References Customer;

Step 8: Entity Subtypes/Supertypes The supertype maps into a base table. Each subtype maps into another base table. The primary key is the same as the primary key of its supertype. This is also a foreign key. Treat attributes that belongs to the subtype only as usual. The primary key of the root entity propagates down a hierarchy of entity types.

Step 8: Example Employee{E#, First, MI, Last, Salary, Manager, D#} Foreign key {D#} references Department; Programmer {E#, Language} Foreign key {E#} references Employee; SYS_Prog {E#, OS} Foreign key {E#} references Programmer; APP_Prog {E#, Web_Based} Foreign key {E#} references Programmer;

The Relational Schema (So far) Department{D#, Dname, City, Manager_E#} Foreign key {Manager_E#} references Employee; Employee{E#, First, MI, Last, Salary, Manager, Dept#} Foreign key {D#} references Department; Supplier{S#, Sname, City, Status}; Part{P#, Pname, Color, Weight, City}; Project{J#, Jname, City, Prj_Mgr_E#} Foreign key {Prj_Mgr_E#} references Employee; Proj_Work{E#, J#} Foreign key {E#} References Employee, Foreign key {J#} References Project;

The Relational Schema (Cont.) SP{S#, P#, QTY} Foreign key {S#} References Supplier, Foreign key {P#} References Part; Contain{Cont_P#, Comp_P#, QTY} Foreign key {Cont_P#} References Part, Foreign key {Comp_P#} References Part; SPJ{S#, P#, J#, QTY} Foreign key {S#} References Supplier, Foreign key {P#} References Part, Foreign key {J#} References Project; Dependent{E#, Dname#, Gender} Foreign key {E#} References Employee;

The Relational Schema (Cont.) Emp_Phone {E#, Phone} Foreign key {E#} References Employee; Programmer {E#, Language} Foreign key {E#} references Employee; SYS_Prog {E#, OS} Foreign key {E#} references Programmer; APP_Prog {E#, Web_Based} Foreign key {E#} references Programmer; Totally 14 tables.

SUPPLIER – PART DB Supplier S# SNAME STATUS CITY Part P# PNAME COLOR WEIGHT CITY SUPPLY QTY

Additional Constraints However, we haven’t treated the additional constraints. Weight is a real number in [0, 10000]. QTY is a real number in [0, 60000]. QTY must be entered for SP. Color must be one of ('Red', 'Green', 'Blue', 'Yellow', 'White', 'Black', 'Other'). Sname does not have duplicates and must be entered. Suppliers in London must have status 20. No suppliers with status less than 20 can supply any part in a quantity greater than 500.

Step 9: Additional Constraints Supplier{S#, Sname, City, Status} Constraint NOT( CITY='London' AND STATUS <> 20), Constraint Sname UNIQUE NOT NULL; Part{P#, Pname, Color, Weight, City} Constraint Color IN ('Red', 'Green', 'Blue', 'Yellow', 'White', 'Black', 'Other'), Constraint Weight >= 0 AND Weight <= 10000;

Data Modeling Tools A number of popular tools that cover conceptual modeling and mapping into relational schema design. Examples: ERWin, S- Designer (Enterprise Application Suite), ER- Studio, etc. POSITIVES: serves as documentation of application requirements, easy user interface - mostly graphics editor support

Problems with Current Modeling Tools DIAGRAMMING Poor conceptual meaningful notation. To avoid the problem of layout algorithms and aesthetics of diagrams, they prefer boxes and lines and do nothing more than represent (primary-foreign key) relationships among resulting tables.(a few exceptions) METHODOLGY lack of built-in methodology support. poor tradeoff analysis or user-driven design preferences. poor design verification and suggestions for improvement.

Some of the Currently Available Automated Database Design Tools COMPANYTOOLFUNCTIONALITY Embarcadero Technologies ER StudioDatabase Modeling in ER and IDEF1X DB ArtisanDatabase administration and space and security management OracleDeveloper 2000 and Designer 2000 Database modeling, application development Popkin SoftwareSystem Architect 2001Data modeling, object modeling, process modeling, structured analysis/design Platinum Technology Platinum Enterprice Modeling Suite: Erwin, BPWin, Paradigm Plus Data, process, and business component modeling Persistence Inc.PwertierMapping from O-O to relational model RationalRational RoseModeling in UML and application generation in C++ and JAVA Rogue WareRW MetroMapping from O-O to relational model Resolution Ltd.XcaseConceptual modeling up to code maintenance SybaseEnterprise Application SuiteData modeling, business logic modeling VisioVisio EnterpriseData modeling, design and reengineering Visual Basic and Visual C++