Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications. Outline. We ll learn: Faloutsos CMU SCS 15-415



Similar documents
Basic Concepts of Database Systems

Database System Architecture & System Catalog Instructor: Mourad Benchikh Text Books: Elmasri & Navathe Chap. 17 Silberschatz & Korth Chap.

1 File Processing Systems

Chapter 1: Introduction

ECS 165A: Introduction to Database Systems

Introduction. Introduction: Database management system. Introduction: DBS concepts & architecture. Introduction: DBS versus File system

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

Introduction: Database management system

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

Database Systems Introduction Dr P Sreenivasa Kumar

Chapter 2 Database System Concepts and Architecture

DATABASE SYSTEM CONCEPTS AND ARCHITECTURE CHAPTER 2

Chapter 1: Introduction. Database Management System (DBMS)

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

Chapter 1: Introduction

Introduction to database management systems

CS 4604: Introduc0on to Database Management Systems

Introduction to Databases

Topics. Introduction to Database Management System. What Is a DBMS? DBMS Types

Introduction to Database Systems. Chapter 1 Introduction. Chapter 1 Introduction

BCA. Database Management System

Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Overview - detailed. Goal. Faloutsos CMU SCS

Week 1 Part 1: An Introduction to Database Systems. Databases and DBMSs. Why Use a DBMS? Why Study Databases??

Principles of Database. Management: Summary

Database Concepts. Database & Database Management System. Application examples. Application examples

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

Overview of Database Management

Introduction to Database Systems

Database Management Systems

Database System Concepts

æ A collection of interrelated and persistent data èusually referred to as the database èdbèè.

Chapter 3. Database Environment - Objectives. Multi-user DBMS Architectures. Teleprocessing. File-Server

Overview of Data Management

Overview of Database Management Systems

Introdução às Bases de Dados

Foundations of Information Management

Oracle 10g PL/SQL Training

Databases What the Specification Says

Database Management Systems. Chapter 1

COMP5138 Relational Database Management Systems. Databases are Everywhere!

Database System. Session 1 Main Theme Introduction to Database Systems Dr. Jean-Claude Franchitti

Scope of this Course. Database System Environment. CSC 440 Database Management Systems Section 1

Course: CSC 222 Database Design and Management I (3 credits Compulsory)

Relational Database Systems 2 1. System Architecture

ICOM 6005 Database Management Systems Design. Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 August 23, 2001

Database Systems. Lecture 1: Introduction

Objectives of Lecture 1. Labs and TAs. Class and Office Hours. CMPUT 391: Introduction. Introduction

Files. Files. Files. Files. Files. File Organisation. What s it all about? What s in a file?

Author: Abhishek Taneja

IT2305 Database Systems I (Compulsory)

Chapter 1 Databases and Database Users

CSE 132A. Database Systems Principles

7. Databases and Database Management Systems

Topics. Database Essential Concepts. What s s a Good Database System? Using Database Software. Using Database Software. Types of Database Programs

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 1 Outline

Chapter 1 File Organization 1.0 OBJECTIVES 1.1 INTRODUCTION 1.2 STORAGE DEVICES CHARACTERISTICS

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

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

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

SQL, PL/SQL FALL Semester 2013

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

IT2304: Database Systems 1 (DBS 1)

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

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

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

1.264 Lecture 15. SQL transactions, security, indexes

Course Notes on Databases and Database Management Systems

Introductory Concepts

How To Create A Table In Sql (Ahem)

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

Physical Database Design and Tuning

DBMS / Business Intelligence, SQL Server


1. Physical Database Design in Relational Databases (1)

Chapter 1 - Database Systems

Database Systems. Session 1 Main Theme Introduction to Database Systems Dr. Jean-Claude Franchitti

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

DATABASE MANAGEMENT SYSTEMS. Question Bank:

php tek 2006 in Orlando Florida Lukas Kahwe Smith

B.Com(Computers) II Year RELATIONAL DATABASE MANAGEMENT SYSTEM Unit- I

EECS 647: Introduction to Database Systems

Introduction. Chapter 1. Introducing the Database. Data vs. Information

Foundations of Information Management

Overview. Introduction to Database Systems. Motivation... Motivation: how do we store lots of data?

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

Databases. DSIC. Academic Year

Big Data Analytics Building Blocks; Simple Data Storage (SQLite)

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY

Big Data Analytics Building Blocks; Simple Data Storage (SQLite)

Oracle USF

