Cse 344 May 11th – Entities.

Slides:



Advertisements
Similar presentations
Information Systems Chapter 4 Relational Databases Modelling.
Advertisements

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.
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:
1 Lecture 3: Database Modeling (continued) April 5, 2002.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Multiplicity in E/R Diagrams
Relation Decomposition A, A, … A 12n Given a relation R with attributes Create two relations R1 and R2 with attributes B, B, … B 12m C, C, … C 12l Such.
Functional Dependencies and Relational Schema Design.
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.
Principles of Database Systems With Internet and Java Applications Today’s Topic Chapter 2: Representing Information with Data Models The lecture notes.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
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.
COMP 430 Intro. to Database Systems Entity-Relationship Diagram Basics Slides use ideas from Chris Ré.
1 Lecture 9: Database Design Wednesday, January 25, 2006.
CS422 Principles of Database Systems Entity-Relationship Model
COP Introduction to Database Structures
Lecture 11: Functional Dependencies
Let try to identify the conectivity of these entity relationship
CSIS 115 Database Design and Applications for Business
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.
COP5725 Database Management ER DIAGRAM AND RELATIONAL DATA MODEL
COP4710 Database Systems E-R Model.
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
Chapter 7: Entity-Relationship Model
Database Management Systems (CS 564)
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
Payroll Management System
ER MODEL Lecture 3.
Chapter 2: Intro to Relational Model
Cse 344 March 2nd – E/r diagrams.
Cse 344 May 14th – Entities.
From E/R Diagrams to Relational Schema
Entity – Relationship Model
Lecture 2: Database Modeling (end) The Relational Data Model
Lecture 06 Data Modeling: E/R Diagrams
Cse 344 May 16th – Normalization.
Functional Dependencies and Relational Schema Design
CSE544 Lecture 1: Introduction
Introduction to Database Systems CSE 444 Lectures 8 & 9 Database Design October 12 & 15, 2007.
Lecture 09: Functional Dependencies, Database Design
name category name price makes Company Product stockprice buys employs
Functional Dependencies
CMPT 354: Database System I
Lecture 8: Database Design
Lecture 8: The E/R Model I
Lecture 9: The E/R Model II
Lecture 07: E/R Diagrams and Functional Dependencies
Functional Dependencies
Lecture 10: The E/R Model III
Chengyu Sun California State University, Los Angeles
Lecture 5: The Relational Data Model
CSE544 Data Modeling, Conceptual Design
Functional Dependencies
MIS2502: Data Analytics Relational Data Modeling
Lecture 06: SQL Monday, October 11, 2004.
CS4433 Database Systems E-R Model.
Syllabus Introduction Website Management Systems
Lecture 08: E/R Diagrams and Functional Dependencies
Database Dr. Roueida Mohammed.
Lecture 6: Functional Dependencies
Information Systems in Organizations 2. 1
Chapter 3: Multivalued Dependencies
Lecture 09: Functional Dependencies
Presentation transcript:

Cse 344 May 11th – Entities

Administrivia HW6 Due next Wednesday (May 16) Section 7 slides very helpful HW7 Out Wednesday Due May 23rd HW8 Out May 23rd Due last day of class, Jun 1 Exam Graded and on canvas tonight Back in class or in OH on Monday

Database Design What it is: Starting from scratch, design the database schema: relation, attributes, keys, foreign keys, constraints etc Why it’s hard The database will be in operation for a very long time (years). Updating the schema while in production is very expensive (why?)

Database Design Consider issues such as: Several formalisms exists What entities to model How entities are related What constraints exist in the domain Several formalisms exists We discuss E/R diagrams UML, model-driven architecture Reading: Sec. 4.1-4.6 It is not easy to go from real-world entities to a database schema. One tool to help along the way are E/R diagram. This is a topic that has been studied for decades – in fact there has been an annual conference just on conceptual modeling!

Database Design Process company makes product name price address Conceptual Model: Relational Model: Tables + constraints And also functional dep. Normalization: Eliminates anomalies We have covered physical schema earlier. Now let’s move on to the upper layers in the design process Conceptual Schema Physical storage details Physical Schema

Entity / Relationship Diagrams Entity set = a class An entity = an object Attribute Relationship Product city Three principal element types Relationships are connections among two or more entity sets. Relationships can have attributes too makes

name CEO price address ssn buys makes employs Company Product Person

Keys in E/R Diagrams Every entity set must have a key name price Product

What is a Relation ? A mathematical definition: if A, B are sets, then a relation R is a subset of A × B A={1,2,3}, B={a,b,c,d}, A × B = {(1,a),(1,b), . . ., (3,d)} R = {(1,a), (1,c), (3,b)} makes is a subset of Product × Company: 1 2 3 a b c d A= B= makes Company Product

Multiplicity of E/R Relations one-one: many-one many-many 1 2 3 a b c d 1 2 3 a b c d One-one: student name and ID Many-one: employees and company Many-Many: books and authors 1 2 3 a b c d

name CEO price address ssn buys makes employs Company Product What does this say ? Person

Attributes on Relationships What does this say ? name price name address date Buys Person Product

Multi-way Relationships How do we model a purchase relationship between buyers, products and stores? date Purchase Product Person Store Multi-way relationships are rare in practice Can still model as a mathematical set (How?) As a set of triples ⊆ Person × Product × Store

Arrows in Multiway Relationships date Q: What does the arrow mean ? Product Purchase Store Person Arrow pointing to E means that if we select one entity from each of the other entity sets in the relationship, those entities are related to at most one entity in E. A: Any person buys a given product from at most one store [Fine print: Arrow pointing to E means that if we select one entity from each of the other entity sets in the relationship, those entities are related to at most one entity in E]

Arrows in Multiway Relationships Q: What does the arrow mean ? date Product Purchase Store Person A: Any person buys a given product from at most one store AND every store sells to every person at most one product

Converting Multi-way Relationships to Binary ProductOf date Product Purchase StoreOf Store BuyerOf Person Arrows go in which direction?

Converting Multi-way Relationships to Binary ProductOf date Product Purchase StoreOf Store BuyerOf Person Make sure you understand why!

3. Design Principles What’s wrong? Purchase Product Person President Country Design does not reflect reality Person Moral: Be faithful to the specifications of the application!

Design Principles: What’s Wrong? date Product Purchase Store We have redundancy: repeat address of person for each purchase. More next lecture. Moral: pick the right kind of entities. personAddr personName

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

From E/R Diagrams to Relational Schema Entity set  relation Relationship  relation

Entity Set to Relation Product(prod-ID, category, price) prod-ID Gizmo55 Camera 99.99 Pokemn19 Toy 29.99

N-N Relationships to Relations prod-ID cust-ID date name date Shipment Shipping-Co Orders address Represent this in relations

N-N Relationships to Relations prod-ID cust-ID date name date Shipment Shipping-Co Orders Orders(prod-ID,cust-ID, date) Shipment(prod-ID,cust-ID, name, date) Shipping-Co(name, address) address prod-ID cust-ID name date Gizmo55 Joe12 UPS 4/10/2011 FEDEX 4/9/2011

N-1 Relationships to Relations prod-ID cust-ID date name date Shipment Shipping-Co Orders address Represent this in relations

N-1 Relationships to Relations prod-ID cust-ID date name date Shipment Shipping-Co Orders address Orders(prod-ID,cust-ID, date1, name, date2) Shipping-Co(name, address) Remember: no separate relations for many-one relationship

Multi-way Relationships to Relations address name Product Purchase price Store prod-ID Person Try this at home! ssn name Purchase(prod-ID, ssn, name)