Lecture 1: Introduction

Similar documents
Week 1 Part 1: An Introduction to Database Systems

Introduction to Database Systems. Chapter 1. Instructor: . Database Management Systems, R. Ramakrishnan and J. Gehrke 1

Introduction to Database Management Systems

Database Management Systems. Chapter 1

Introduction and Overview

Introduction to Database Systems CS432. CS432/433: Introduction to Database Systems. CS432/433: Introduction to Database Systems

Database Management Systems Chapter 1 Instructor: Oliver Schulte Database Management Systems 3ed, R. Ramakrishnan and J.

Introduction and Overview

Database. Università degli Studi di Roma Tor Vergata. ICT and Internet Engineering. Instructor: Andrea Giglio

Introduction to Data Management. Lecture #1 (Course Trailer )

Introduction to Data Management. Lecture #1 (Course Trailer ) Instructor: Chen Li

Introduction to Data Management. Lecture #1 (Course Trailer )

Database Management System

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 1-1

Introduction: Databases and. Database Users

BBM371- Data Management. Lecture 1: Course policies, Introduction to DBMS

Transaction Management Overview. Transactions. Concurrency in a DBMS. Chapter 16

Introduction: Databases and Database Users. Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Slide 1

Database Applications (15-415)

CS 443 Database Management Systems. Professor: Sina Meraji

Transaction Management Overview

Introduction to Data Management. Lecture #18 (Transactions)

Concurrency Control & Recovery

Database Management Systems. Syllabus. Instructor: Vinnie Costa

Chapter 1. Introduction of Database (from ElMasri&Navathe and my editing)

Concurrency Control & Recovery

Page 1. Goals for Today" What is a Database " Key Concept: Structured Data" CS162 Operating Systems and Systems Programming Lecture 13.

Chapter 1. Types of Databases and Database Applications. Basic Definitions. Introduction to Databases

CMPUT 291 File and Database Management Systems

A Few Tips and Suggestions. Database System II Preliminaries. Applications (contd.) Applications

Fall Semester 2002 Prof. Michael Franklin

A Few Tips and Suggestions. Database System I Preliminaries. Applications (contd.) Applications

Page 1. Quiz 18.1: Flow-Control" Goals for Today" Quiz 18.1: Flow-Control" CS162 Operating Systems and Systems Programming Lecture 18 Transactions"

A Few Tips and Suggestions. Database System II Preliminaries. Applications (contd.) Applications

COURSE 1. Database Management Systems

Introduction. Example Databases

Big Data Processing Technologies. Chentao Wu Associate Professor Dept. of Computer Science and Engineering

Announcements. PS 3 is out (see the usual place on the course web) Be sure to read my notes carefully Also read. Take a break around 10:15am

The Relational Model. Database Management Systems

Outline. Database Management Systems (DBMS) Database Management and Organization. IT420: Database Management and Organization

Database Management Systems MIT Introduction By S. Sabraz Nawaz

Intro to Transaction Management

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Database Management System

Overview of Transaction Management

Chapter 1: Introduction

Database Systems ( 資料庫系統 ) Practicum in Database Systems ( 資料庫系統實驗 ) 9/20 & 9/21, 2006 Lecture #1

Transaction Management and Concurrency Control. Chapter 16, 17

Introduction to Database Systems

DATABASE MANAGEMENT SYSTEMS. UNIT I Introduction to Database Systems

CMPT 354 Database Systems I. Spring 2012 Instructor: Hassan Khosravi

9/8/2018. Prerequisites. Grading. People & Contact Information. Textbooks. Course Info. CS430/630 Database Management Systems Fall 2018

CS430/630 Database Management Systems Spring, Betty O Neil University of Massachusetts at Boston

CS145: Intro to Databases. Lecture 1: Course Overview

Overview. Introduction to Transaction Management ACID. Transactions

CAS CS 460/660 Introduction to Database Systems. Fall

Database Applications (15-415)

Database Technology Introduction. Heiko Paulheim

Introduction to Data Management. Lecture #1 (The Course Trailer )

CS425 Fall 2016 Boris Glavic Chapter 1: Introduction

CSC 261/461 Database Systems Lecture 20. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101

1/19/2012. Finish Chapter 1. Workers behind the Scene. CS 440: Database Management Systems

Course Logistics & Chapter 1 Introduction

One Size Fits All: An Idea Whose Time Has Come and Gone

