Lecture 10: The E/R Model III

Slides:



Advertisements
Similar presentations
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Advertisements

Information Systems Chapter 4 Relational Databases Modelling.
Lecture 6: Design Constraints and Functional Dependencies January 21st, 2004.
CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology.
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.
1 Lecture 3: Database Modeling (continued) April 5, 2002.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Multiplicity in E/R Diagrams
The Relational Data Model Database Model (ODL, E/R) Relational Schema Physical storage ODL definitions Diagrams (E/R) Tables: row names: attributes rows:
1 Lecture 4: Database Modeling (end) The Relational Data Model April 8, 2002.
CS411 Database Systems Kazuhiro Minami
Conceptual Design Lecture - 2 Database Development.
E/R Diagrams and Functional Dependencies. Modeling Subclasses The world is inherently hierarchical. Some entities are special cases of others We need.
Lecture 08: E/R Diagrams and Functional Dependencies.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
1 CSE 480: Database Systems Lecture 4: Enhanced Entity-Relationship Modeling Reference: Read Chapter 8.1 – 8.5 of the textbook.
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.
ER Diagrams and Relational Model CS 174a (Winter 2015)
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.
CS422 Principles of Database Systems Entity-Relationship Model
COP Introduction to Database Structures
Contents Design Process Modeling Constraints E-R Diagram Design Issues
Comp 1100 Entity-Relationship (ER) Model
Relational Database Design by ER- and ERR-to-Relational Mapping
Enhanced Entity-Relationship (EER) Model
Lecture 5: Conceptual Database Design
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
Enhanced Entity-Relationship and Object Modeling Objectives
Relational Database Design by ER- and EER-to- Relational Mapping
COP4710 Database Systems E-R Model.
Session 2 Welcome: The sixth learning sequence
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Lecture 4 Lecture 4: The E/R Model.
Chapter 7: Entity-Relationship Model
ER- and EER-to-Relational
Constraints in Entity-Relationship Models
9/5/2018.
Cse 344 March 2nd – E/r diagrams.
Instructor: Elke Rundensteiner
Cse 344 May 14th – Entities.
11/15/2018.
From E/R Diagrams to Relational Schema
Lecture 4: Database Modeling (continued)
Module 8 – Database Design Using the E-R Model
Lecture 2: Database Modeling (end) The Relational Data Model
Chapter 8: Mapping a Conceptual Design into a Logical Design
Lecture 06 Data Modeling: E/R Diagrams
Relational Database Design by ER- and EER-to-Relational Mapping
name category name price makes Company Product stockprice buys employs
The Entity-Relationship Model
CMPT 354: Database System I
Lecture 8: The E/R Model I
Lecture 9: The E/R Model II
Chengyu Sun California State University, Los Angeles
Lecture 5: The Relational Data Model
Relational Database Design by ER- and EER-to- Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
4/11/2019.
CS4433 Database Systems E-R Model.
Relational Database Design by ER- and EER-to-Relational Mapping
Lecture 08: E/R Diagrams and Functional Dependencies
CS4222 Principles of Database System
7/19/2019.
CS4222 Principles of Database System
Chapter 6b: Database Design Using the E-R Model
Presentation transcript:

Lecture 10: The E/R Model III Lecture and activity contents are based on what Prof Chris Ré used in his CS 145 in the fall 2016 term with permission.

3. Advanced E/R Concepts

What you will learn about in this section Subclasses & connection to OO Constraints Weak entity sets ACTIVITY: Crayon Time! Drawing E/R diagrams Pt. III

Modeling Subclasses We can define subclasses in E/R! Some objects in a class may be special, i.e. worthy of their own class Define a new class? But what if we want to maintain connection to current class? Better: define a subclass Ex: Products Software products Educational products We can define subclasses in E/R!

Modeling Subclasses Product name price Child subclasses contain all the attributes of all of their parent classes plus the new attributes shown attached to them in the E/R diagram isA Software Product platforms Educational Product ageGroup

