CS411 Database Systems



Similar documents
Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

The Entity-Relationship Model

Conceptual Design Using the Entity-Relationship (ER) Model

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #5: En-ty/Rela-onal Models- - - Part 1

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

Lecture 6. SQL, Logical DB Design

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Database Design and Programming

The Relational Data Model: Structure

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Review: Participation Constraints

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

Object Oriented Databases. OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

Data Modeling. Database Systems: The Complete Book Ch ,

2. Conceptual Modeling using the Entity-Relationship Model

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

Databases What the Specification Says

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Lecture 12: Entity Relationship Modelling

Databases and BigData

B561 Advanced Database Concepts. 0 Introduction. Qin Zhang 1-1

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Entity Relationship Diagram

Object Oriented Databases (OODBs) Relational and OO data models. Advantages and Disadvantages of OO as compared with relational

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Database Design. Goal: specification of database schema Methodology: E-R Model is viewed as a set of

Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

types, but key declarations and constraints Similar CREATE X commands for other schema ëdrop X name" deletes the created element of beer VARCHARè20è,

Database Management. Technology Briefing. Modern organizations are said to be drowning in data but starving for information p.

Modern Databases. Database Systems Lecture 18 Natasha Alechina

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

DATABASE INTRODUCTION

Relational Databases. Christopher Simpkins

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

OBJECTS AND DATABASES. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 21

IT2304: Database Systems 1 (DBS 1)

IT2305 Database Systems I (Compulsory)

Chapter 1: Introduction. Database Management System (DBMS) University Database Example

The Entity-Relationship Model

Lesson 8: Introduction to Databases E-R Data Modeling

EECS 647: Introduction to Database Systems

ECS 165A: Introduction to Database Systems

Normal Form vs. Non-First Normal Form

Trial version of GADD Dashboards Builder

Oracle USF

Database Management Systems. Chapter 1

not necessarily strictly sequential feedback loops exist, i.e. may need to revisit earlier stages during a later stage

CMU - SCS / Database Applications Spring 2013, C. Faloutsos Homework 1: E.R. + Formal Q.L. Deadline: 1:30pm on Tuesday, 2/5/2013

Database Systems. Lecture 1: Introduction

Part 7: Object Oriented Databases

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

Grade 6 Math Circles. Binary and Beyond

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

TIM 50 - Business Information Systems

There are five fields or columns, with names and types as shown above.

Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

Chapter 9: Object-Based Databases

Answers included WORKSHEET: INTEGRITY CONTROL IN RELATIONAL DATABASES

Introduction to Database Systems. Normalization

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Designing a Database Schema

Taming of the Shrew Documenting an APEX Application. Dietmar Aust Opal-Consulting, Köln

Object-persistence formats. Files. Object-oriented databases. Data management layer design. Relational databases. Relational Database Example.

Relational Databases

Fundamentals of Database Design

Chapter 1: Introduction. Database Management System (DBMS)

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

CS352 Lecture - Object-Based Databases

Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

Relational Schema Design

Basic Concepts of Database Systems

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

Relational Database Concepts

5.5 Copyright 2011 Pearson Education, Inc. publishing as Prentice Hall. Figure 5-2

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

Winter Winter

Entity-Relationship Model

Chapter 1: Introduction

Database Fundamentals: 1

3. Relational Model and Relational Algebra

Overview RDBMS-ORDBMS- OODBMS

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method

11 November

Complex Data and Object-Oriented. Databases

Data Modeling: Part 1. Entity Relationship (ER) Model

Transcription:

Announcements CS411 Database Systems 03: The Relational Model Kazuhiro Minami Project stage 0 is due today Grade distribution of the course project Stage 1 (Decide your application): 5% Stage 2 (ER modeling) : 5% Stage 3 (Relational schema design): 10% Stage 4 (Demo for basic functions) : 30% Stage 5 (Final demo/report): 50% Grade distribution of the graduate project Stage A (Decide your survey topic): 5% Stage B (Preliminary report): 30% Stage C (Final report): 65% Ideas Database Model (E/R, ODL) DB Modeling & Implementation Diagrams (E/R) Relational Schema Tables: column s: attributes rows: tuples Physical storage Complex file organization and index structures. Why do we need both the ER and relational models? Relational model has just a single concept: tables Allow us to express queries at a very high level well-suited for efficient manipulations on computers ER model is richer: entities, relationships, attributes, etc. well-suited for capturing application requirements not so well-suited for computer implementation (no query language)

