CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture.

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.
Overview of Database Systems CPSC 315 – Programming Studio Spring 2009 Team Project 1, Lecture 1.
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
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
1 Convert E/R to Relation May 18, Entity Set -> Relation Relation: Beers(name, manf) Beers name manf.
Databases : Relational Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman distributes.
Entity-Relationship Model
Chapter 4 Notes. Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Design Principles: Faithfulness
Entity-Relationship Model. The process of designing a database begins with: –an analysis of what information the database must hold, and –the relationships.
Design Principles: Faithfulness
Database Design and the E-R Model Chapter 7 [1 of 2]
1 Entity-Relationship Model Slides by Jeffrey Ullman Modified by J. Welch to replace beers with candies.
1 Announcement Recitation time  Before midterm: 6-7pm, by Earl Wagner  After midterm: 5-6pm, by Yi Qiao Newsgroup safe to subscribe  Will not cause.
Entity-Relationship Model
A four-way Relationship
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
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.
CS411 Database Systems Kazuhiro Minami
What is a Database Management System? 1. Manages very large amounts of data. 2. Supports efficient access to very large amounts of data. 3. Supports concurrent.
CSET 3300 Databases & ER Data Models. Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system.
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.
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.
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
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.
CS422 Principles of Database Systems Convert ER Design to Relations Chengyu Sun California State University, Los Angeles.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles.
A short revision on entity- relationship modelling.
A short review on entity- relationship modelling.
1 Database Design: DBS CB, 2 nd Edition Logical Database Model: Entity Relationship Model & Object Description Language & Unified Modeling Language Ch.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes.
Database Design and Programming Jan Baumbach Adopted from previous slides of Peter Schneider-Kamp.
CS422 Principles of Database Systems Entity-Relationship Model
Introduction to Database Systems, CS420
Session 2 Welcome: To the fourth learning sequence
Entity-Relationship Model
COP4710 Database Systems E-R Model.
Constraints in Entity-Relationship Models
CPSC-310 Database Systems
The Entity-Relationship Model
Instructor: Zhe He Department of Computer Science
CPSC-310 Database Systems
CPSC-310 Database Systems
CPSC-310 Database Systems
Overview of Database Systems
Session 2 Welcome: The fifth learning sequence
Overview of Database Systems
Chengyu Sun California State University, Los Angeles
The Relational Data Model
CS4433 Database Systems E-R Model.
CPSC-608 Database Systems
Overview of Database Systems
CS 405G: Introduction to Database Systems
Presentation transcript:

CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes at

Data Modeling Problem in Real WorldTables in RDBM ? Some Restaurant Terminal ID: NC2HHRY Merchant ID: VISA ***********1234 srv:1 SALE Batch: Date: JUN 17, 06 Time: 18:44 inv: AUTH:00559B Base: $36.70 Tip: Total: Chengyu Sun

Entity-Relationship (ER) Model Sort of an object-oriented approach Support subclasses A graphical representation of the design – ER Diagram Easily converted to relational model ProblemTablesER Model

ER Diagram Drinkers addrname Beers manfname Bars name license addr Sells LikesFrequents Entity Set Attribute Relationship

Entity Set and Attributes Entity Set is similar to class in an OO language Attributes are the properties of an entity set Similar to the class variables in an OO language Must have simple values like numbers or strings – cannot be collection or composite type

Instances of An Entity Set Entity – object in an OO language Beers manfname (Bud, Anheuser-Busch) (Miller, Miller Brewing) (Bud Lite, Anheuser-Busch) Bars name license addr (Joe’s Bar, 113 Main St, Full) (Sue’s Bar, 20 East St, Beer)

Relationship Instances of a relationship?? Beers manfname Bars name license addr Sells

Many-to-Many Relationship An entity of either set can be connected to many entities of the other set

Many-to-One Relationship The relationship Favorite between Drinkers and Beers

Many-to-One in ER Diagram An arrow is used to indicate the “one” side There could be multiple relationships between two entity sets DrinkersBeers Likes Favorite

One-to-One Relationship The relationship Best-seller between Manufactures and Beers

One-to-One in ER Diagram Arrows on both ends ManufacturesBeers Best-seller Brew ??

Multiway Relationship Sometimes we need a relationship that connects more than two entity sets. Suppose drinkers will only drink certain beers at certain bars.

A 3-Way Relationship Bars Beers Drinkers name addr manf nameaddr license Preferences

Instances of the Preferences Relationship BarDrinkerBeer Joe’s BarAnnMiller Sue’s BarAnnBud Sue’s BarAnnPete’s Ale Joe’s BarBobBud Joe’s BarBobMiller Joe’s BarCalMiller Sue’s BarCalBud Lite

“Arrows” in Multi-way Relationships What does an arrow mean in a multi-way relationship?? Can we add any arrows in the Preferences relationship?? Bars Beers Drinkers Preferences ??

Attributes of Relationships Sometimes it’s useful to attach an attribute to a relationship. BarsBeers Sells price Can we do without relationship attributes??

Roles An entity set may appear in the same relationship more than once. Label the edges with names called Roles Drinkers Married husbandwife

A Different Perspective Husband (Drinkers) Married Wife (Drinkers) HusbandWife BobAnn JoeSue ……

Subclasses Subclass Special case More properties No multiple inheritance Represented by the isa triangle Beers Ales isa namemanf color

Keys A key is an attribute or a set of attributes that uniquely identify an entity in an entity set.

Keys in ER Diagram Student First_NameLast_NameCIN QuarterNameSection Courses ??

Rules about Keys Each entity set must have a key If there are multiple keys, choose one of them as the primary key Super class must have all the key attributes

Weak Entity Set Entity set E is said to be weak if in order to identify entities of E uniquely, we need to follow one or more many- one relationships from E and include the key of the related entities from the connected entity sets.

Weak Entity Set Example What’s the key for Players?? PlayersTeams Plays-on name number

Representing Weak Entity Sets The key of a weak entity set consists of its own key attributes and the key attributes of the supporting set PlayersTeams Plays-on name number

Referential Integrity A stronger many-to-one or one-to-one relationship many-to-oneone-to-one

Representing Referential Integrity Manufactures Beers Best-seller

Design Principles Faithfulness Avoid redundancy Don’t use an entity set when an attribute would do Limit the use of weak entity set

Avoid Redundancy Redundancy wastes space, and more importantly, encourages inconsistency.

Example: Good BeersManfs ManfBy name addr

Example: Bad BeersManfs ManfBy name manf addr

Example: Bad Beers namemanfmanfAddr

Entity Set vs. Attributes 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.

Example: Good BeersManfs ManfBy name addr

Example: Good Beers namemanf

Example: Bad BeersManfs ManfBy name

Don’t Overuse Weak Entity Set We can usually create unique IDs for entity sets.

Some Common Problems Missing arrows Not identifying keys Two entity sets are connected without a relationship Attributes are not of simple type Misuse of multiway relationships

Example 1: Receipt Revisited Some Restaurant Terminal ID: NC2HHRY Merchant ID: VISA ***********1234 srv:1 SALE Batch: Date: JUN 17, 06 Time: 18:44 inv: AUTH:00559B Base: $36.70 Tip: Total: Chengyu Sun

Example 2: Product Hierarchy All CPUMouseHard Drive IntelAMDOpticalWirelessIDESCSI SATA

Example 3: Price That Changes Products namepricedescription What if we want to model price that changes?? Price of Intel P3 $ time