ER to Relational Translation COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.

Slides:



Advertisements
Similar presentations
Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Advertisements

Relational Database Design Via ER Modelling
How to translate ER Model to Relational Model By: Jung T. Chang CS 157A T/Th Morning Section.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
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.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
E R Model to Relational Model
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
CS F212 Database Systems Today’s Class E R Model.
Entity-Relationship Model and Diagrams (continued)
Information Resources Management February 13, 2001.
Chapter 3: Relational Model
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
©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.
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Amity School of Engineering & Technology E-R Diagram for a University Enterprise.
Ch 6: ER to Relational Mapping
Entity-Relationship modeling Transparencies
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
Database Design Concepts
Web-Enabled Decision Support Systems
Chapter 5 Entity–Relationship Modeling
ER to Relational Translation COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
Concepts and Terminology Introduction to Database.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5.
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
IE 423 – Design of Decision Support Systems Data modeling and database development.
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.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
DATABASE MANAGEMENT SYSTEM Entity-Relationship Model.
Relational Theory and Design
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Databases Illuminated Chapter 3 The Entity Relationship Model.
Chapter 6: Entity-Relationship Model. 6.2Unite International CollegeDatabase Management Systems Chapter 6: Entity-Relationship Model Modeling Constraints.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
Week 7-8 DBMS ER-Relational Mapping. ER-Relational Mapping.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Entity-Relationship Modeling. 2 Entity Type u Entity type –Group of objects with same properties, identified by enterprise as having an independent existence.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Chapter 2: Entity-Relationship Model. 3.2 Chapter 2: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity.
©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.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
Database System Concepts, 7 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module 4: Overview of.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
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.
How to translate ER Model to Relational Model. Review - Concepts Relational Model is made up of tables A row of table = a relational instance/tuple A.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Entity-Relationship Model
Tables and Their Characteristics
Chapter 7 Entity-Relationship Model
Data Models.
How to translate ER Model to Relational Model
Session 2 Welcome: The seventh learning sequence
DBMS ER-Relational Mapping
Presentation transcript:

ER to Relational Translation COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI

Relational Models Tables: In relation data model, relations are saved in the format of Tables. This format stores the relation among entities. A table has rows and columns, where rows represent records and columns represents the attributes. Tuple: A single row of a table, which contains a single record for that relation is called a tuple. Relation instance: A finite set of tuples in the relational database system represents relation instance. Relation instances do not have duplicate tuples.

Relational Models Relation schema: This describes the relation name (table name), attributes and their names. Relation key: Each row has one or more attributes which can identify the row in the relation (table) uniquely, is called the relation key. Attribute domain: Every attribute has some pre-defined value scope, known as attribute domain.

From ER Model to Relational Model So… how do we convert an ER diagram into a table?? Simple!! Basic Ideas:  Build a table for each entity set  Build a table for each relationship set if necessary (more on this later)  Make a column in the table for each attribute in the entity set  Primary Key

Example – Strong Entity Set SIDNameMajorGPA 1234JohnCS MaryEE3.6 Student SIDName Major GPA Advisor Professor SSNName Dept SSNNameDept 9999SmithMath 8888LeeCS

Representation of Weak Entity Set Weak Entity Set Cannot exists alone To build a table/schema for weak entity set ◦Construct a table with one column for each attribute in the weak entity set ◦Augment one extra column on the right side of the table, put in there the primary key of the Strong Entity Set (the entity set that the weak entity set is depending on) ◦Primary Key of the weak entity set = foreign key

Example – Weak Entity Set AgeNameParent_SID 10Bart1234 8Lisa5678 Student SIDName Major GPA Name Age Childrenowns * Primary key of Children is Parent_SID + Name

Representation of Relationship Set Unary/Binary Relationship set  Depends on the cardinality and participation of the relationship N-ary (multiple) Relationship set Identifying Relationship  No relational model representation necessary

Representing Relationship Set Unary/Binary Relationship For one-to-one relationship w/out total participation ◦Build a table with two columns, one column for each participating entity set’s primary key. Add successive columns, one for each descriptive attributes of the relationship set (if any). For one-to-one relationship with one entity set having total participation ◦Augment one extra column on the right side of the table of the entity set with total participation, put in there the primary key of the entity set without complete participation as per to the relationship.

Example – One-to-One Relationship Set SIDMaj_ID CoS_Degree Student SIDName Major GPA ID Code Majorstudy * Primary key can be either SID or Maj_ID_Co Degree

Example – One-to-One Relationship Set SIDNameMajorGPALP_S/NHav_Cond 9999BartEconomy Own 8888LisaPhysics Loan Student SIDName Major GPA S/N # LaptopHave * Primary key can be either SID or LP_S/N Condition Brand 1:1 Relationship

Representing Relationship Set Unary/Binary Relationship For one-to-many relationship w/out total participation ◦Same thing as one-to-one For one-to-many/many-to-one relationship with one entity set having total participation on “many” side ◦Augment one extra column on the right side of the table of the entity set on the “many” side, put in there the primary key of the entity set on the “one” side as per to the relationship.

Example – Many-to-One Relationship Set SIDNameMajorGPAPro_SSNAd_Sem 9999BartEconomy Fall LisaPhysics Fall 2005 Student SIDName Major GPA SSN Professor * Primary key of this table is SID Semester Name N:1 Relationship Dept Advisor

Representing Relationship Set Unary/Binary Relationship For many-to-many relationship ◦Same thing as one-to-one relationship without total participation. ◦Primary key of this new schema is the union of the foreign keys of both entity sets.

Representing Relationship Set N-ary Relationship Intuitively Simple ◦Build a new table with as many columns as there are attributes for the union of the primary keys of all participating entity sets. ◦Augment additional columns for descriptive attributes of the relationship set (if necessary) ◦The primary key of this table is the union of all primary keys of entity sets that are on “many” side ◦That is it, we are done.

Example – N-ary Relationship Set P-Key1P-Key2P-Key3A-KeyD-Attribute Yes No E-Set 1 P-Key1 Another Set * Primary key of this table is P-Key1 + P-Key2 + P-Key3 D-Attribute A relationship A-Key E-Set 2 P-Key2 E-Set 3 P-Key3

Representing Composite Attribute Relational Model Indivisibility Rule Applies One column for each component attribute NO column for the composite attribute itself Professor SSNName Address SSNNameStreetCity 9999Dr. Smith50 1 st St.Fake City 8888Dr. Lee1 B St.San Jose StreetCity

Representing Multivalue Attribute For each multivalue attribute in an entity set/relationship set ◦Build a new relation schema with two columns ◦One column for the primary keys of the entity set/relationship set that has the multivalue attribute ◦Another column for the multivalue attributes. Each cell of this column holds only one value. So each value is represented as an unique tuple ◦Primary key for this schema is the union of all attributes

Example – Multivalue attribute SIDNameMajorGPA 1234JohnCS HomerEE3.6 Student SIDName Major GPA Stud_SIDChildren 1234Johnson 1234Mary 5678Bart 5678Lisa 5678Maggie Children The primary key for this table is Student_SID + Children, the union of all attributes