1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-2.

Slides:



Advertisements
Similar presentations
Database Design DB Chapter 5 J.G. Zheng June 29th 2005.
Advertisements

Chapter 6: Entity-Relationship Model (part I)
Text-Book Chapters (7 and 8) Entity-Relationship Model
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS34311 Translating ER Schema to Relational Model.
CS157A Lecture 3 ER Diagram Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Databases Revision.
Murali Mani The Relational Model. Murali Mani Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still.
Entity-Relationship Data Model CS 157A Professor Sin-Min Lee Student: Yen-Chu Pan.
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
CS34311 The Entity- Relationship Model. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design Conceptual.
CS34311 The Entity- Relationship Model Part II.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Chapter 2: Entity-Relationship Model (Continued)
Murali Mani The Entity- Relationship Model. Murali Mani Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model.
the Entity-Relationship Model
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Entity-Relationship Model Ch. 3
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
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.
Dr. Ahmad R. Hadaegh A.R. Hadaegh California State University San Marcos (CSUSM) Page 1 Entity Relational Diagram (ERD) Modeling This particular lecture.
©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.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Entity – Relationship Model (E-R Model)
Computing & Information Sciences Kansas State University Wednesday, 24 Sep 2008CIS 560: Database System Concepts Lecture 12 of 42 Wednesday, 24 September.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
CS3431: C-Term The Entity- Relationship Model Part II. Instructor: Mohamed Eltabakh
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues 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.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
1 Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
ITTelkom Entity Relationship Diagram (1) CS2343 Perancangan Basisdata Relasional.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
CS34311 Translating ER Schema to Relational Model.
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh
Database Systems – ER Diagrams EXAMPLE COMPANY DATABASE Requirements of the Company (oversimplified to illustrate) The company is organized into DEPARTMENTs.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
Data Modeling Using the Entity-Relationship (ER) Data Model.
The Entity-Relationship Model
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-3.
CS34311 The Entity- Relationship Model Part III..
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
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.
CS3431-B111 The Entity- Relationship Model Part II. Instructor: Mohamed Eltabakh
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
CS3431: C-Term Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
CS34311 Translating ER Schema to Relational Model.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Entity-Relationship Data Model
Translating ER Schema to Relational Model
Entity-Relationship Model
Entity Relationship Model
Entity-Relationship Model
Translating ER Schema to Relational Model
The Entity-Relationship Model
The Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
Entity-Relationship Data Model
Presentation transcript:

1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-2

More Elements in ER Model Key Constraints Cardinality Constraints Weak Entities Subclass Entities (ISA Relationships) Principles for Good Design 2 Adding these elements to ERD makes the model more accurate

Keys of Entity Sets Remember entity set is a group of entities with the same type Key of Entity Set Set of attributes that uniquely identify each entity Examples: “Car”  VIN “Person”  SSN “WPI Student”  University ID “US Student”  (UniversityName + UnivesityID), Or SSN A key has to be unique within the scope of your application Does not have to be globally unique 3 CustomerCar

Types of Keys A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity “Person”  SSN, SSN + FirstName “Account”  AccountNumber + AccountType A candidate key of an entity set is a minimal super key “Person”  SSN “Account”  AccountNumber “US Student”  SSN, UniversityName + UnivesityID Each candidate key is a super key but not vice versa A primary key is one from, possibly several, candidate keys  Pick one and declare it as “primary key” “Student”  SSN, StudentID, FirstName + MiddleName + LastName 4

Keys Summary Key combination of one or more attributes that uniquely identify an entity Types: Super key (does not have to be minimal) Candidate key (minimal super key) Primary key (any one from the candidate keys) 5 Only primary keys are modeled in ERD

Primary Keys in ERD Select only one key to be the primary key Primary key is modeled by “underline” under its set of attributes Good Practice: Select singleton and number attributes whenever possible 6

7 Multi-Attributes Primary Key Key for Student is sNumber Key for Movie is We can represent key for entity set consisting of more than one attribute (e.g.: Movie)

8 Multi-Attributes Primary Key What does it mean? Key for Movie is year -Movie title is unique -Cannot have two movies in the DB with the same title -(title, year) together are unique -Cannot have two movies with the same title in the same year -Can have in the DB movies with the same title but on different years

Keys of Relationships Relationship without attributes The combination of primary keys of the participating entity sets forms a key of a relationship set (customer_id, load_number) is the key of borrower 9

Keys of Relationships (Cont’d) Relationship with attributes Attributes of the relationship may (not always) participate inside the key + the external keys (sNumber, cNumber) is the key of the relationship 10 semeste r project Grade

Keys of Relationships (Cont’d) Relationship with attributes Attributes of the relationship may (not always) participate inside the key + the external keys (sNumber, cNumber, semester) is the key of Taken 11 semester project Grade

What Does it Mean…? 12 Which one is more practical and why? A student can take a course only once over all semesters A student can take the same course over different semesters (more flexible assumption)

More Elements in ER Model Key Constraints Cardinality Constraints Weak Entities Subclass Entities (ISA Relationships) Principles for Good Design 13

Cardinality Constraints Express the number of entities to which another entity can be associated via a relationship set Most useful in describing binary relationship sets For a binary relationship set the mapping cardinality must be one of the following types: One to one One to many Many to one Many to many 14

Mapping Cardinalities 15

Mapping Cardinalities (Cont’d) 16

Representing Cardinalities in ERD In a relationship: “ ” : Represent “many” (including 0) “ ” : Represent “one” (including 0) “ ”: Represent “one” (must be one) 17 A student is taking “many” courses. A course can be taken by “many” students.

One-To-Many Relationship 18

One-To-Many Relationship In the one-to-many relationship a loan is associated with at most one customer via borrower, a customer is associated with many (including 0) loans via borrower 19 A customer can take many loans A loan can be taken by one (and at least one) customer

Many-To-One Relationship 20

Many-To-One Relationship In a many-to-one relationship a loan is associated with many (including 0) customers via borrower, a customer is associated with at most one loan via borrower 21 A customer can take at most one loan A loan can be taken by many customers

Many-To-Many Relationship In a many-to-many relationship a loan is associated with many (including 0) customers via borrower, a customer is associated with many loan via borrower 22

23 Degree of Cardinalities How : Expressed using (min, max) Student can take many courses, and a course can be taken by many students Student can take 0 to 5 courses, and a course can be taken by 3 to 60 students (3, 60) (0, 5)

24 Cardinality Constraints for Recursive Relationships A Part may contain many subparts A Part can be subpart in many superParts Contains Part pName pNumber subPartsuperPart quantity

25 Cardinality Constraints for Recursive Relationships A Part can have many subParts A Part can be subpart for at most one superPart

Revisit this example… 26 Employees & Managers ….. Add cardinalities Employee ID Name Supervise supervisor supervised Semantics: Manager can supervise many employees Employee is supervised by one manager

27 Cardinality Constraints for Multi-way Relationships Every Supplier supplies some Product to some Consumer Supplier sName sLoc Consumer cName cLoc Supply price Product pName pNumber qty Adding degree constraints over multi-way relationship is complex and not easy to understand…

28 Cardinality Constraints for Multi-way Relationships Every Supplier supplies some Product to some Consumer To add degree constraints, introduce a new entity set and create multiple binary relationships !!! We can always convert a multi-way to binary this way

Adding Cardinality Constraints to Multi-way Relationships 29 Supplier sName sLoc Consumer cName cLoc price Product pName pNumber qty Contract What is the key of this entity ??? (Weak Entity) supplies consumes in

What about an Exercise ( Book publisher company) 30