Introduction to Data Management. Lecture #24 (Transactions)

What are Transactions? Transaction Management: Introduction (Chap. 16) Major Example: the web app. Concurrent Execution. Web app in execution (CS636)

Introduction to Databases

CS564: Database Management Systems. Lecture 1: Course Overview. Acks: Chris Ré 1

Intro to Transactions

Transaction Management: Introduction (Chap. 16)

Introduction. Who wants to study databases?

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

Queries for Today. CS186: Introduction to Database Systems. What? Why? Who? How? For instance? Joe Hellerstein and Christopher Olston.

The Relational Data Model. Data Model

Introduction to Data Management. Lecture #25 (Transactions II)

Introduction to Data Management. Lecture #26 (Transactions, cont.)

Database Management Systems MIT Lesson 01 - Introduction By S. Sabraz Nawaz

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

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

SQL: Part III. Announcements. Constraints. CPS 216 Advanced Database Systems

CSE 544 Principles of Database Management Systems

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

CSE 3241: Database Systems I Databases Introduction (Ch. 1-2) Jeremy Morris

Transaction Management: Concurrency Control, part 2

Locking for B+ Trees. Transaction Management: Concurrency Control, part 2. Locking for B+ Trees (contd.) Locking vs. Latching

EECS 647: Introduction to Database Systems

Chapter 1 Introduction

MIT Database Management Systems Lesson 01: Introduction

Database System Concepts and Architecture. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

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

CS275 Intro to Databases. File Systems vs. DBMS. Why is a DBMS so important? 4/6/2012. How does a DBMS work? -Chap. 1-2

CSE 132A. Database Systems Principles

The functions performed by a typical DBMS are the following:

Introduction to Databases CS348

Data! CS 133: Databases. Goals for Today. So, what is a database? What is a database anyway? From the textbook:

Outline. Databases and DBMS s. Recent Database Applications. Earlier Database Applications. CMPSCI445: Information Systems.

Course Web Site. 445 Staff and Mailing Lists. Textbook. Databases and DBMS s. Outline. CMPSCI445: Information Systems. Yanlei Diao and Haopeng Zhang

Database System Concepts and Architecture

Introduction to Data Management. Lecture #2 Intro II & Data Models I

Administration Naive DBMS CMPT 454 Topics. John Edgar 2

Transcription:

CSCC43 Introduction to Databases Lecture 1: Introduction Lei Jiang (slides provided by Prof. John Mylopoulos) Outline Databases and DBMSs Data Models and Data Independence Database Transactions DBMS Languages Development of DBMSs 2

Databases and DBMSs What is a Database? Database Large, integrated collection of data. A database usually models a real-world enterprise. Entities (e.g., instructors, students, courses) Properties (e.g., student number 11111, course title cscc43) Relationships (e.g., Lei is teaching CSCC43) Examples Student, payroll, customer, product databases Scientific and medical databases You may not notice it, but databases are behind almost everything you do on the Web Google searches Queries at Amazon, ebay, etc. ROSI Other examples? 4

What is a DBMS Database Management System (DBMS) a software package designed to store and manage databases examples: PostgreSQL, MySQL, DB2, Oracle, MS Access 5 Why Use a DBMS? Provide data independence don t need to know implementation to access data Provide common data management services Find, update and modify data efficiently Optimize and execute queries Protect data (data quality, integrity, security, privacy, etc.) Enforce (certain) integrity constraints automatically Prevent unauthorized access (access control) Provide concurrent control to multiple programs or users Recover from crashes (failure recovery) Provide uniform data administration DBA 6

Data Models and DB Schemas Data Models and Database Schemas A data model is a collection of concepts for specifying: structure of data entity-relationship model = entity sets, etc. relational model = tables; semi-structured model = trees/graphs. operations on data create, update, query constraints on data rules which specify what is allowed and what isn t A database schema is a description of a particular collection of data, using a given data model. 8

Relational Model The relational model of data is the most widely used data model today. Main concept: mathematical concept of relation, basically a table with rows (tuples) and columns (attributes). Students Sid Name Login Age Gpa 00243 01786 02699 02439 Paolo Maria Klaus Eric pg mf klaus eric 21 20 19 19 4.0 3.6 3.4 3.1 Courses Cid Cname Credits csc340 csc343 ece268 csc324 Rqmts Engineering Databases Operating Systems Programming Langs 4 6 3 4 Relational Model Constraints integrity constraints, assertions e.g., key constraint, domain constraint, referential integrity constraint, cardinality constraint Operations on data query languages e.g., relational algebra, relational calculus, SQL To find all students who are 20 years old, we can write: SELECT * FROM Students WHERE age = 20

