Tallahassee, Florida, 2015 COP4710 Database Systems E-R Model Fall 2015.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Conceptual Design using the Entity-Relationship Model
Constraints in Entity-Relationship Models Zaki Malik September 18, 2008.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
1 541: Database Systems S. Muthu Muthukrishnan. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.)  What are the entities.
The Entity-Relationship (ER) Model
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Information Systems Chapter 4 Relational Databases Modelling.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
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
Design Principles: Faithfulness
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.) –What are the entities.
DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design II (week 3)
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Modeling Your Data Chapter 2. Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information.
A four-way Relationship
The Entity-Relationship (ER) Model CS541 Computer Science Department Rutgers University.
1 Data Modeling Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
1 Lecture 3: Database Modeling (continued) April 5, 2002.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
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.
Multiplicity in E/R Diagrams
1 The Entity-Relationship Model Chapter 2. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
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.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design : (ER Model is used at this stage.)  What are the entities.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
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.
ICS 321 Spring 2011 High Level Database Models Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 2/7/20111Lipyeow.
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
ER Data Models Ctd. CSET 3300.
Christoph F. Eick: Designing E/R Diagrams 1 The Entity-Relationship Model Chapter 3+4.
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.
© 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
1 Conceptual Design using the Entity- Relationship Model.
Databases 1 Fifth lecture. Entity-Relationship Model Diagrams Class hierarchies Weak entity sets From E/R diagrams to Relations 2.
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
CSC 411/511: DBMS Design 1 1 Dr. Nan WangCSC411_L2_ER Model 1 The Entity-Relationship Model (Chapter 2)
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
Entity-Relationship Model E/R Diagrams Converting E/R Diagrams to Relations.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
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 Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
COP Introduction to Database Structures
Introduction to Database Systems, CS420
COP4710 Database Systems E-R Model.
Constraints in Entity-Relationship Models
CPSC-310 Database Systems
name category name price makes Company Product stockprice buys employs
The Entity-Relationship Model
CS4433 Database Systems E-R Model.
CS 405G: Introduction to Database Systems
Presentation transcript:

Tallahassee, Florida, 2015 COP4710 Database Systems E-R Model Fall 2015

Why should we study this? 1

Key Steps in Building DB Applications Step 0: pick an application domain – We will talk about this later Step 1: conceptual design – Discuss with your team mate what to model in the application domain – Need a modeling language to express what you want ER model is the most popular such language – Output: an ER diagram of the application domain 2

Key Steps in Building DB Applications Step 2: pick a type of DBMS’s – Relational DBMS is most popular and is our focus Step 3: translate ER design to a relational schema – Use a set of rules to translate from ER to relational schema – Use a set of schema refinement rules to transform the above relational schema into a good relational schema At this point – You have a good relational schema on paper 3

Key Steps in Building DB Applications Subsequent steps include 4.Implement your relational DBMS using a "database programming language" called SQL 5.Ordinary users cannot interact with the database directly and the database also cannot do everything you want, hence write your application program in C++, Java, PHP, etc. to handle the interaction and take care of things that the database cannot do So, the first thing we should start with is to learn ER model... 4

ER Model A language to specify – what information a database must hold – what are the relationships among components of that information What we will cover – basic stuff; constraints; weak entity sets; design principles Proposed by Peter Chen in 1976 – "The Entity-Relationship Model --- Toward a Unified View of Data". in ACM transactions on database systems (TODS) One of the most cited CS papers 5

Entities and Attributes Entities – Real-world objects distinguishable from other objects – Described using a set of attributes Attributes – each has an atomic domain: string, integers, reals, etc. Entity set: a collection of similar entities 6

(Binary) Relationship (Binary) Relationship A mathematical definition: – if A, B are sets, then a relation R is a subset of A x B (Cartesian product) A={1,2,3}, B={a, b, c, d}, R = {(1,a), (1,c), (3,b)} makes is a subset of Product x Company: a b c d A= B= makes Company Product

Multiplicity of E/R Relationships 8 one-one: many-one many-many abcabc abcdabcd abcdabcd

Example An employee can work in many departments; a department can have many employees In contrast, each department has at most one manager 9 Manages dname budgetdid Departments Works_In lot name ssn Employees