Relation (table) s: Attributes (columns) Each attribute has a type: its domain Name Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks PowerGizmo $29.99 Gadgets GizmoWorks SingleTouch $149.99 Photography Canon Integer, string, date, real Traditionally domains were not userdefinable, e.g., map Domains must be atomic (why? see later) MultiTouch $203.99 Household Hitachi Tuples (rows) The relation s schema is its metadata Relation (table) s: Attributes (columns) & their domains Name Price Category Manufacturer The relation s instance = the data in it Gizmo $19.99 Gadgets GizmoWorks PowerGizmo $29.99 Gadgets GizmoWorks SingleTouch $149.99 Photography Canon MultiTouch $203.99 Household Hitachi 4 tuples (rows)

We can write a schema concisely: (Name, Price, Category, Manufacturer) DB schema = finite set of relation schemas. (Name, Price, Category, Manufacturer), Vendor(Name, Address, Phone),. Now the fun part: translating an ER diagram into the relational model How to convert a E/R diagram to a set of relations? price category Start Year makes Company Stock price How to translate an ER diagram to a relational schema Basic cases Entity set E = relation with attributes of E Relationship R = relation with attributes being keys of related entity sets + attributes of R Special cases Combining two relations Translating weak entity sets Translating is-a relationships and subclasses

How to convert an entity set to a relation category How to convert a relationship to a relation price category Start Year price makes Company : Name Price Category Gizmo $19.99 Gadgets Makes (watch out for attribute conflicts) _ Name _ Category Company_ Name Gizmo Gadgets GizmoWorks 1963 Start_Year Stock price Sometimes it is best to combine two relations addr Drinkers Likes buddy1 buddy2 Buddies Favorite Likes(drinker, beer) husband wife Favorite(drinker, beer) Married Buddies(1, 2) Married(husband, wife) price category Start Year makes Company Stock price (, category, price) Makes(product_, category, StartYear, company_) Company(, StockPrice)

Sometimes it is best to combine two relations price category Start Year makes Company No need for Makes. Just modify : Stock price Name Price Category Manufacturer Start_ Year Gizmo $19.99 Gadgets GizmoWorks 1963 It is OK to combine the relation for an entity set E with the relation for a one-one relationship from E to another entity set. Drinkers(, addr) Favorite(drinker, beer) Drinkers(, addr, favoritebeer) What if each drinker could have several favorite beers? Combining a many-to-many relationship causes trouble Companies(, addr) MakerOf(companyName, producttype) Name Address Type GizmoWorks 123 MG Rd Wheels GizmoWorks 123 MG Rd Whistles Redundancy! How to convert a weak entity set to a relation Team affiliation University schedule sport address Team Sport Schedule University_Name Mud wrestling <long string> Montezuma State Univ. Do include all the attributes in the key for Team. Don t include a separate relation for Affiliation. (why?)

Exercise 4.5.1 Convert the E/R diagram to a relational database schema. row seat Booking memory How to translate a subclass platforms Software topic Educational agegroup Customers phone Flights SSN address number day aircraft Educ-software Educationalmethod Three ways to translate subclasses Object-oriented: each entity belongs to exactly one class; create a relation for each class, with all its attributes. E/R style: create one relation for each subclass, with only the key attribute(s) and attributes attached to that entity set; Use null: create one relation; entities have nulls in attributes that don t belong to them. Option #1: the OO Approach 4 tables: each object can only belong to a single table (, price, category, manufacturer) Educational(, price, category, manufacturer, agegroup, topic) Software(, price, category, manufacturer, platforms, requiredmemory) EducationalSoftware(, price, category, manufacturer, agegroup, topic, platforms, requiredmemory) All s are distinct

Option #2: the E/R Approach (, price, category, manufacturer) Educational(, agegroup, topic) Software(, platforms, requiredmemory) No need for a relation EducationalSoftware unless it has a specialized attribute: EducationalSoftware(, educational-method) Same may appear in several relations Have one table: Option #3: The Null Value Approach (, price, manufacturer, age-group, topic, platforms required-memory, educational-method) Some values in the table will be NULL, meaning that the attribute not make sense for the specific product. Too many meanings for NULL Example Object Oriented Bud Anheuser-Busch Summerbrew Pete s dark

E/R Style Using Nulls Bud Anheuser-Busch Summerbrew Pete s Summerbrew dark Bud Anheuser-Busch NULL Summerbrew Pete s dark Comparisons O-O approach good for queries like find the of ales made by Pete s. Just look in relation. E/R approach good for queries like find all beers (including ales) made by Pete s. Just look in relation. Using nulls saves space unless there are lots of attributes that are usually null.