CSCI1270 Introduction to Database Systems

Similar documents
CMSC 424 Database design Lecture 4: Relational Model ER to Relational model. Book: Chap. 2 and 6. Mihai Pop

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

7042 Datenbanken. Prof. O. Nierstrasz. Wintersemester 1997/98

Chapter 2: Relational Model

QQ Group

CSCI 127 Introduction to Database Systems

DATABASE TECHNOLOGY - 1DL124

Database System Concepts, 5 th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "

Relational Model. Nisa ul Hafidhoh

Chapter 2: Relational Model

DATABASE DESIGN I - 1DL300

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7

SQL QUERIES. CS121: Relational Databases Fall 2017 Lecture 5

ADVANCED DATABASES ; Spring 2015 Prof. Sang-goo Lee (11:00pm: Mon & Wed: Room ) Advanced DB Copyright by S.-g.

CS34800 Information Systems. The Relational Model Prof. Walid Aref 29 August, 2016

Chapter 1: Introduction

Chapter 3: Relational Model

CSE 132A Database Systems Principles

CMPT 354: Database System I. Lecture 2. Relational Model

Database Technology Introduction. Heiko Paulheim

Database System Concepts

CS425 Fall 2016 Boris Glavic Chapter 1: Introduction

DATABASE TECHNOLOGY. Spring An introduction to database systems

Chapter 2: Intro to Relational Model

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model

Databases. Jörg Endrullis. VU University Amsterdam

UNIT I. Introduction

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

Upon completion of this Unit, students will be introduced to the following

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9

CSCB20. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

Chapter 3: Introduction to SQL

D.Hemavathi & R.Venkatalakshmi, Assistant Professor, SRM University, Kattankulathur

DATABASE TECHNOLOGY - 1MB025

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

DATABASTEKNIK - 1DL116

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

CAS CS 460/660 Introduction to Database Systems. Fall

U1. Data Base Management System (DBMS) Unit -1. MCA 203, Data Base Management System

Chapter 4: Intermediate SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

DATABASE TECHNOLOGY - 1MB025

The Relational Model

Database Systems Introduction SL01

Chapter 6: Formal Relational Query Languages

Chapter 1: Introduction

Database Principle. Zhuo Wang Spring

Relational Model. Prepared by: Ms. Pankti Dharwa ( Asst. Prof, SVBIT)

CSCI1270 Introduction to Database Systems

Chapter 1: Introduction

The SQL data-definition language (DDL) allows defining :

Textbook: Chapter 4. Chapter 5: Intermediate SQL. CS425 Fall 2016 Boris Glavic. Chapter 5: Intermediate SQL. View Definition.

Chapter 4: SQL. Basic Structure

2. E-R Model. Entity Sets Relationship Sets Attributes

1. (a) Explain the Transaction management in a database. (b) Discuss the Query Processor of Database system structure. [8+8]

Review. The Relational Model. Glossary. Review. Data Models. Why Study the Relational Model? Why use a DBMS? OS provides RAM and disk

Chapter 4: Intermediate SQL

CS425 Fall 2017 Boris Glavic Chapter 5: Intermediate SQL

Lecture 2 SQL. Announcements. Recap: Lecture 1. Today s topic. Semi-structured Data and XML. XML: an overview 8/30/17. Instructor: Sudeepa Roy

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

Review. Support for data retrieval at the physical level:

Introduction to DBMS

Chapter 3: Introduction to SQL

DATABASE DESIGN I - 1DL300

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Relational Databases Fall 2017 Lecture 1

Textbook: Chapter 6! CS425 Fall 2013 Boris Glavic! Chapter 3: Formal Relational Query. Relational Algebra! Select Operation Example! Select Operation!

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Introduction to Relational Database Systems Fall 2016 Lecture 1

DATABASE TECHNOLOGY. Spring An introduction to database systems

Chapter 1: Introduction. Chapter 1: Introduction

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

Chapter 2 Introduction to Relational Models

Explain in words what this relational algebra expression returns:

The SQL database language Parts of the SQL language

Lecture 3 SQL. Shuigeng Zhou. September 23, 2008 School of Computer Science Fudan University

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

