Entity-Relationship Model

Slides:



Advertisements
Similar presentations
High-Level Database Models Spring 2011 Instructor: Hassan Khosravi.
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
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 6 A First Course in Database Systems.
Functional Dependencies - Example
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
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.
Entity-Relationship Model Lecture 2. Database Modeling and Implementation Process Ideas ER DesignRelational Schema Relational DBMS Implementation.
The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes rows: tuples Complex file.
A four-way Relationship
Entity-Relationship Data Model Alex Ostrovsky. Presentation Overview ► Short historical overview ► Elements of E-R Model ► Basic organization & relationships.
The Entity-Relationship Data Model
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
1 The Entity-Relationship Data Model Chapter 2 (Database Design)
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.
Database Systems The Entity-Relationship Model
Entity-Relationship Data Model N. Harika Lecturer(csc)
Data Warehouse Fundamentals Rabie A. Ramadan, PhD 5.
CSET 3300 Databases & ER Data Models. Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system.
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.
Database Management Systems Chapter 2 The Entity-Relationship Data Model Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
1 Entity-Relationship Model Chapter 2 Copyright : Jeff Ullman + Hank Korth.
Conversion E/R to Relational CIS 4301 Lecture Notes Lecture 6 - 1/31/2006.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Entity-Relationship Model
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 2 Introduction to a First Course in Database Systems.
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 diagram Name: Quian Crosby Form:6AQ Subject: Information Technology Teacher: Ms. D. Anderson.
Entity-Relationship Model E/R Diagrams Converting E/R Diagrams to Relations.
Data Modeling and the Entity-Relationship Model CS 475 Lecture Notes.
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,
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.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
A short revision on entity- relationship modelling.
Modeling: Entity-Relationship Diagrams
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 Database Modeling (Semantic data modeling) ER Data Model –A high-level conceptual data model –Proposed by P. Chen (1976) –Widely used in DB design process.
The Entity-Relationship Diagram for Data Modeling
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.
ER Diagrams and Relational Model CS 174a (Winter 2015)
Hele-Mai Haav: CSC210-Spring*01 CSC230-Spring*03 Database Design.
Session 2 Welcome: To the fourth learning sequence
Entity-Relationship Model
Entity-Relationship Model
CPSC-310 Database Systems
The Entity-Relationship Model
CPSC-608 Database Systems
Instructor: Zhe He Department of Computer Science
CPSC-310 Database Systems
Instructor: Zhe He Department of Computer Science
Presentation transcript:

Entity-Relationship Model

Database Modeling Ideas E/R design Relational schema Relational DBMS The process of designing a database begins with: an analysis of what information the database must hold, and the relationships among components of that information. The structure of the database, called the database schema is specified in a suitable notation for expressing designs. We will use the Entity-Relationship (E/R) model, which is graphical in the nature. Ideas E/R design Relational schema Relational DBMS A mechanical process Abstract design Concrete design

Elements of the E/R Model Entities are like the objects in OO programming. Entity sets are like the classes. However, E/R is a static model, so there are no methods associated with the entities. Movies Attributes are similar to the attributes in OO programming. However, they are atomic, i.e. only numbers and strings are allowed. Title Relationships are connections among two or more entity sets. Stars-in

Example Movies Stars-In Stars Owns Studios title year name address length filmType Owns Studios address

Visualizing E/R Relationships It is often helpful (for us) to represent E/R relationships by a table or relation, each row representing a list (it can be pair) of entities participating in the relationship. For instance the Stars-in relationship could be visualized as a table: Movies | Stars Basic Instinct | Sharon Stone. Total Recall | Arnold Schwarzeneger. Total Recall | Sharon Stone. This table is called the relationship set for the relationship. The members of the relationship set are the rows of the table.

Multiplicity of Relationships A relationship R is many-one from one entity set E to another entity set F, if any member of E can be associated to at most one member of F. We also equivalently say that R is one-many from F to E. Any member of F can be associated with many members of E. Movies Studios Owns Arrows can be used to indicate the multiplicity of a relationship in an E/R diagram. An arrow means “at most one.” It does not guarantee the existence of an entity of the set pointed to. So, if a relationship is many-one from entity set E to F, we place an arrow entering F.

Multiplicity (Cont.) Studios Presidents Runs Movies Stars Stars-In If a relationship R is both many-one from E to F and many-one from F to E, then we say that R is one-one represented by arrows pointing to both E and F. Studios Presidents Runs If a relationship R is neither many-one from E to F or from F to E, then we say R is many-many. Movies Stars Stars-In

