CS411 Database Systems Kazuhiro Minami

Slides:



Advertisements
Similar presentations
Constraints in Entity-Relationship Models Zaki Malik September 18, 2008.
Advertisements

1–1 Students Entity/Relationship Model Diagrams to represent designs. Entity like object, = “thing.” Entity set like class = set of “similar” entities/objects.
CSCI 305 – Fall 2013 The Entity-Relationship Model Based on Slides by Prof. Brian King.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Information Systems Chapter 4 Relational Databases Modelling.
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
Chapter 4 Notes. Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Design Principles: Faithfulness
Weak Entity Sets. Occasionally, entities of an entity set need “help” to identify them uniquely. Example. Crews might have a number and some description,
Design Principles: Faithfulness
Database Design and the E-R Model Chapter 7 [1 of 2]
1 Relational Model and Translating ER into Relational.
1 Entity-Relationship Model Slides by Jeffrey Ullman Modified by J. Welch to replace beers with candies.
DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design II (week 3)
A four-way Relationship
Fall 2001Arthur Keller – CS 1802–1 Schedule Today Sep. 25 (T) u More Entity-Relationship Model. u Read Sections Note: Sep. 27 (TH) Class cancelled.
The Entity-Relationship Data Model
1 Lecture 3: Database Modeling (continued) April 5, 2002.
1 Conceptual Design with ER Model Lecture #2. 2 Lecture Outline Logistics Steps in building a database application Conceptual design with ER model.
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
Winter 2002Arthur Keller – CS 1802–1 Schedule Today: Jan. 8 (T) u Weak Entity Sets, Entity-Relationship Design. u Read Sections Jan. 10 (TH) u.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Multiplicity in E/R Diagrams
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
E/R Diagrams and Functional Dependencies. Modeling Subclasses The world is inherently hierarchical. Some entities are special cases of others We need.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 3 Introduction to a First Course in Database Systems.
1 Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Databases : Entity-Relationship Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Database Management Systems Chapter 2 The Entity-Relationship Data Model Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
ER Data Models Ctd. CSET 3300.
1 Entity-Relationship Model Chapter 2 Copyright : Jeff Ullman + Hank Korth.
1 Database Systems ( 資料庫系統 ) September 27/28, 2006 Lecture #2.
1 Session 2 Welcome: The fifth learning sequence “ Entity-Relationship Model -2“ E-R Model Recap : In the previous learning sequence, we discussed the.
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.
Tallahassee, Florida, 2015 COP4710 Database Systems E-R Model Fall 2015.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Entity-Relationship Model
SAnta Clara UniversityHolliday – COEN 1782–1 Today’s Topic Today: u Constraints, Weak Entity Sets, Entity- Relationship Design. u Read Sections
Winter 2006Cushing Keller UllmanJudy Cushing2–1 Weak Entity Sets Sometimes an E.S. E ’s key comes not (completely) from its own attributes, but from the.
Dale Roberts 11/26/ Department of Computer and Information Science, School of Science, IUPUI Fall 2003 Dale Roberts, Lecturer Computer Science, IUPUI.
Home Work. Design Principles and Weak Entity Sets.
Databases 1 Fifth lecture. Entity-Relationship Model Diagrams Class hierarchies Weak entity sets From E/R diagrams to Relations 2.
Entity-Relationship Modelling ER Diagrams and EER Diagrams Some design techniques Elements and process: text  diagram Slides by Jeff Ullman (infolab.stanford.edu/~ullman/dscb/pslides/er.ppt),
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 4 Introduction to a First Course in Database Systems.
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
Entity-Relationship Model E/R Diagrams Converting E/R Diagrams to Relations.
Winter 2002Arthur Keller – CS 1802–1 Weak Entity Sets Sometimes an E.S. E ’s key comes not (completely) from its own attributes, but from the keys of one.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
1 Database Systems ( 資料庫系統 ) 9/23/2009 Lecture #2.
Functional Dependencies. Babies Exercise 2.2.5: At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses,
CS 405G Introduction to Database Systems Lecture 3: ER Model Instructor: Chen Qian.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
Database Design and Programming Jan Baumbach Adopted from previous slides of Peter Schneider-Kamp.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture.
Introduction to Database Systems, CS420
Entity-Relationship Model
COP4710 Database Systems E-R Model.
Weak Entity Sets Sometimes an E.S. E ’s key comes not (completely) from its own attributes, but from the keys of one or more E.S.’s to which E is linked.
02: ER Model Ch 4.1 – 4.4 Optionally, begin with Ch 2.1.
Constraints in Entity-Relationship Models
CPSC-310 Database Systems
Instructor: Zhe He Department of Computer Science
Session 2 Welcome: The fifth learning sequence
CS4433 Database Systems E-R Model.
CS 405G: Introduction to Database Systems
Presentation transcript:

CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model Data modeling for high-level design http://www.cs.uiuc.edu/class/fa09/cs411/index.html Kazuhiro Minami

The ER model is very simple name name category price makes Company Product stockprice buys employs 3 main types of concepts: entity sets, relations, attributes no operations Similar to object design analysis Person name ssn address

We can show the cardinality of a relationship E F one-one many-one many-many 1 2 3 a b c d 1 2 3 a b c d 1 2 3 a b c d makes Company Product

Exercise 4.2.5 (Multiway relationships) At a birth, there is one baby, one mother, any number of nurses, and any number of doctors. For each, tell how to add arrows or other elements to the E/R diagram. a) For every baby, there is a unique mother b) For every combination of a baby, nurse, and doctor, there is a unique mother c) For every combination of a baby and a mother there is a unique doctor. Mothers Births Babies Nurses Doctors (baby, mother, nurse, doctor) = (Bob, Mary, Kate, Dave)

Underline the key for each entity set name category multi-attribute keys are okay! price Product Multiple “candidate keys”? Pick just one to be the key. Person Is this a good key? weak entity sets name ssn address

Referential Integrity Constraints The reference integrity constraint on relationships explicitly requires a reference to exist The DB equivalent of a dangling pointer makes Company Product makes Company Product )

Sometimes your entity might not seem to have a key Weak entity set: some or all of its key attributes come from other classes to which it is related. Referential integrity constraint Weak entity set affiliation Team ) University sport record name

Exercise 2 Q1. One way to represent students and the grades they get in course is to use entity sets corresponding to students, to courses, and to “enrollments.” Enrollment entities form a “connecting” entity set between students and courses and can be used to represent not only the fact that a student is taking a certain course, but the grade of the student in the course. Draw an E/R diagram for this situation, indicating weak entity sets and the keys for the entity set. You can assume an appropriate set of attributes for “students” and “courses” entitysets. Q2. Modify your solution so that we can record grades of the student for each of several assignments within a course.

Subclasses Subclass = special case = fewer entities = more properties. Example: Ales are a kind of beer. Not every beer is an ale, but some are. Let us suppose that in addition to all the properties (attributes and relationships) of beers, ales also have the attribute color.

Example Beers name manufacturer isa Ales color

ER subclasses are different from object oriented subclasses In the object-oriented world, objects are in one class only. Subclasses inherit properties from superclasses. In contrast, E/R entities have components in all subclasses to which they belong. Matters when we convert to relations.

Example Beers name manf Pete’s Ale isa Ales color

ER Design Principle #1: Model your domain faithfully Purchase Product Person President Country Person for instructor teaching course: is it many-one or one-one or many-many? depending on which assumptions we have about the domain Teaches Instructor Course

Principle #2: Avoid redundancy Don’t say the same thing in two different ways. Redundancy wastes space and (more importantly) encourages inconsistency (i.e., update anomaly) The two instances of the same fact may become inconsistent if we change one and forget to change the other, related version. garbage

Good name name addr ManufBy Beers Manufacturers This design gives the address of each manufacturer exactly once.

Bad name name addr ManufBy Beers Manufacturers manf This design states the manufacturer of a beer twice: as an attribute and as a related entity.

We could use a set of attributes instead of an entity set Q: Can we remove the Manufactures entity set? name manf manfAddr Beers This design repeats the manufacturer’s address once for each beer; loses the address if there are temporarily no beers for a manufacturer.

Good name name addr ManfBy Beers Manufacturers Manufacturers deserves to be an entity set because of the nonkey attribute addr. Beers deserves to be an entity set because it is the “many” of the many-one relationship ManfBy.

Principle #3: Don’t overuse entity sets An entity set should satisfy at least one of the following conditions: It is more than the name of something; it has at least one non-key attribute. or It is the “many” in a many-one or many-many relationship.

Good name manufacturer Beers No need to make the manufacturer an entity set, because we only remember its name.

Bad name name ManfBy Beers Manufacturer Since the manufacturer is nothing but a name, and is not at the “many” end of any relationship, it should not be an entity set.

Principle #4: Don’t Overuse Weak Entity Sets Beginning database designers often make most entity sets weak, supported by all other entity sets to which they are linked. Instead, we create unique IDs for entity sets. Social-security numbers, driver’s license numbers, automobile VINs, … Only use weak entity sets when necessary. Example: unique player numbers across all football teams in the world.

Exercise 4.2.6 Births Doctors Nurses Babies Mothers Use arrows to represent the following conditions: Every baby is a result of a unique birth, and every birth is of a unique baby. In addition to (a), every baby has a unique mother. In addition to (a) and (b), for every birth there is a unique doctor. In each case, what design flaws do you see?