Introduction to Databases

Similar documents
CSC 261/461 Database Systems Lecture 10

Conceptual Design. The Entity-Relationship (ER) Model

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

The Relational Model 2. Week 3

Database Management Systems. Chapter 3 Part 2

The Entity-Relationship Model

From ER to Relational Model. Book Chapter 3 (part 2 )

The Relational Model

High-Level Database Models (ii)

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

Data Modeling. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

The Relational Model. Chapter 3

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

The Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1

OVERVIEW OF DATABASE DEVELOPMENT

The Relational Model

CSE 530A. ER Model to Relational Schema. Washington University Fall 2013

The Entity-Relationship Model. Overview of Database Design

The Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model

The Relational Model (ii)

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

Review The Big Picture

Introduction to Data Management. Lecture #4 (E-R Relational Translation)

Translating an ER Diagram to a Relational Schema

Introduction to Database Design

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

High Level Database Models

Database Applications (15-415)

Database Design. ER Model. Overview. Introduction to Database Design. UVic C SC 370. Database design can be divided in six major steps:

CIS 330: Applied Database Systems

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Overview. Introduction to Database Design. ER Model. Database Design

Introduction to Database Design

Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU /615

Database Applications (15-415)

The Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations

Database Systems ( 資料庫系統 )

ER to Relational Mapping. ER Model: Overview

CSC 261/461 Database Systems Lecture 8. Fall 2017

CSE 530A. ER Model. Washington University Fall 2013

CSC 261/461 Database Systems Lecture 8. Spring 2018

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Introduction to Data Management. Lecture #4 (E-R à Relational Design)

Database Systems. Course Administration

The Relational Model

The Entity-Relationship Model

Entity-Relationship Models: Good Design and Constraints

Contents. Database. Information Policy. C03. Entity Relationship Model WKU-IP-C03 Database / Entity Relationship Model

Why Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

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

CS2 Current Technologies Lecture 5: Data Modelling and Design

Comp 5311 Database Management Systems. 4b. Structured Query Language 3

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

The Entity-Relationship (ER) Model

The Entity-Relationship Model. Steps in Database Design

Introduction to Data Management. Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping

MIS Database Systems Entity-Relationship Model.

Introduction to Data Management. Lecture #5 (E-R Relational, Cont.)

The Relational Model. Week 2

ER to Relational Mapping

The Entity-Relationship Model. Overview of Database Design. ER Model Basics. (Ramakrishnan&Gehrke, Chapter 2)

Database Management Systems. Session 2. Instructor: Vinnie Costa

ER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

Conceptual Design. The Entity-Relationship (ER) Model

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Entity-Relationship Diagrams

Introduction to Data Management. Lecture #6 E-Rà Relational Mapping (Cont.)

CS W Introduction to Databases Spring Computer Science Department Columbia University

Database Systems. Lecture2:E-R model. Juan Huo( 霍娟 )

ER Model Overview. The Entity-Relationship Model. Database Design Process. ER Model Basics

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Representation in Relational Model.

CIS 330: Web-driven Web Applications. Lecture 2: Introduction to ER Modeling

Database Design & Deployment

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Database Applications (15-415)

SYLLABUS ADMIN DATABASE SYSTEMS I WEEK 2 THE ENTITY-RELATIONSHIP MODEL. Assignment #2 changed. A2Q1 moved to A3Q1

Relational data model

Introduction to Database Design. Dr. Kanda Runapongsa Dept of Computer Engineering Khon Kaen University

The Entity-Relationship Model

