COMP 430 Intro. to Database Systems ER Design Considerations Slides use ideas from Chris Ré.

Slides:



Advertisements
Similar presentations
Exercise 1 Consider the ER diagram below. Assume that an employee may work in up to two departments or may not be assigned to any department. Assume that.
Advertisements

Relational Database Design Via ER Modelling
Prof. Sin-Min Lee Department of Computer Science
Information Systems Chapter 4 Relational Databases Modelling.
1 Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – EER Model –21th June.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
1 Lecture 04 Entity/Relationship Modelling. 2 Outline E/R model (Chapter 5) From E/R diagrams to relational schemas (Chapter 5) Constraints in SQL (Chapter.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Enhanced Entity-Relationship (EER) Modeling.
Enhanced ER-diagram Prof. Sin-Min Lee Department of Computer Science.
Sunday, June 28, Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)
1 Lecture 3: Database Modeling (continued) April 5, 2002.
1 Enhanced Entity Relationship Modelling EER Model Concepts Includes all basic ER modeling concepts Additional concepts: subclasses/superclasses specialization/generalization.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Multiplicity in E/R Diagrams
EXTENDED-ER (EER) MODEL CONCEPTS. Enhanced-ER (EER) Model Concepts  Basic ER diagram + more concepts =EER model  Additional concepts:  Subclasses/superclasses.
Enhanced Entity-Relationship and UML Modeling. Enhanced-ER (EER) Model Concepts Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses,
Ch 6: ER to Relational Mapping
CS411 Database Systems Kazuhiro Minami
Database Design April 3, Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed.
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Relational Database Design by ER- and EER-to-Relational Mapping
the Entity-Relationship Model
Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Relationships: like in ODL except - not associated with.
Entities and Attributes
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
© Shamkant B. Navathe CC. © Shamkant B. Navathe CC Chapter 4 - Part I Enhanced Entity-Relationship and UML Modeling Copyright © 2004 Ramez Elmasri and.
Enhanced Entity – Relationship (EER) and Object Modeling (Based on Chapter 4 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
1 Introduction to Database Systems CSE 444 Lecture 07 E/R Diagrams October 10, 2007.
Entity Relationship Diagram (2)
Lecture 2: E/R Diagrams and the Relational Model Wednesday, April 3 rd, 2002.
Relational Database Design by ER- and EERR-to-Relational Mapping.
Enhanced Entity-Relationship (EER) Modeling. Slide 4- 2 Chapter Outline EER stands for Enhanced ER or Extended ER EER Model Concepts Includes all modeling.
Weak Entity Sets A weak entity is an entity that cannot exist in a database unless another type of entity also exists in that database. Weak entity meets.
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Ramez Elmasri and Shamkant Navathe Enhanced-ER (EER) Model Concepts.
© Shamkant B. Navathe CC Enhanced Entity-Relationship Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
COMP 430 Intro. to Database Systems ER Implementation as Tables Slides use ideas from Chris Ré.
COMP 430 Intro. to Database Systems Entity-Relationship Diagram Basics Slides use ideas from Chris Ré.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Introduction to Database Systems
Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping.
Lecture 3 A short revision of ER and EER modelling See R. Elmasri, S.B. Navathe. Fundamentals of Database Systems (third edition) Addison-wesley. Chapter.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
Chapter 4_part2: The Enhanced Entity-Relationship (EER) Model.
Databases (CS507) CHAPTER 8
Lecture 4: The E/R Model Lecture 4 Today’s Lecture 1.E/R Basics: Entities & Relations ACTIVITY: Crayon time! 2.E/R Design considerations ACTIVITY: Crayon.
Databases (CS507) CHAPTER 7.
Enhanced Entity-Relationship (EER) Model
Lecture 5: Conceptual Database Design
EER Model – Chapter
Session 2 Welcome: The sixth learning sequence
Enhanced Entity-Relationship (EER) Modeling
Lecture 4 Lecture 4: The E/R Model.
Conceptual Database Design
Entity – Relationship Model
Lecture 06 Data Modeling: E/R Diagrams
name category name price makes Company Product stockprice buys employs
Lecture 9: The E/R Model II
Sampath Jayarathna Cal Poly Pomona
Sampath Jayarathna Cal Poly Pomona
Enhanced Entity-Relationship (EER) Modeling
Presentation transcript:

COMP 430 Intro. to Database Systems ER Design Considerations Slides use ideas from Chris Ré.

Book Writes Publishes GoesOnLoan Borrower Author ID address Solution to Library Activity Publisher Loan Borrows name ISBNtitle num_copies address name card_num ISBN card_num date

Relationship multiplicity abcdabcd One-to-one: abcdabcd Many-to-one: abcdabcd One-to-many: abcdabcd Many-to-many: Recall that X  Y represents a function mapping from X to Y. There are a variety of ER styles, differing primarily in these edge notations.

address namessn Person Buys Makes Employs Company Product namecategory stockprice name price What does this diagram say?

What’s wrong? Purchase ProductPerson President PersonCountry

What’s wrong? Purchase Product Store date PersonName PersonAddr

Weak entity sets name University Team Affiliation IDsport Existence/meaning is dependent on another entity set(s). Part of their key comes from that other entity set(s)

Decide: weak or not? name University Team Affiliation IDsportname CityTeam Affiliation IDsport College: Professional:

Many-to-many junctions often weak CourseStudent Enrollment CourseOfStudentOf crns_idgradesemester

N-ary relationships Purchase Product Person Store Purchase is a subset of Person  Product  Store. Entity sets should have primary keys. Omitted for brevity.

Arrows in n-ary relationships Purchase Product Person Store Meaning: Given Person, then Store & Product are determined. I.e., each person can make one purchase – and thus of one product at one store.

Arrows in n-ary relationships Purchase Product Person Store Meaning: Given Product & Person, then Store is determined. I.e., any person can buy any given product at most once – and thus at one store.

Arrows in n-ary relationships Purchase Product Person Store How to say: “Every person shops in at most one store.”?

Can convert n-ary to binary Purchase Person Store Product StoreOf ProductOf BuyerOf date How has the meaning changed? Add what arrows?

Decision: n-ary or binary? Purchase Person Store Product StoreOf ProductOf BuyerOf date Purchase Product Person Store Allows multiple purchases per Product-Store-Person combination. Allows attributes/constraints on Purchase. “A person who shops in only one store.” “How long a person has been shopping at a store.” Best when relationship really is between multiple entities.

What’s wrong? Purchase Product Person Store date Dates

Decision: attribute or entity set? Employee address1 address2 Address street_addr ZIP Employee AddrOf Difference in meaning? Advantages of each? Add what arrows?

Activity – Add arrows to ER diagram Authors have IDs and names. They write books. Books have ISBNs and titles. The library keeps track of how many copies it has of the book. Each book is written by authors and published by a publisher. We want to know every time it is checked out by a borrower. Borrowers have a library card number, name, and address. They can check out a book on a particular date. Publishers have an ID, name and address. They publish books.

Book Writes Publishes GoesOnLoan Borrower Author ID address Solution to Library Activity Publisher Loan Borrows name ISBNtitle num_copies address name card_num date

Partial vs. total participation Makes ProductCompany Are there products made by no company? Makes ProductCompany Each Product must be made by some Company.

Partial vs. total – alternate wording Makes ProductCompany Each product made by 0 or 1 companies. Each company makes 0 or more products. Makes ProductCompany Each product made by 1 company. Each company makes 0 or more products.

Total participation & weak entity sets name University Team Affiliation IDsport Recall: Weak entity set must be associated with some strong entity set.

Subclasses & inheritance Product name price Software Product platforms Educational Product age_group Every entity in subclass must be entity in superclass. I.e., subclasses are subsets of superclass. Subclasses inherit superclass attributes.  

ER subclasses very flexible Product name price Software Product platforms Educational Product age_group Default: Partial I.e., a Product doesn’t have to be in any subclass. Default: Not disjoint I.e., a Product can be in multiple subclasses.  

ER subclass options Employee ID name HourlyEmployee rate SalaryEmployee salary Total Every Employee must be in one or more subclasses. disjoint An Employee can’t be both hourly and salaried. D  

Can have just one subclass Employee emp_id name Manager project  Employee emp_id name Manager project 

Hierarchy of subclasses

The need for categories/unions Goal: “Every art piece is owned by a person or company.” ArtPiece Person Company OwnedByPerson OwnedByComp What is the problem?

Solution with categories/unions Goal: “Every art piece is owned by a person or company.” ArtPiece Person Company OwnedBy ArtCollector 

Partial vs. total unions Not every Person and Company collects art. Person Company ArtCollector  Car Truck RoadVehicle  Bicycle All cars, trucks, and bicycles are vehicles.

Multiple superclasses Person Company ArtCollector  Car Truck RoadVehicle  Bicycle Each subclass entity belongs to & inherits from the appropriate one superclass. Copier Printer All-in-one  ScannerFax    Each subclass entity belongs to & inherits from all superclasses.

Decision: total union or subclasses? Car Truck RoadVehicle  Bicycle Car Truck D RoadVehicle  Bicycle   Use if Car, Truck, Bicycle have (many) common attributes. Move those to RoadVehicle.

Activity – Add participation, sub/superclasses Authors have IDs and names. They write books or chapters of book. Books have ISBNs and titles. The library keeps track of how many copies it has of the book. Each book is written by authors and published by a publisher. We want to know every time it is checked out by a borrower. Borrowers have a library card number, name, and address. They can check out a book on a particular date. Publishers are typically a company with an ID, name and address. They publish books. Alternatively, authors can self-publish.