Multiway Relationships The E/R model makes it convenient to define relationships involving more than two entity sets. A multiway relationship in an E/R diagram is represented by lines from the relationship diamond to each of the involved entity sets. Motivating Example. Take the previous organization: Movies Stars-In Stars Owns Studios What’s the problem with this design?

Relating studios, movies and stars Suppose that we want to know how studios are related to the stars. I.e. Which stars a studio is (or was) paying for a specific movie. As long as a movie is produced by a single studio the previous organization works very well. Why? Because we can relate a studio s through a specific movie m with the stars sti forming valid triples: (s, m, st1), (s, m, st2),…, (s, m, stk) Suppose now that movies can be produced (and owned) by not just a single studio but, by some studios. (The line connecting studios is without arrow in such a case) Now if we try to create the above triples they can be not valid.

Why the triples can be not valid? Suppose a studio s1 is paying a star st1 for the movie m and a studio s2 is paying st2 for the same movie m. Then we will have the following triples: (s1, m, st1) (s1, m, st2) (s2, m, st1) (s2, m, st2) The second and the third triples are not valid. If we consider the collection of all the valid triples, it is nothing else but a three way relationship between Studios, Movies and Stars

Solution: Three-way relationship Stars Movies Contracts Studios Formally: The relationship Contracts involves a studio, a star, and a movie. This relationship says that a studio has contracted a particular star in a particular movie. In multiway relationships, an arrow pointing to an entity set E means: If we select one entity from each of the other entity sets in the relationship, these entities are related to at most one entity in E.

Roles in a relationship An entity set can appear two or more times in a relationship. If so, we draw as many lines from the relationship to the entity set as the entity set appears in the relationship. Each line to the entity set represents a different role. Original Movies Sequel-of Sequel We assume that a movie may have many sequels, but for each sequel there is only one original movie.

Another Example Relationship Set Husband Wife Bob Ann Joe Sue … … … … Drinkers Married husband wife

Another Example Relationship Set Buddy1 Buddy2 Bob Ann Joe Sue Ann Bob Joe Moe … … Buddies 1 2 Drinkers

Attributes on Relationships Sometimes, it is convenient to associate attributes with a relationship, rather than with any one of the entity sets that the relationship connects. Consider the 3-way Contracts relationships between a star and a studio for a movie. We might wish to record the salary associated with this contract. We cannot associate it with the star; a star might get different salaries for different movies. It does not make sense to associate the salary with a studio or with a movie. However, it is appropriate to associate a salary with the (star, movie, studio) triple in the relationship set for the Contracts relationship.

A relationship with an attribute Movies title year length filmType Contracts salary Stars name address Studios

“Bars-Beer-Drinkers” (BBD) Example Bars sell some beers. Drinkers like some beers. Drinkers frequent some bars. What would be the E/R diagram?

“Bars-Beer-Drinkers” (BBD) Example name license addr Note: license = beer, full, none Beers manf name Sells Bars sell some beers. Frequents Drinkers frequent some bars. Likes Drinkers like some beers. Drinkers addr name Why we need it?

BBD relation sets For the relationship Sells, we might have a relationship set like: Bar Beer Joe’s Bar Bud Joe’s Bar Miller Sue’s Bar Bud Sue’s Bar Pete’s Ale Sue’s Bar Bud Lite

BBD Multiway Relationship Suppose that drinkers will only drink certain beers at certain bars. Our three binary relationships Likes, Sells, and Frequents do not allow us to make this distinction. But a 3-way relationship would.

name addr name manf Bars Beers license Preferences Drinkers name addr

A Typical Relationship Set Bar Drinker Beer Joe’s Bar Ann Miller Sue’s Bar Ann Bud Sue’s Bar Ann Pete’s Ale Joe’s Bar Bob Bud Joe’s Bar Bob Miller Joe’s Bar Cal Miller Sue’s Bar Cal Bud Lite

Multiple Relationships Between Two Entity Sets Likes Drinkers Beers Favorite

“Exactly one” Multiplicity Best- seller Manfs Beers Some beers are not the best-seller of any manufacturer, so a rounded arrow to Manfs would be inappropriate. But a manufacturer has to have a best-seller (we assume they are beer manufacturers).