References. Introduction to Database Systems CSE 444. Motivation. Basic Features. Outline: Database in the Cloud. Outline

Introduction to Database Systems CSE 444

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

CS 564: DATABASE MANAGEMENT SYSTEMS

Ch.5 Database Security. Ch.5 Database Security Review

Logistics. Database Management Systems. Chapter 1. Project. Goals for This Course. Any Questions So Far? What This Course Cannot Do.

SQL Server. 1. What is RDBMS?

Introduction to Database Systems. Module 1, Lecture 1. Instructor: Raghu Ramakrishnan UW-Madison

Database Management. Chapter Objectives

Database Schema Deployment. Lukas Smith - lukas@liip.ch CodeWorks PHP on the ROAD

Transcription:

Faloutsos 15-415 Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications C. Faloutsos Lecture#1: Introduction Outline Introduction to DBMSs The Entity Relationship model The Relational Model SQL: the commercial query language DB design: FD, 3NF, BCNF indexing, q-opt concurrency control & recovery advanced topics (data mining, multimedia) Faloutsos 15-415 2 What are RDBMS when to use them We ll learn: how to model data with them how to store and retrieve information how to search quickly for information Internals of an RDBMS: indexing, transactions Faloutsos 15-415 3 1

Faloutsos 15-415 We ll learn (cnt d) Advanced topics multimedia indexing (how to find similar, eg., images) data mining (how to find patterns in data) Faloutsos 15-415 4 Administrivia Weights: as announced Sum= 100% ASGN Course grade 30% 30% 40% 5% 5% ASGN1 ASGN8 MT Final exam Faloutsos 15-415 5 Administrivia - II FYI: ASGN3 and ASGN7 are heavy Late policy: 4 slip days Exams: no aids allowed, except 1 page with your notes (both sides) for MT 2 such pages for Final Faloutsos 15-415 6 2

Faloutsos 15-415 Introduction Motivating example Detailed outline How do DBMSs work? DDL, DML, views. Fundamental concepts DBMS users Overall system architecture Conclusions Faloutsos 15-415 7 What is the goal of rel. DBMSs Faloutsos 15-415 8 What is the goal of rel. DBMSs Electronic record-keeping: Fast and convenient access to information. Faloutsos 15-415 9 3

Faloutsos 15-415 Definitions DBMS = Data Base Management System : the (commercial) system, like: DB2, Oracle, MS SQL-server,... Database system : DBMS + data + application programs Faloutsos 15-415 10 Motivating example Eg.: students, taking classes, obtaining grades; find my gpa <and other ad-hoc queries> Faloutsos 15-415 11 Obvious solution: paper-based advantages? disadvantages? eg., student folders, alpha sorted Faloutsos 15-415 12 4

Faloutsos 15-415 Obvious solution: paper-based advantages? cheap; easy to use disadvantages? eg., student folders, alpha sorted Faloutsos 15-415 13 Obvious solution: paper-based advantages? cheap; easy to use disadvantages? no ad hoc queries no sharing large physical foot-print Faloutsos 15-415 14 Next obvious solution computer-based (flat) files + C (Java,...) programs to access them e.g., one (or more) UNIX/DOS files, with student records and their courses Faloutsos 15-415 15 5

