The Relational Data Model Database Model (ODL, E/R) Relational Schema Physical storage ODL definitions Diagrams (E/R) Tables: row names: attributes rows:

Slides:



Advertisements
Similar presentations
1 Lecture 02: SQL. 2 Outline Data in SQL Simple Queries in SQL (6.1) Queries with more than one relation (6.2) Recomeded reading: Chapter 3, Simple Queries.
Advertisements

SQL Introduction Standard language for querying and manipulating data Structured Query Language Many standards out there: SQL92, SQL2, SQL3. Vendors support.
Information Systems Chapter 4 Relational Databases Modelling.
1 Relational Model and Translating ER into Relational.
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 06 The Relational Data Model. 2 Outline Relational Data Model Functional Dependencies FDs in ER Logical Schema Design Reading Chapter 8.
One More Normal Form Consider the dependencies: Product Company Company, State Product Is it in BCNF?
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.
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.
Exercises Product ( pname, price, category, maker) Purchase (buyer, seller, store, product) Company (cname, stock price, country) Person( per-name, phone.
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.
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.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
1 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An = {(x1, x2, x3, …, xn): xi  Ai} R  A1  A2.
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
Object Definition Language
Database Design Why do we need it? – Agree on structure of the database before deciding on a particular implementation. Consider issues such as: –What.
1 Web Database The Relational Data Model Irvanizam Zamanhuri, M.Sc Computer Science Study Program Syiah Kuala University Website :
1 Lecture 08: E/R Diagrams and Functional Dependencies Friday, January 21, 2005.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
CSE 326: Data Structures Lecture #22 Databases and Sorting Alon Halevy Spring Quarter 2001.
Lecture 11: Functional Dependencies
SQL.
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 Relational Model.
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
Conceptual Database Design
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
Chapter 4 Relational Databases
Translation of ER-diagram into Relational Schema
Problems in Designing Schema
Lecture 2 (cont’d) & Lecture 3: Advanced SQL – Part I
From E/R Diagrams to Relational Schema
March 30th – intro to joins
Cse 344 January 10th –joins.
Introduction to SQL Wenhao Zhang October 5, 2018.
Principles of Database Management Systems CSE 544
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
name category name price makes Company Product stockprice buys employs
Building a Database Application
SQL Introduction Standard language for querying and manipulating data
Functional Dependencies
Lecture 12: SQL Friday, October 20, 2000.
Lectures 3: Introduction to SQL 2
Introduction to Database Systems CSE 444 Lecture 02: SQL
Where are we? Until now: Modeling databases (ODL, E/R): all about the schema Now: Manipulating the data: queries, updates, SQL Then: looking inside -
Lecture 07: E/R Diagrams and Functional Dependencies
Functional Dependencies
Lecture 5: The Relational Data Model
Functional Dependencies
CS4433 Database Systems Relational Model.
Terminology Product Attribute names Name Price Category Manufacturer
Lectures 2: Introduction to SQL 1
DATABASE MANAGEMENT SYSTEM
Lecture 08: E/R Diagrams and Functional Dependencies
Lecture 6: Functional Dependencies
Lecture 09: Functional Dependencies
Presentation transcript:

The Relational Data Model Database Model (ODL, E/R) Relational Schema Physical storage ODL definitions Diagrams (E/R) Tables: row names: attributes rows: tuples Complex file organization and index structures.

Terminology Name Price Category Manufacturer gizmo $19.99 gadgets GizmoWorks Power gizmo $29.99 gadgets GizmoWorks SingleTouch $ photography Canon MultiTouch $ household Hitachi tuples Attribute names

More Terminology Every attribute has an atomic type. Relation Schema: relation name + attribute names + attribute types Relation instance: a set of tuples. Only one copy of any tuple! Database Schema: a set of relation schemas. Database instance: a relation instance for every relation in the schema.

More on Tuples Formally, a mapping from attribute names to (correctly typed) values: name gizmo price $19.99 category gadgets manufacturer GizmoWorks Sometimes we refer to a tuple by itself: (note order of attributes) (gizmo, $19.99, gadgets, GizmoWorks) or Product (gizmo, $19.99, gadgets, GizmoWorks).

Updates The database maintains a current database state. Updates to the data: 1) add a tuple 2) delete a tuple 3) modify an attribute in a tuple Updates to the data happen very frequently. Updates to the schema: relatively rare. Rather painful.

From ODL to Relational Schema Start simple: a class definition has only single valued attributes Interface product{ float price; string name; Enum {telephony, gadgets, books} category} Every attribute becomes a relation attribute: Name Price Category Gizmo $19.99 gadgets

Adding Non atomic Attributes Name Currency Amount Category Gizmo US$ gadgets Power Gizmo US$ gadgets Price is a record: {string currency, float amount}

Set Attributes Name SSN Phone Number Fred (201) Fred (206) Joe (908) Joe (212) One option: have a tuple for every value in the set: Disadvantages?

Modeling Collection Types How can we model bags? Lists? Fixed length arrays? The problem becomes even more significant if a class has several attributes that are set types? Question: how bad is the redundancy for n set type attributes, each with possibly up to m values? Questions:

Modeling Relationships Interface Product { attribute string name; attribute float price; relationship madeBy; } Interface Company { attribute string name; attribute float stock-price; attribute string address; } How do we incorporate the relationship madeBy into the schema?

Option #1 Name Price made-by-name made-by-stock-price made-by-address Gizmo $19.99 gizmoWorks $ Montezuma What’s wrong?

Hint Interface Product { attribute string name; attribute float price; relationship madeBy; } Interface Company { attribute string name; attribute float stock-price; attribute string address; relationship set makes; }

Better Solution Name Price made-by-name Gizmo $19.99 gizmoWorks Product relation: (assume: name is a key for company) Company relation: Name Stock Price Address Gizmo $ Montezuma

Additional Issues 1. What if there is no key? 2. What if the relationship is multi-valued? 3. How do we represent a relationship and its inverse?