Multiplicity in E/R Diagrams

Slides:



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

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.
Constraints in Entity-Relationship Models Zaki Malik September 18, 2008.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Chapter 31 Chapter 3 Data Modeling Using the Entity-Relationship Model.
Information Systems Chapter 4 Relational Databases Modelling.
Lecture 6: Design Constraints and Functional Dependencies January 21st, 2004.
1 Relational Model and Translating ER into Relational.
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.
Lecture #2 October 5 th, 2000 Conceptual Modeling Administration: –HW1 available –Details on projects –Exam date –XML comment.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Functional Dependencies Definition: If two tuples agree on the attributes A, A, … A 12n then they must also agree on the attributes B, B, … B 12m Formally:
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.
Lecture 9: Conceptual Database Design January 27 th, 2003.
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
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.
Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Relationships: like in ODL except - not associated with.
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 08: E/R Diagrams and Functional Dependencies.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
CS 564 Database Management Systems: Design and Implementation
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.
Lecture 2: E/R Diagrams and the Relational Model Wednesday, April 3 rd, 2002.
Home Work. Design Principles and Weak Entity Sets.
Lecture 3 Book Chapter 3 (part 2 ) From ER to Relational.
Lecture 3: Conceptual Database Design and Schema Design April 12 th, 2004.
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
1 Lecture 08: E/R Diagrams and Functional Dependencies Friday, January 21, 2005.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
COMP 430 Intro. to Database Systems ER Design Considerations Slides use ideas from Chris Ré.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Example COMPANY Database
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
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.
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.
COP4710 Database Systems E-R Model.
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
Lecture 4 Lecture 4: The E/R Model.
02: ER Model Ch 4.1 – 4.4 Optionally, begin with Ch 2.1.
Conceptual Database Design
Constraints in Entity-Relationship Models
Cse 344 May 14th – Entities.
From E/R Diagrams to Relational Schema
Lecture 4: Database Modeling (continued)
Cse 344 May 11th – Entities.
Lecture 2: Database Modeling (end) The Relational Data Model
Lecture 06 Data Modeling: E/R Diagrams
name category name price makes Company Product stockprice buys employs
Functional Dependencies
Lecture 9: The E/R Model II
Functional Dependencies
Lecture 10: The E/R Model III
Lecture 5: The Relational Data Model
Functional Dependencies
CS4433 Database Systems E-R Model.
Presentation transcript:

Multiplicity in E/R Diagrams Rule: the head of the arrow can have at most one value, given values to the other entities in the relationship. Product Purchase Store Person

Design Principles What’s wrong? Purchase Product Person President Country Person Moral: be faithful!

What’s Wrong? date Product Purchase Store Moral: don’t talk too much. personAddr person

What’s Wrong? date Dates Product Purchase Store Moral: don’t complicate life more than it already is. Person

Do we really need 3-way relationships? ProductOf Product Purchase StoreOf Store Moral: Find a nice way to say things. BuyerOf Person

Modeling Subclasses The world is not flat! Some objects in a class may have properties not shared by other members: Products Software products Educational products So --- we define subclasses (in ODL and in E/R).

Subclasses in ODL Interface SoftwareProduct: Product{ attribute Set<string> platform; attribute Set<integer> requiredMemory; } Interface EducationalProduct: Product{ attribute Struct Interval {integer begin, integer end} ageGroup; attribute string topic The two classes also inherit all the properties of Product.

Multiple Inheritance Product Platforms required memory ageGroup topic Educational Product Software Product Educ-software Product Educational-method

How do we resolve conflicts? Rating (ATA) Product Platforms required memory ageGroup topic Educational Product Software Product Rating (ASA) Educ-software Product Educational-method Rating?

Subclasses in E/R Diagrams name category price Product isa isa Software Product Educational Product platforms Age Group

In ODL: Every object belongs to a single class In E/R: An entity may be spread out in multiple sets. name category price Product isa isa Software Product Educational Product platforms Age Group

Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely identifies a person. Single-value constraints: a person can have only one father. Referential integrity constraints: if you work for a company, it must exist in the database. Domain constraints: peoples’ ages are between 0 and 150. Why are these constraints useful in the implementation?

Keys A set of attributes that uniquely identify an object or entity: Person: social security number name name + address name + address + age Perfect keys are often hard to find, so organizations usually invent something. An object may have multiple keys: employee number, social-security number

Keys in ODL Interface Person (key ssn) { properties… } Defining multiple keys: (key ssn employeID (name address age))

Keys in E/R Diagrams name category price Product No formal way to specify multiple keys in E/R diagrams Person name ssn address

Single Value Constraints An entity (or object) may have at most one value for a given attribute or relationship. Person: name, social-security number Company: stock price How do we do this in ODL? In E/R, every attribute has at most one value. Arrows tell us about multiplicity of relations. If we have a single-valued constraint, we can either: 1. Require that the value exist (see referential integrity shortly) 2. Allow null values.

Referential Integrity Constraints A relationship has one value and the value must exist. Example: Product madeBy Company: company must exist. How do we enforce referential integrity constraints? (otherwise, we get dangling pointers) - forbid to delete a reference object, or - delete the objects that reference an object we’re deleting. In E/R diagrams: makes Product Company

Weak Entity Sets Entity sets are weak when their key attributes come from other classes to which they are related. This happens if: - part-of hierarchies - splitting n-ary relations to binary. affiliation Team University sport number name