Levels of Data Abstraction Many views, single logical schema and physical schema. Views (external schemas) describe how users see the data. Logical schema defines logical structure. Physical schema describes the files and indexes used. View 1 View 2 View 3 Logical Schema Physical Schema 11 Example: University Database Logical schema: Student(sid: string, name: string, login: string, age: integer, gpa:real) Course(cid: string, cname:string, credits:integer) Enrolled(sid:string, cid:string, grade:string) describes data in terms of the data model of the DBMS Physical schema: Relations stored as unordered files. Index on first column of Students. External Schema (View): Course_info(cid:string,enrollment:integer) 12

Data Independence Applications insulated from how data is actually structured and stored: Logical data independence: Protection from changes to the logical schema. Query does not change when change the order of tuples add or modify other attributes Physical data independence: Protection from changes to the physical schema. Query does not change when add or modify indexes One of the most important benefits of using a DBMS! 13 Database Transactions

Database Transactions A transaction is an atomic sequence of database actions (read/write), I.e., it executes completely, or aborts leaving DB in a consistent state, if DB is consistent when transaction begins. Beyond this, the DBMS does not really understand the semantics of the data, e.g., how the interest on a bank account is computed. Thus, ensuring that a transaction (run alone) preserves consistency is ultimately the user s responsibility! 15 Concurrency Control Concurrent execution of user programs is essential for good DBMS performance. Because disk accesses are frequent, and relatively slow, it is important to keep the CPU humming by working on several user programs concurrently. Interleaving actions of different user programs can lead to inconsistency: e.g., cheque is cleared while account balance is being computed. DBMS ensures that such problems don t arise: users can pretend they are using a single-user system. 16

Scheduling Concurrent Transactions DBMS ensures that execution of {T 1,...,T n } is equivalent to some serial execution of T 1,...,T n. Before reading/writing a data object (for example, a table row), a transaction requests a lock on the object, and waits till the DBMS gives it the lock. All locks are released at the end of the transaction (Strict 2-phase locking protocol.) Idea: If an action of T i (say, writing X) affects T k (which perhaps reads X), one of them, say T i, will obtain the lock on X first and T k is forced to wait until T i completes; this effectively orders the transactions. What if T k already has a lock on Y and T i later requests a lock on Y? (Deadlock!) T i or T k is aborted and restarted! 17 Ensuring Atomicity DBMSs ensure atomicity (all-or-nothing property), even if system crashes in the middle of a transaction. Idea: Keep a log (history) of all actions carried out by the DBMS while executing a set of transactions: Before a change is made to the database, the corresponding log entry is forced to a safe location. (WAL protocol; OS support for this is often inadequate.) After a crash, the effects of partially executed transactions are undone using the log. (Thanks to WAL, if log entry wasn t saved before the crash, corresponding change was not applied to database!) 18

The Log The following actions are recorded in the log: T i writes an object: the old value and the new value; log record must go to disk before the changed page! T i commits/aborts: a log record indicating this action. Log records chained together by transaction id, so it s easy to undo a specific transaction (e.g., to resolve a deadlock). Log is often duplexed and archived on stable storage. All log related activities (and in fact, all CC-related activities such as lock/unlock, dealing with deadlocks etc.) are handled transparently by the DBMS. 19 Database Languages

Database Languages A DBMS supports several languages and several modes of use: Interactive textual query languages, such as SQL; Interactive commands embedded in a host programming language (Pascal, C, Cobol, Java, etc.) Interactive commands embedded in ad-hoc development languages (known as 4GL), usually with additional features (e.g., for the production of forms, menus, reports,...) Form-oriented, non-textual user-friendly languages such as QBE. 21 SQL, a Query Language Schemas Courses(Title, RoomCode, Instrutor) Rooms(Code, Building, Floor) Instances Courses Course Title RoomCode Instructor Net w or k s N3 Dann y S y ste m s Data b ases N3 G John Lei Query: list the title, room code and building of courses that are taught in a room which is located on the ground level SELECT Title, RoomCode, Building FROM Courses, Rooms WHERE RoomCode = Code AND Floor= Ground" Rooms Code Building Floor DS1 Ex -OMI Ground N3 Ex -OMI Ground G Science Third 22