LAB 3 Notes. Codd proposed the relational model in 70 Main advantage of Relational Model : Simple representation (relationstables(row,

CS/INFO 330 Entity-Relationship Modeling. Announcements. Goals of This Lecture. Mirek Riedewald

Part I: Structured Data

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

COMP 244. Entity Relationship Model Basics. Entity-Relationship Models. Key elements of the E-R model DATABASE CONCEPTS & APPLICATIONS

Agent 7 which languages? skills?

SQL DDL. CS3 Database Systems Weeks 4-5 SQL DDL Database design. Key Constraints. Inclusion Constraints

Database Design. Goal: specification of database schema Methodology:

Introduction to Data Management. Lecture #3 (E-R Design, Cont d.)

Overview of db design Requirement analysis Data to be stored Applications to be built Operations (most frequent) subject to performance requirement

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

The Relational Data Model. Data Model

The Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)

CITS3240 Databases Mid-semester 2008

Introduction to Data Management. Lecture #4 E-R Model, Still Going

Modeling Your Data. Chapter 2. cs542 1

CSE 880:Database Systems. ER Model and Relation Schemas

DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL. 1 Powered by POeT Solvers Limited

Advance Database Management System

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

Transcription:

Introduction to Databases

Data Retrival SELECT * FROM Students S WHERE S.age < 18

Data Retrival SELECT S.name, S.login FROM Students S WHERE S.age < 18

Entity sets to tables

Entity sets to tables CREATE TABLE ( CHAR(11), CHAR(30), Date, PRIMARY KEY () )

Relation sets to tables (no constraints) Since DID D Budget WorksIn Departments

Relation sets to tables (no constraints) Since DID D Budget WorksIn Departments CREATE TABLE WorksIn ( CHAR(11), DID INTEGER, Since DATE, PRIMARY KEY (, DID), FOREIGN KEY () REFERENCES, FOREIGN KEY (DID) REFERENCES Departments )

Relation sets to tables (no constraints) ReportsTo

Relation sets to tables (no constraints) ReportsTo CREATE TABLE ReportsTo (supervisor_ CHAR(11), subordinate_ CHAR(11), PRIMARY KEY (supervisor_, subordinate_), FOREIGN KEY (supervisor_) REFERENCES (), FOREIGN KEY (subordinate_) REFERENCES () )

Relation sets to tables (with key constraints) Since DID D Budget Manages Departments

Relation sets to tables (with key constraints) Since DID D Budget Manages Departments CREATE TABLE Manages ( CHAR(11), DID INTEGER, Since DATE, PRIMARY KEY (DID), FOREIGN KEY () REFERENCES, FOREIGN KEY (DID) REFERENCES Departments )

Relation sets to tables (with key constraints) Since DID D Budget Manages Departments CREATE TABLE Dept_Mgr (DID INTEGER, D CHAR(20), Budget REAL, CHAR(11), SINCE DATE, PRIMARY KEY (DID), FOREIGN KEY () REFERENCES )

Which way is better? Since DID D Budget Manages Departments Departments + Manages Dept_Mgr

Which way is better? Since DID D Budget Manages Departments Departments + Manages Often more space efficient Can be slow when generating the combined view Dept_Mgr Can waste space Remove the need for another table and therefore faster to query

Relation sets to tables (with participation constraints) Since DID D Budget Manages Departments CREATE TABLE Dept_Mgr (DID INTEGER, D CHAR(20), Budget REAL, CHAR(11) NOT NULL, SINCE DATE, PRIMARY KEY (DID), FOREIGN KEY () REFERENCES ON DELETE NO ACTION )

Relation sets to tables (with participation constraints) Since DID D Budget Manages Departments CREATE TABLE Manages ( CHAR(11), DID INTEGER, Since DATE, PRIMARY KEY (DID), FOREIGN KEY () REFERENCES, FOREIGN KEY (DID) REFERENCES Departments ) Can we still capture the total participation constraint?

Relation sets to tables (with participation constraints) Since DID D Budget Manages Departments CREATE TABLE Manages ( CHAR(11) NOT NULL, DID INTEGER, Since DATE, PRIMARY KEY (DID), FOREIGN KEY () REFERENCES, FOREIGN KEY (DID) REFERENCES Departments ) Does this fix the problem?

Relation sets to tables (with participation constraints) Since DID D Budget Manages Departments Participation constraints in general cannot be enforced with only table definitions. We need other more powerful tools, such as table constraints and assertions. What can be captured? (1) In a binary relationship, there is exactly one of the entity sets has a key constraints, and the total participation constraint is expressed on that entity set. (2) A relationship in which all participating entity sets have key constraints and total participation.

Weak entities to tables Cost P Age Policy Dependents CREATE TABLE Dep_Policy(P CHAR(20), Age INTEGER, Cost REAL, CHAR(11), PRIMARY KEY (P, ), FOREIGN KEY () REFERENCES ON DELETE CASCADE )

Class hierarchies First approach: Dog, Trained_Dog, In_Training_Dog

Class hierarchies Second approach: Trained_Dog and In_Training_Dog which common attributes of Dog.

Class hierarchies Which way is better? ER to Relational

Questions?