1 The Entity-Relationship Data Model Chapter 2 (Database Design)

Slides:



Advertisements
Similar presentations
High-Level Database Models Spring 2011 Instructor: Hassan Khosravi.
Advertisements

Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Functional Dependencies - Example
Text-Book Chapters (7 and 8) Entity-Relationship Model
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
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #2 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
Entity-Relationship Model Lecture 2. Database Modeling and Implementation Process Ideas ER DesignRelational Schema Relational DBMS Implementation.
Additional ODL Concepts OO Model to Relational Model Object-Relational Design OO vs OR.
Movies length titleyearfilmType Voices isa Cartoons isa MurderMystery weapon toStar Our Movie Example.
Entity-Relationship Model
A four-way Relationship
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #2 Matthew P. Johnson Stern School of Business, NYU Spring, 2005.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #2 M.P. Johnson Stern School of Business, NYU Spring, 2008.
Entity-Relationship Data Model Alex Ostrovsky. Presentation Overview ► Short historical overview ► Elements of E-R Model ► Basic organization & relationships.
From E/R Diagrams to Relations. The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes.
The Entity-Relationship Data Model
Other Data Models. Text New edition (DBS the complete book): Chapter 4 Old edition (First course in DBS): –Section 2.1 –Section –Section 2.4.1,
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Murali Mani The Entity- Relationship Model. Murali Mani Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
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.
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
Data Modeling Using the Entity-Relationship Model
Data Modeling Using the Entity-Relationship Model
the Entity-Relationship Model
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Database Systems The Entity-Relationship Model
Entity-Relationship Data Model N. Harika Lecturer(csc)
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
Database Systems Lecture # 7 8 th Feb, Conceptual and Logical Design Person buys Product name pricenamessn Conceptual Model: Relational Model: (plus.
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.
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.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
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
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.
Databases Illuminated Chapter 3 The Entity Relationship Model.
Home Work. Design Principles and Weak Entity Sets.
CS 157B Database Systems Dr. T Y Lin. Updates 1.Red color denotes updated data (ppt) 2.Class participation will be part of “extra” credits to to “quiz.
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.
Data Modeling and the Entity-Relationship Model CS 475 Lecture Notes.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
© D. Wong Ch. 3 (part 1)  Relational Model basics  From E/R diagram to Relations.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
Modeling: Entity-Relationship Diagrams
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 System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Entity Relationship (E-R) Model
Hele-Mai Haav: CSC210-Spring*01 CSC230-Spring*03 Database Design.
COP Introduction to Database Structures
Session 2 Welcome: To the fourth learning sequence
Chap 3. High-Level Database Models
COP4710 Database Systems E-R Model.
Entity-Relationship Model
Chapter 7: Entity-Relationship Model
The Entity-Relationship Model
Module 8 – Database Design Using the E-R Model
Database Modeling using Entity Relationship Model (E-R Model)
Chapter 7: Entity-Relationship Model
Chapter 3: Multivalued Dependencies
Chapter 6b: Database Design Using the E-R Model
Presentation transcript:

1 The Entity-Relationship Data Model Chapter 2 (Database Design)

2 Steps in designing a database Analysis: –What information needs to be stored? –What are the relationships between different components of the stored information? –What is the suitable database structure (or schema)? Design the database structure (using a database design language or notation suitable for expressing design) Implementation in DBMS once committed to the design

3 Steps in picture Ideas/ Problems Database Structure Database Design DBMS Analysis Design Implementation E/R diagram Relational model ODL, ORDL

4 Entity-Relationship Model Traditional & popular Graphical representation Three types of elements –Entity set (rectangle) –Attributes (oval) –Relationship (diamond)

5 Entity Set Collection of similar objects Similar to a class in the sense of OOP Entity vs. entity set Example: Database about movies, their stars, the studio that producing them, and other aspects of movies. –A movie is an entity –Collection of movies is an entity set –Other entities in this db: ?

6 Attributes Entity set has associated attributes Each attribute represents a property of entities belonging to the entity set Example: –The entity set Movies has the associated attribute Title  each movie has a title Assumption: attributes are atomic values  address with two components (e.g. number, street) cannot be used as an attribute of an entity set

7 Relationship Connections among entity sets Represent a relationship between entity sets –If E and F are two entity sets and R connect the two, then R is a binary relation between E and F, mathematically we write R  E x F. Example: Movies and Stars are two entity sets and a connection Stars-In between the two  the intention: m is related to s means that star s starts in movie m.

8 E/R Diagram A graph representing entity sets, attributes, and relationships. –Entity set (rectangle) –Attributes (oval) –Relationship (diamond)

9 Movies Stars_in Owns title year length film type Studios name address Stars nameaddress

10 A reading of the previous diagram Three entity sets: –Movies [title,year,length,film type] –Stars[name,address] –Studio[name,address] Two relationships –(m:n) – Stars_in(Movies,Stars) –(m:1) – Owns(Movies,Studios)

11 Instance of an E/R diagram Concrete data of a database, whose structure is represented by a E/R diagram, creates a database instance In an instance –For each entity set: a particular finite set of entities, each has values for each attribute –For each relationship connecting the entities E 1, E 2,…,E n a set of tuples (e 1,e 2,…,e n ) each e i is an entity in the entity set of E i –Where are the attributes?