Multiway Relationships 10 How do we model a purchase relationship between buyers, products and stores? Purchase Product Person Store Can still be modeled as a mathematical set (how ?)

Arrows in Multiway Relationships 11 Q: what does the arrow mean ? Contract Studios Stars Movies

Roles in Relationships 12 What if we need an entity set twice in one relationship? subor- dinate super- visor Reports_To since Works_In dname budget did Departments lot name Employees ssn

Attributes on Relationships 13 Purchase Product Person Store date

Converting Multiway Relationships to Binary 14 Purchase Person Store Product StoreOf ProductOf BuyerOf date

Relationships: Summary Modeled as a mathematical set Binary and multiway relationships Converting a multiway one into many binary ones Constraints on the degree of the relationship – many-one, one-one, many-many Attributes of relationships 15

Subclasses 16

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 Assume subclasses form a tree – No multiple inheritance Isa triangles indicate the subclass relationship – Point to the superclass 17

Example 18 Beers Ales isa namemanf color

ER vs. Object Oriented Subclasses In the object-oriented world, objects are in one class only – Subclasses inherit properties from super-classes In contrast, E/R entities have components in all subclasses to which they belong – Matters when we convert to relations 19 Beers Ales isa namemanf color Pete’s Ale

Constraints Constraint: an assertion about the database that must be true at all times – Part of the database schema – Very important in database design Finding constraints is part of the modeling process – 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 – General constraints: all others (at most 60 students enroll in the class COP4710) 20

Why Constraints Give more semantics to the data – Help us better understand it Allow us to refer to entities (e.g., using keys) Enable efficient storage, data lookup, etc. 21 Michael Jordan, Chicago Bulls Michael Jordan, UC Berkeley

Keys in E/R Diagrams 22 address namessn Person Product namecategoryprice No formal way to specify multiple keys in E/R diagrams Underline:

More about Keys Every entity set must have a key – why? A key can consist of more than one attribute There can be more than one key for an entity set – Among all candidate keys, one key will be designated as primary key 23

Referential Integrity Constraint Ref. int. constraint: exactly one value exists in a given role – An attribute has a non-null, single value However, we more commonly use such constraints to refer to relationships – In some formalisms we may refer to other object but get garbage instead e.g. a dangling pointer in C/C++ – The Referential integrity constraint on relationships explicitly requires a reference to exist 24

Referential Integrity Constraint 25 CompanyProduct makes CompanyProduct makes

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 26 lot name age pname Dependents Employees ssn Policy cost )

Weak Entity Sets The 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 owner entity sets: one owner, many weak entities 27 lot name age pname Dependents Employees ssn Policy cost )

Design Principles: Be Faithful 28 Purchase Product Person President PersonCountry Teaches CourseInstructor

Avoiding Redundancy Redundancy occurs when we say the same thing in two different ways Redundancy wastes space and (more importantly) encourages inconsistency – The two instances of the same fact may become inconsistent if we change one and forget to change the other, related version 29 BeersManfs ManfBy name manf addr This design states the manufacturer of a beer twice: as an attribute and as a related entity

Another Possible Design 30 Beers name This design repeats the manufacturer’s address once for each beer; loses the address if there are temporarily no beers for a manufacturer manfmanfAddr

A Good Design 31 BeersManfs ManfBy name This design gives the address of each manufacturer exactly once nameaddr

Entity Sets 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 32 BeersManfs ManfBy name addr

Which One is Good? 33 Beers namemanf BeersManfs ManfBy name

Don’t Overuse Weak Entity Sets Database designers often doubt that anything could be a key by itself – They make all entity sets weak, supported by all other entity sets to which they are linked In reality, we usually create unique ID’s for entity sets. – Examples include social-security numbers, automobile VIN’s etc When Do We Need Weak Entity Sets? – The usual reason is that there is no global authority capable of creating unique ID’s Example: it is unlikely that there could be an agreement to assign unique player numbers across all football teams in the world 34

How to Identify Them by #10 35

ER Review Basic stuff – entity, attribute, entity set – relation: binary, multi-way, converting from multi-way – relationship roles, attributes on relationships – subclasses (is-a) Constraints – on relations many-one, one-one, many-many – keys, single-valued, ref integrity, domain & general constraints Weak Entity Set Design principles 36