Understanding Subclasses Think in terms of records; ex: Product SoftwareProduct EducationalProduct name price Child subclasses contain all the attributes of all of their parent classes plus the new attributes shown attached to them in the E/R diagram Product name price isA Educational Product Software Product ageGroup platforms name price platforms name price ageGroup

Think like tables… Product Sw.Product Ed.Product name price category Gizmo 99 gadget Camera 49 photo Toy 39 Product name price isA Educational Product Software Product ageGroup platforms Sw.Product name platforms Gizmo unix Ed.Product name ageGroup Gizmo todler Toy retired

Difference between OO and E/R inheritance OO: Classes are disjoint (same for Java, Python, C++) i.e., a software product can’t be a educational product in Java, Python, … OO = Object Oriented. E.g. classes as fundamental building block, etc… p1 p2 p3 sp1 sp2 ep1 ep2 ep3 Product SoftwareProduct EducationalProduct

Difference between OO and E/R inheritance E/R: entity sets overlap SoftwareProduct EducationalProduct p1 p2 p3 sp1 sp2 ep1 ep2 ep3 Product

Difference between OO and E/R inheritance We have three entity sets, but four different kinds of objects Product p1 p2 p3 sp1 sp2 ep1 ep2 ep3 EducationalProduct SoftwareProduct esp2 esp1 No need for multiple inheritance in E/R

IsA Review If we declare A IsA B then every A is a B We use IsA to Add descriptive attributes to a subclass To identify entities that participate in a relationship No need for multiple inheritance

Modeling UnionTypes With Subclasses Person FurniturePiece Company Suppose each piece of furniture is owned either by a person, or by a company. How do we represent this?

Modeling Union Types with Subclasses Say: each piece of furniture is owned either by a person, or by a company Solution 1. Acceptable, but imperfect (What’s wrong ?) Person FurniturePiece Company ownedByPerson ownedByComp

Modeling Union Types with Subclasses Solution 2: better (though more laborious) FurniturePiece What is happening here? ownedBy Owner Person Company isa

Constraints in E/R Diagrams Finding constraints is part of the E/R modeling process. Commonly used constraints are: Keys: Implicit constraints on uniqueness of entities Ex: An SSN uniquely identifies a person Single-value constraints: Ex: an NFL player can only belong to one team at any moment Referential integrity constraints: Referenced entities must exist Ex: if you work for a company, it must exist in the database Other constraints: Ex: peoples’ ages are between 0 and 150 Recall FOREIGN KEYs!

Participation Constraints: Partial v. Total makes Product Company Are there products made by no company? Companies that don’t make a product? makes Product Company Bold line indicates total participation (i.e. here: all products are made by a company)

One More Example: Partial v. Total Owns Apartment People Are there apartments owned by no people? People who don’t own an apartment? Owns Apartment People Bold line indicates total participation: all apartments are owned by some people.

Keys in E/R Diagrams name category Underline keys: price Note: no formal way to specify multiple keys in E/R diagrams… Product Person name ssn address

Single Value Constraints See previous section! makes v. s. makes

Referential Integrity Constraints Company Product makes Each product made by at most one company. Some products made by no company? Company Product makes Each product made by exactly one company.

Weak Entity Sets Entity sets are weak when their key comes from other classes to which they are related. name University Team affiliation number sport “Football team” v. “The Stanford Football team” (E.g., Berkeley has a football team too)

Weak Entity Sets Entity sets are weak when their key comes from other classes to which they are related (not independent). affiliation Team University sport number name number is a partial key. (denote with dashed underline). University is called the identifying owner. Participation in affiliation must be total. Why?

E/R Summary E/R diagrams are a visual syntax that allows technical and non-technical people to talk For conceptual design Basic constructs: entity, relationship, and attributes A good design is faithful to the constraints of the application, but not overzealous

Activity 4-3: Weak entities, constraints

Add in: Subclasses, constraints, and weak entity sets Concepts to include / model: Players are either on Offense or Defense, and are of types (QB, RB, WR, TE, K, …) All passes are to exactly one player; all runs include a player Teams belong to cities- model as weak entity sets Make sure you have designated keys for all our concepts!