12 Example A possible database instance of the previous E/R diagram (Note: The info is inserted for illustrative purpose only – it needs not be true in real life ) Basic instinct Drama Total recall Mystery Sharon Stonea1 Arnold Schwarzeneggera2 Basic instinctSharon Stone Total recallSharon Stone Total recallArnold Schwarzenegger MoviesStars Stars_in Universal Studio Dream World Studio Basic instinctUniversal Studio Total recallUniversal Studio Owns

13 A little of math before continuing E, F are two sets –R  E x F: R is a binary relation from E to F R is a set whose member is a pair (e,f) where e is a member of E and f is a member of F R could be empty, could be equal the Cartesian product of E and F –R is many to one relation if for each e in E there is at most one element (e,f) in R –R is one to one: many to one from E to F and many to one from F to E –R is many to many: not many to one from E to F and not many to one from F to E

14 many-one one-many one-one many-many

15 Multiplicity of Binary E/R Relationship R is a binary relation from E to F –One to many –One to one –Many to many Representing using arrow in the connection between entity set and relationship –Arrow entering an entity set represents the ‘one’ in the above description

16 Movies Stars_in Owns title year length film type Studios name address Stars nameaddress many-many many-one

17 Multiway Relationships Easy to handle in E/R diagram: connect all related entity sets with the relationship (Note: weakening the relationship (movie,studio) ) Movies Contracts Studios Stars Contracts relationship: (studio,star,movie)

18 Roles in Relationship An entity set can appear more than one times in a relationship E/R diagram: labeling the arc connecting the entity set and the relationship Movies Sequel_of Original Sequel

19 Another example Movies Contracts Studios Stars Producing studio Studio of star

20 Attributes on Relationships How to record the salary of a star in a contract? Movies Contracts Studios Stars salary ? ? ?

21 Attributes on Relationships How to record the salary of a star in a contract? Ans: attribute of Contracts! Movies Contracts Studios Stars salary

22 Movies title year length film type Studios name address Stars nameaddress Contracts salary The complete diagram of the Contracts relationship. Can we live without *? * *

23 Movies title year length film type Studios name address Stars nameaddress Contracts salary Salaries

24 Eliminating Attributes on Relationship Introducing a new entity set whose attributes are the attributes attached to the relationship Connecting the new entity set to the relationship, with the arrow pointed to the new entity set

25 Converting Multiway Relationship to Binary Relationship Useful when the language for defining the database structure does not allow multiway relationship. Simple: –Introducing a new entity set representing the relationship –Introducing binary relation between the new entity set and the old ones which are connecting to the relationship

26 Movies Contracts Studios Stars Producing studio Studio of star Movies Studios Stars Contracts Movie_of Star_of Producing studio Studio of star Before After

27 Subclasses in the E/R Model Subclass: common in real-life Represented by the isa relationship isa is one-one relationship In E/R diagram: –draw as a triangle –no arrows into the entity sets

28 Movies titleyearlengthfilm type Cartoons Murder Mysteries isa weapon Voices Stars At home: read example 2.10 and 2.11.

29 Design Principles Faithfulness Avoiding redundancy Simple Select the right relationships Select the right kind of element

30 Faithfulness Entity sets and attributes should reflect reality. Relationships are created only if they make sense given what we know about the domain/application. Example: –Stars_in relationship should be many-many –Teaches relationship between Courses and Instructors? What? How?

31 No Redundancy Motto: Stored everything only one! Space reason (less serious) Consistency (serious) Example: Add an attribute studioName to the entity set Movies while having the relationship Owns between Movies and Studios – consequences: –More space (obvious: studio name stored twice) –Change in ownership of a movie  change in the Owns relationship and the Movies entity set

32 Simplicity Do only whatever is necessary! Example: MoviesOwnsStudios MoviesOwnsStudiosHoldings Represents is better than

33 Right Relationships Should we represent every possible relationships? NO: due to space & redundancy requirements  get only the necessarily one How? Consider the assumptions, identify those that cannot be deduced from or represented by others

34 Movies title year length film type Studios name address Stars nameaddress Contracts Stars_in Owns Assumption: a star can plays in a movie if there is a contract involving the star and the movie  Stars_in is redundant

35 Movies title year length film type Studios name address Stars nameaddress Works_for Stars_in Owns Question: Would it make sense to have a relationship Works_for? Depending …

36 Right Kind of Element Attribute vs. Entity set/Relationship Example: address –in the examples so far: attribute –better as an entity with attributes such as street, number, zip code, state

37 Example: What happens if we replace Studios by its two attributes?  redundancy, losing information (if a studio does not own a movie its address is lost) Movies Stars_in Owns title year length film type Studios name address Stars nameaddress

38 When to use attribute for entity set E? All relationships connecting to E must have an arrow entering E. Attributes for E must collectively identify an entity. If there are more than one attributes then they must not depend on each other. No relationship involves E more than one.

39 Converting from Entity sets to Attributes E R F AB F AB

40 Converting from Entity sets to Attributes E R F AB F R F A B F