Faloutsos 15-415 Next obvious solution your layout for the student records? Faloutsos 15-415 16 Next obvious solution your layout for the student records? (eg., comma-separated values csv Smith,John,123,db,A,os,B Tompson,Peter,234 Atkinson,Mary,345,os,B,graphics,A Faloutsos 15-415 17 Next obvious solution your layout for the student records? (many other layouts are fine, eg.: Smith,John,123 Tompson,Peter,234 Atkinson,Mary,345 123,db,A 123,os,B 345,os,B 345,graphics,A Faloutsos 15-415 18 6

Faloutsos 15-415 Problems? Faloutsos 15-415 19 Problems? inconvenient access to data (need C++ expertize, plus knowledge of file-layout) data isolation data redundancy (and inconcistencies) integrity problems atomicity problems Faloutsos 15-415 20 Problems? (cont d)... concurrent-access anomalies security problems Faloutsos 15-415 21 7

Faloutsos 15-415 Problems? (cont d) [ why? because of two main reasons: file-layout description is buried within the C programs and there is no support for transactions (concurrency and recovery) ] DBMSs handle exactly these two problems Faloutsos 15-415 22 DBMS solution commercial/freeware DBMS & application programs Faloutsos 15-415 23 Commercial Oracle IBM/DB2 Main vendors/products MS SQL-server Sybase Informix/IBM (MS Access,...) Open source Postgres (UCB) mysql, msql minibase (Wisc) Predator (Cornell) sqlite (sqlite.org) (www.acm.org/sigmod) Faloutsos 15-415 24 8

Faloutsos 15-415 <Demo with sqlite3> Insert student and takes records Find the os class roster Find the GPA of Smith www.cs.cmu.edu/~christos/courses/dbms.s12/files/sqldemo.zip Faloutsos 15-415 25 Introduction Motivating example Detailed outline How do DBMSs work? DDL, DML, views. Fundamental concepts DBMS users Overall system architecture Conclusions Faloutsos 15-415 26 How do DBs work? Pictorially: select * from student DBMS data and meta-data = catalog = data dictionary Faloutsos 15-415 27 9

Faloutsos 15-415 How do DBs work? % sqlite3 miniu.sql sqlite>create table student ( ssn fixed; name char(20) ); Smith,John, 123,db,A,os,B Tompson,Peter,234 Atkinson,Mary,345,os,B,graphics,A Faloutsos 15-415 28 How do DBs work? % sqlite3 miniu.sql sqlite>create table student ( ssn fixed; name char(20) ); Smith, 123,db,A,os,B Tompson, 234 Atkinson, 345,os,B,graphics,A Faloutsos 15-415 29 How do DBs work? sqlite>insert into student values (123, Smith ); sqlite>select * from student; Faloutsos 15-415 30 10

Faloutsos 15-415 create table student (ssn fixed, name char(20)); insert into student values(123, "Smith"); insert into student values(234, "Tompson"); insert into student values(345, "Atkinson"); -- see what we have inserted select * from student; ssn name ---------- ---------- 123 Smith 234 Tompson 345 Atkinson Faloutsos 15-415 31 How do DBs work? sqlite>create table takes ( ssn fixed, cid char(10), grade fixed)); Faloutsos 15-415 32 -- register students in classes and give them grades drop table if exists takes; create table takes (ssn fixed, cid char(10), grade fixed); insert into takes values( 123, "db", 4); insert into takes values( 123, "os", 3); insert into takes values( 345, "os", 3); insert into takes values( 345, "graphics", 4); Smith,John,123,db,A,os,B Tompson,Peter,234 Atkinson,Mary,345,os,B,graphics,A Faloutsos 15-415 33 11

Faloutsos 15-415 -- see what we inserted select * from takes; ssn cid grade ---------- ---------- ---------- 123 db 4 123 os 3 345 os 3 345 graphics 4 Smith,John,123,db,A,os,B Tompson,Peter,234 Atkinson,Mary,345,os,B,graphics,A Faloutsos 15-415 34 How do DBs work - cont d More than one tables - joins Eg., roster (names only) for os Faloutsos 15-415 35 How do DBs work - cont d sqlite> select name from student, takes where student.ssn = takes.ssn and takes.c-id = os Faloutsos 15-415 36 12

Faloutsos 15-415 -- find the os class roster select name from student, takes where student.ssn = takes.ssn and cid="os"; name ---------- Smith Atkinson Smith,John,123,db,A,os,B Tompson,Peter,234 Atkinson,Mary,345,os,B,graphics,A Faloutsos 15-415 37 Views - a powerful tool! what and why? suppose secy is allowed to see only ssn s and GPAs, but not individual grades -> VIEWS! Faloutsos 15-415 38 Views sqlite> create view fellowship as ( select ssn, avg(grade) from takes group by ssn); takes ssn cid grade 123 db 4 123 os 3 345 os 3 345 graphics 4 Faloutsos 15-415 39 13

Faloutsos 15-415 Views Views = virtual tables Faloutsos 15-415 40 Views sqlite> select * from fellowship; takes ssn cid grade 123 db 4 123 os 3 345 os 3 345 graphics 4 Faloutsos 15-415 41 Views sql> grant select on fellowship to secy; ( grant not supported in sqlite) takes ssn cid grade 123 db 4 123 os 3 345 os 3 345 graphics 4 Faloutsos 15-415 42 14

Faloutsos 15-415 Iterating: advantages over (flat) files logical and physical data independence, because data layout, security etc info: stored explicitly on the disk concurrent access and transaction support Faloutsos 15-415 43 Disadvantages over (flat) files? Faloutsos 15-415 44 Disadvantages over (flat) files Price additional expertise (SQL/DBA) (hence: over-kill for small, single-user data sets But: mobile phones (eg., android) use sqlite; some versions of firefox do, too) Faloutsos 15-415 45 15

Faloutsos 15-415 Introduction Motivating example Detailed outline How do DBMSs work? DDL, DML, views. Fundamental concepts DBMS users Overall system architecture Conclusions Faloutsos 15-415 46 Fundamental concepts 3-level architecture logical data independence physical data independence Faloutsos 15-415 47 view level logical level physical level 3-level architecture v1 v2 v3 Faloutsos 15-415 48 16

Faloutsos 15-415 3-level architecture view level logical level: eg., tables STUDENT(ssn, name) TAKES (ssn, cid, grade) physical level: how are these tables stored, how many bytes / attribute etc Faloutsos 15-415 49 3-level architecture view level, eg: v1: select ssn from student v2: select ssn, c-id from takes logical level physical level Faloutsos 15-415 50 3-level architecture -> hence, physical and logical data independence: logical D.I.:??? physical D.I.:??? Faloutsos 15-415 51 17

Faloutsos 15-415 3-level architecture -> hence, physical and logical data independence: logical D.I.: can add (drop) column; add/drop table physical D.I.: can add index; change record order Faloutsos 15-415 52 Introduction Motivating example Detailed outline How do DBMSs work? DDL, DML, views. Fundamental concepts DBMS users Overall system architecture Conclusions Faloutsos 15-415 53 Database users naive users casual users application programmers [ DBA (Data base administrator)] Faloutsos 15-415 54 18

Faloutsos 15-415 select * from student Casual users DBMS data and meta-data = catalog Faloutsos 15-415 55 ``Naive users Pictorially: DBMS data app. (eg., report generator) and meta-data = catalog Faloutsos 15-415 56 App. programmers those who write the applications (like the report generator ) Faloutsos 15-415 57 19

Faloutsos 15-415 DB Administrator (DBA) Duties? Faloutsos 15-415 58 DB Administrator (DBA) schema definition ( logical level) physical schema (storage structure, access methods schema modifications granting authorizations integrity constraint specification Faloutsos 15-415 59 Introduction Motivating example Detailed outline How do DBMSs work? DDL, DML, views. Fundamental concepts DBMS users Overall system architecture Conclusions Faloutsos 15-415 60 20

Faloutsos 15-415 Overall system architecture [Users] DBMS query processor storage manager [Files] Faloutsos 15-415 61 naive app. pgmr casual DBA users app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 62 Overall system architecture query processor DML compiler embedded DML pre-compiler DDL interpreter Query evaluation engine Faloutsos 15-415 63 21

Faloutsos 15-415 Overall system architecture (cont d) storage manager authorization and integrity manager transaction manager buffer manager file manager Faloutsos 15-415 64 Overall system architecture (cont d) Files data files data dictionary = catalog (= meta-data) indices statistical data Faloutsos 15-415 65 Some examples: DBA doing a DDL (data definition language) operation, eg., create table student... Faloutsos 15-415 66 22

Faloutsos 15-415 naive app. pgmr casual DBA users app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 67 Some examples: casual user, asking for an update, eg.: update student set name to smith where ssn = 345 Faloutsos 15-415 68 naive app. pgmr casual DBA users app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 69 23

Faloutsos 15-415 naive app. pgmr casual DBA users app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 70 naive app. pgmr casual DBA users app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 71 Some examples: app. programmer, creating a report, eg main(){... exec sql select * from student... } Faloutsos 15-415 72 24

Faloutsos 15-415 naive app. pgmr casual DBA users pgm (src) app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 73 Some examples: naive user, running the previous app. Faloutsos 15-415 74 naive app. pgmr casual DBA users pgm (src) app. pgm(o) emb. DML DML proc. query eval. DDL int. query proc. trans. mgr buff. mgr file mgr storage mgr. data meta-data Faloutsos 15-415 75 25

Faloutsos 15-415 Introduction Motivating example Detailed outline How do DBMSs work? DDL, DML, views. Fundamental concepts DBMS users Overall system architecture Conclusions Faloutsos 15-415 76 Conclusions (relational) DBMSs: electronic record keepers customize them with create table commands ask SQL queries to retrieve info Faloutsos 15-415 77 Conclusions cont d main advantages over (flat) files & scripts: logical + physical data independence (ie., flexibility of adding new attributes, new tables and indices) concurrency control and recovery Faloutsos 15-415 78 26