Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types Different Relationship Types in a Logical Relational Model.

Slides:



Advertisements
Similar presentations
Database Design J.G. Zheng May 19 th Overview Entity Relationship Modeling Data modeling using Entity Relationship Diagram (ERD) Transforming.
Advertisements

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.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Modeling Data The Entity Relationship Model (ER) For Database Design.
Methodology Logical Database Design for the Relational Model
Mapping the ER Model to Relations(1)1 Overview  Mapping entity types  Mapping relationship types  One-to-one  One-to-many  Many-to-many.
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
Motivation for IDEF1X Simplicity Common Standard Useful when relational model is target Air Force 1985 or thereabouts.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 6 Database Design Using Entity- Relationship Models.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Entity-Relationship (E-R) Model
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Mapping ERM to relational database
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.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Entity-Relationship modeling Transparencies
the Entity-Relationship Model
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
Converting ER model Into Relational Table
Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Relational DB Components
Chapter 5 Entity–Relationship Modeling
Entity Relationship Modeling
ER to Relational Translation COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
© 2002 by Prentice Hall 1 Database Design David M. Kroenke Database Concepts 1e Chapter 5 5.
Database Design Using Entity-Relationship Models Transformation of Entity-Relationship Models into Relational Database Design Trees, Networks, and Bills.
CSCI 3140 Module 3 – Logical Database Design for the Relational Model Theodore Chiasson Dalhousie University.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapters 15 &16 Conceptual and Logical Database Design Methodology.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
CS 3630 Database Design and Implementation. 2 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
CS 370 Database Systems Lecture 9 The Relational model.
Chapter 11 & 12 Entity-Relationship (E-R) Model Characteristics of E-R Model Components of E-R Model Example of E-R Model Enhanced E-R Model.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
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.
Jozef Kuper.  Describe a Database  Entities  Atributes  Relationships.
1 Data Modeling : ER Model…. Lecture Summary so for …. ER Model Entity, Attribute, Key Relationships Instance Diagram.
Mapping from conceptual model (EER-M)
1 Chapter 17 Methodology - Local Logical Database Design.
Databases Illuminated Chapter 3 The Entity Relationship Model.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Chapter 17 Logical Database Design for the Relational Model Pearson Education © 2009.
Database Systems – ER Diagrams EXAMPLE COMPANY DATABASE Requirements of the Company (oversimplified to illustrate) The company is organized into DEPARTMENTs.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
CSC271 Database Systems Lecture # 23. Summary: Previous Lecture  Database design using ER modeling  Concepts of ER model  Entities  Relationships.
Quiz Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.
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.
Logical Database Design and the Relational Model.
Transforming ER models to relational schemas
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
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.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 2: MODELING DATA.
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.
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.
Database Design I IST 210: Organization of Data IST2101.
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 تنبيه :
Presentation transcript:

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types Different Relationship Types in a Logical Relational Model

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1. Entity Types 1.1 Entity 1.1 Strong and Weak Entity 1.2 Representing Weak Entity 2. Binary Relationship Types 2.1 One-to-One Relationship 2.2 One-to-Many Relationship 2.3 Many-to-Many Relationship 2.4 Problem with Recursive Relationship 2.5 Other Problems for Relational Models Topics

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1. Entity Types 1.1 Entity 1.1 Strong and Weak Entity 1.2 Representing Weak Entity 2. Binary Relationship Types 2.1 One-to-One Relationship 2.2 One-to-Many Relationship 2.3 Many-to-Many Relationship 2.4 Problem with Recursive Relationship 2.5 Other Problems for Relational Models Topics

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.1 Entity An entity is an object that exists and is distinguishable from other objects  Example: specific person, company, event plant Entities have attributes  Example: people have names and adresses An entity set is a set of entities of the same type that share the same properties.  Example: set of all persons, companies, trees, holidays An entity is an object that exists and is distinguishable from other objects  Example: specific person, company, event plant Entities have attributes  Example: people have names and adresses An entity set is a set of entities of the same type that share the same properties.  Example: set of all persons, companies, trees, holidays

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.1 Example for Entity EmployeeNewOfKin Employee name salary position NewOfKin name phone

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.2 Strong and Weak Entity Types Create a relation that includes all simple attributes of that entity. Has sufficient attributes to form a primary key is called a strong entity. Entity Strong Entity Weak Entity Lacks sufficient attributes to form a primary key. A weak entity is an entity that exists only if is related to a set of uniquely determined entities, which are called the owners of the weak entity. A strong entity set is a dominant entity A weak entity set is a subordinate entity

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.3 Representing Weak Entity But every entity needs a key: What to do? - Must import attributes from strong entity set(s) - Importation is done via many-to-one relationship(s) - A weak entity set member is subordinate to the dominant entity(-ies) from strong entity set(s) providing (reliably) attributes to complete its key 1n The idea of strong and weak entity sets is related to the existence dependencies seen earlier.

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1. Entity Types 1.1 Entity 1.1 Strong and Weak Entity 1.2 Representing Weak Entity 2. Binary Relationship Types 2.1 One-to-One Relationship 2.2 One-to-Many Relationship 2.3 Many-to-Many Relationship 2.4 Problem with Recursive Relationship 2.5 Other Problems for Relational Models Topics

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1 : 1 One-to-One Entity B Entity A N : M Many-to- Many Entity B 1 : N One-to-Many Entity B 2. Binary Relationship Types Entity A

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.1 One-to-One Binary Relationship Types Each employee has one or none locker One locker is owned by one employee LOCKER EMPLOYEE 1:1 A 1:1 relationship cannot be used to identify parent and child entities in a relationship.

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.1 One-to-One Binary Relationship Types The key from one relation is placed in the other as a foreign key. It does not matter which table receives the foreign key. Foreign Key LOCKER EMPLOYEE 1:1 Emp_ID Locker_ID Emp_ID Locker_Desc Location Primary Key Foreign Key Primary Key EmpName

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.2 One-to-Many Binary Relationship Types Each employee is employed in only one Department Each department employs one ore more employees N DEPARTMENT EMPLOYEE 1:N Entity on the ‘1..1 side‘ is designated the parent entity and entity on the ‘1..N side‘ is the child entity.

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.2 One-to-Many Binary Relationship Types Like a 1:1 relationship, a 1:N relationship is saved by placing the key from one table into another as a foreign key However, in a 1:N the foreign key always goes into the ‘1..N side’ Foreign Key DEPARTMENT EMPLOYEE 1:N Emp_ID Emp_Name Dep_ID Dep_Address Dep_Phone Primary Key Dep_ID

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.3 Many-to-Many Binary Relationship Types Each employee has one or more skills Each skill is “owned “ by one or more employees 1..* SKILL EMPLOYEE N:M

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.3 N:M ->: not capable with Rel. Model IdentifiesDescribes EMP_Skill Skill_ID Emp_ID To save a N:M relationship, a new relation has to be created: the intersection relation SKILL EMPLOYEE N:M Skill_ID Emp_ID Skill_Desc Emp_Name n

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.4 Problem with Recursive Relationships TeamMember N:M SUPPORTER SUPORTEE Supports 0.. * TeamMember Support Supports Supported by *

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.5 Other Problems for Relational Models Complex relationship types have to be removed Solution: Create new relation Foreign keys: Primary keys of the participated entities Primary key: Foreign keys that represent a many (1..*,0..*) relationship + perhaps other attributes of new relation Multi-valued attributes (mva) aren‘t allowed Solution: Create new relation Primary key: Combination of mva and primary key of the related entity

Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types THE END Thank you for attention !