customer = (customer_id, _ customer_name, customer_street,

CS34800 Information Systems. Course Overview Prof. Walid Aref January 8, 2018

The Relational Data Model. Data Model

Integrity and Security

Database Management Systems (CPTR 312)

The Relational Model of Data (ii)

King Fahd University of Petroleum and Minerals

The Relational Model. Suan Lee

CS127 Homework #3. Due: October 11th, :59 P.M. Consider the following set of functional dependencies, F, for the schema R(A, B, C, D, E)

CS143: Relational Model

1. The rst database systems were based on the network and hierarchical models. These are covered briey

Chapter 1: Introduction

Entity-Relationship Model

CS275 Intro to Databases

CS425 Midterm Exam Summer C 2012

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

Administrivia. The Relational Model. Review. Review. Review. Some useful terms

CompSci 516 Database Systems. Lecture 2 SQL. Instructor: Sudeepa Roy

CSCC43H: Introduction to Databases. Lecture 4

Database Management Systems. Chapter 3 Part 1

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

CS 377 Database Systems

Announcements If you are enrolled to the class, but have not received the from Piazza, please send me an . Recap: Lecture 1.

Relational data model

Transcription:

CSCI1270 Introduction to Database Systems Relations

Relational Data Model Introduced by Ted Codd (late 60 s early 70 s) Before = Network Data Model (Cobol as DDL, DML) Very contentious: Database Wars Relational data model contributes: 1. Separation of logical and physical data models (data independence) 2. Declarative query languages 3. Formal semantics 4. Query optimization (key to commercial success) First prototypes: Ingres (UC Berkeley) System R (IBM) DB2

Relations bname acct_no balance Account = A-101 A-201 900 Table name A-217 Terms:: Attribute names Tables Relations Columns Attributes Rows Tuples Schema (e.g.: Acct_Schema = (bname, acct_no, balance)) Domain -> set of all possible values for an attribute. (e.g., domain(acct_no)= { A101, A201, A217, A230} )

Why Are They Called Relations? Mathematical relations Given sets: R = {1, 2, 3}, S = {3, 4} R X S = { (1, 3), (1, 4), (2, 3), (2, 4), (3, 3), (3, 4) } A relation on R, S is any subset ( ) of R X S (e.g: { (1, 4), (3, 4)}) Database relations Given attribute domains Branches = {,, } Accounts = { A-101, A-201, A-217, } Balances = R = real numbers Account Branches Accounts Balances { (, A-101, ), (, A-201, 900), (, A-217, ) } (no nesting = 1NF)

Relations bname acct_no balance Account = A-101 A-201 900 A-217 Considered equivalent to { (, A-101, ), (, A-201, 900), (, A-217, ) } Relational database semantics are defined in terms of mathematical relations (i.e., sets)

Keys and Relations Kinds of keys 1. Superkeys set of attributes of table for which every row has distinct set of values 2. Candidate keys minimal superkeys 3. Primary keys DBA-chosen candidate key Act as Integrity Constraints i.e., guard against illegal/invalid instance of given schema e.g., Branch = (bname, bcity, assets) bname bcity assets Brooklyn 5M Boston 3M Invalid!!

Integrity Constraints in Create Table not null primary key (A 1,..., A n ) Example: Declare ID as the primary key for instructor. create table instructor ( ID char(5), name varchar(20) not null, dept_name varchar(20), salary numeric(8,2), primary key (ID)) primary key declaration on an attribute automatically ensures not null

And a Few More Relation Definitions create table student ( student_id varchar(5), name varchar(20) not null, dept_name varchar(20), total_credit numeric(3,0), primary key (student-id)); w.o. sec_id in key: create table takes ( student_id varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), is disallowed year numeric(4,0), grade varchar(2), primary key (student_id, course_id, sec_id, semester, year) ); (stan, cs127, 1, fall, 2017, A) (stan, cs127, 2, fall, 2017, B) Note: sec_id should be dropped from primary key above. Must ensure a student cannot be registered for two sections of the same course in the same semester

Example of Using Keys (student_id course_id sec_id ssemester year grade S1 CS127 1 fall 2017 A S1 CS127 2 fall 2017 B With sec_id in the key, these 2 tuples are unique and thus are allowed Without sec_id in the key, these 2 tuples are identical and thus are disallowed CSCI1270, Fall 2011, Lecture 2

Bank Database (Schema) Account bname acct_no balance Branch bname bcity assets cname Depositor acct_no cname Borrower lno Customer cname cstreet ccity Loan bname lno amt

Bank Database Account bname acct_no balance Mianus Perry R.H. Redwood cname Johnson Smith Hayes Turner Johnson Jones Lindsay A-101 A-215 A-102 A-305 A-201 A-222 A-217 Depositor Customer 700 400 350 900 700 750 acct_no A-101 A-215 A-102 A-305 A-201 A-217 A-222 cname cstreet ccity Jones Smith Hayes Curry Lindsay Turner Williams Adams Johnson Glenn Brooks Green Main North Main North Park Putnam Nassau Spring Alma Sand Hill Senator Walnut Harrison Rye Harrison Rye Pittsfield Stanford Princeton Pittsfield Palo Alto Woodside Brooklyn Stanford Branch bname bcity assets Redwood Perry Mianus R.H. Pownel N. Town cname Jones Smith Hayes Jackson Curry Smith Williams Adams Brooklyn Palo Alto Horseneck Horseneck Horseneck Bennington Rye Brooklyn Borrower Loan lno L-17 L-23 L-15 L-14 L-93 L-11 L-17 L-16 9M 2.1M 1.7M 0.4M 8M 0.3M 3.7M 7.1M bname lno amt Redwood Perry Mianus R.H. Perry L-17 L-23 L-15 L-14 L-93 L-11 L-16 1000 2000 1 1 900 1300