Query Optimization Here are two possible execution plans for this query: SELECT Title, RoomCode, Building FROM Courses, Rooms WHERE RoomCode = Code c1 AND Floor= Ground" c2 Courses Rooms Course Title RmCodeInstructor RoomInstructor Code Building Floor Networks N3 Danny DS1 Ex-OMI Ground Systems N3 John N3 Ex-OMI Ground Databases G Lei G Science Third (P1) For each Courses row, find the (unique) corresponding Rooms row, check if it is at ground level and if so return a tuple; (P2) For each Rooms row at ground level, find all corresponding Courses rows, and return a tuple for each; P1 is much worse than P2 if there are many courses and few ground-floor rooms. A query optimizer keeps track of # of tuples in each relation, also selectivities for each attribute and generates an optimal execution plan. 23 SQL Embedded in Pascal 1. write( city name''?'); readln(city); 2. EXEC SQL DECLARE E CURSOR FOR 3. SELECT NAME, SALARY 4. FROM EMPLOYEES 5. WHERE CITY = :city ; 6. EXEC SQL OPEN E ; 7. EXEC SQL FETCH E INTO :name, :salary ; 8. while SQLCODE = 0 do begin 9. write( employee:', name, raise?'); 10. readln(raise); 11. EXEC SQL UPDATE PERSON SET SALARY=SALARY+:raise 12. WHERE CURRENT OF E 13. EXEC SQL FETCH E INTO :name, :salary 14. end; 15. EXEC SQL CLOSE CURSOR E 24

Form-Based Interface (in Access) Demo: A running MS Access example. 25 Development of DBMSs

Historical Development of Database Technology Early Database Applications: The Hierarchical and Network Models were introduced in mid 1960s and dominated during the seventies. Hierarchical database consists of hierarchical record structures; a field may have as value a list of records; every record has at most one parent A database now consists of records with pointers (links) to other records. Offers a navigational view of a database. Book Borrower B365 38 Elm Borrowing War & Peace $8.99 Toronto parent children Customer Customer 1::n link Order Order Ordered Ordered Part Part cycles of links are allowed Part Part Sales Sales History History Jan 28, 1994 Feb 24, 1994 Region Region 27 Historical Development of Database Technology (cont'd) Relational Model based Systems: Relational model was originally introduced in 1970, was heavily researched and experimented within IBM Research and several universities. Relational DBMS Products emerged in the early 1980s. Object-oriented and emerging applications: Object-Oriented Database Management Systems (OODBMSs) were introduced in late 1980s and early 1990s to cater to the need of complex data processing in CAD and other applications. Their use has not taken off much. Many relational DBMSs have incorporated object database concepts, leading to a new category called object-relational DBMSs (ORDBMSs) Extended relational systems add further capabilities (e.g. for multimedia data, XML, and other data types) 28

Historical Development of Database Technology (cont'd) Data on the Web and E-commerce Applications: Web contains data in HTML with links among pages. This has given rise to a new set of applications and E-commerce is using new standards like XML (extended Markup Language). Script programming languages such as PHP and JavaScript allow generation of dynamic Web pages that are partially generated from a database Also allow database updates through Web pages 29 Extending Database Capabilities New functionality is being added to DBMSs in the following areas: Scientific Applications XML (extensible Markup Language) Image Storage and Management Audio and Video Data Management Data Warehousing and Data Mining Spatial Data Management Time Series and Historical Data Management The above gives rise to new R & D in incorporating new data types, complex data structures, new operations and storage and indexing schemes in database systems. 30

Summary DBMSs are used to maintain and query large amount of data. Benefits include recovery from system crashes concurrent access quick application development data integrity and security A DBMS typically has a layered architecture. DBAs hold responsible jobs and are well-paid! monster.ca: A typical Database Administrator working in Ontario -- Toronto earns a median total cash compensation of $105,639, DBMS is one of the broadest, exciting areas in CS in terms of R&D. 31 CSC343 Introduction to Databases Lecture 1: Introduction Some additional slides 32

Do You Know SQL? Explain the difference between: SELECT b FROM R WHERE a < 10 OR a >= 10; and SELECT b FROM R; a b 1 20 2 30 3 40 R 33 And How About These? SELECT a FROM R, S WHERE R.b = S.b; SELECT a FROM R WHERE b IN (SELECT b FROM S); 34