Θεµελίωση Βάσεων εδοµένων

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Θεµελίωση Βάσεων εδοµένων"

Transcription

1 Θεµελίωση Βάσεων εδοµένων Βασίλης Βασσάλος 1 What do we need to produce good software? Good programmers, software engineers, project managers, business experts, etc. (People) Good software development methodologies and practices (Processes) Good programming languages, compilers, etc. (Tools) 2 1

2 What Is a Database? A very large, integrated collection of data It models a real-world enterprise Entities (e.g., customers, orders) Relationships (e.g., Joe Smith bought a Corvette) A Database Management System (DBMS) is a software package designed to store and manage databases Difficult software package (needs tending - DBA) Expensive software package 3 Databases and Database Management Database A structured collection of data and information about entities (things) of interest Database Management System: A software application with which you can create, store, organize and retrieve data from one or many databases E.g. Oracle, Sybase, Informix, DB2, Access Database Administrator: A person responsible for the development and management of an organization s databases 4 2

3 Why we need a DBMS A DBMS stores, manages and manipulates effectively and efficiently large amounts of data Most business processes and functions in big organizations generate, depend on, and use large amounts of data 5 A view of an ebookseller s customer-oriented IT infrastructure LAN Web Server Client HTML XML ISP T3 Telco DSL Web Client Personalization Application Server Search application http ISP T3 ISDN Web Client Transaction Monitor Community Server Shopping Bot http CableCo Web Client ODBC, SQL SQL ISP Internet http Wireless Provider Laptop Database Server DBMS Books CORBA XML Zshops Customer & order info Intranet Data Warehouse Check Inventory Levels OLAP Server Intelligent Agent Order Execution and Procurement System (*) Distributor Data mining guru Distributors Automated Warehouse Marketing 3

4 Two broad business uses for DBMS s Run the operational aspects of the business Order entry, payroll, inventory management, etc Online transaction processing Help with decision-making Measure the effectiveness of marketing campaigns, or find out the most profitable products Online decision support Uses are converging Supply chain execution 7 DBMS provides levels of abstraction Many views, a single conceptual (logical) schema and a physical schema Views describe how users see the data Conceptual schema defines logical structure Physical schema describes the files and indexes used View 1 View 2 View 3 Conceptual Schema Physical Schema Schemata are defined using DDL - Data Definition Language Data are modified/queried using DML - Data Manipulation Language 8 4

5 Example: Bookstore Database Conceptual schema: Customers(cid: string, name: string, address: string, sex: string, category:integer) Books(isbn: string, title:string, price:float) Sales(cid:string, isbn:string, pdate:date) Physical schema: Relations stored as unordered files Index on first column of Customers External Schema (View): TSalesPerBook(isbn:string,total_sales:float) Goodcustomers(cid:string,name:string) 9 Data Independence Applications insulated from how data are structured and stored Logical data independence: Protection from changes in logical structure of data Physical data independence: Protection from changes in physical structure of data One of the most important benefits of using a DBMS! 10 5

6 Database Development Process (Abstraction Revisited) Conceptual Data Modeling Diagram, Preliminary Model Technology Independent Example: Entity-Relationship Diagrams Decide what entities should be part of the database and what are the relations between them Logical Database Design Abstract model of database Relational: Tables Physical Database Design How database will be arranged technology dependent DBMS (Database Management System) Database Implementation Database Maintenance 11 Why we need a DBMS Concurrent access Recovery from crashes Focus of class Data integrity and security Preserve constraints on data, avoid corruption, control access Data independence Conceptual modeling should be independent of physical modeling Declarative language Efficient access Focus of class Uniform data administration Manage the individual accounts, the customer info, the business loans Reduced application development time 12 6

7 Example: Bookstore Database Conceptual schema: Customers(cid: string, name: string, address: string, sex: string, category:integer) Books(isbn: string, title:string, price:float) Sales(cid:string, isbn:string, pdate:date) Physical schema: Relations stored as unordered files Index on first column of Students External Schema (View): TSalesPerBook(isbn:string,total_sales:float) Goodcustomers(cid:string,name:string) 13 Data Models A data model is a vocabulary of primitives for describing data A schema is a description of a particular collection of data, using the a given data model The relational model of data is the most widely used model today Main primitive: relation, basically a table with rows and columns Every relation has a schema, which describes the columns, or fields Proposed by E.F. Codd in

8 Querying a Database Find how many customers have bought A random walk down Wall Street on 10/3/2002 S(tructured) Q(uery) L(anguage) select COUNT(P.cid) from Purchase P, Books B where P.isbn=B.isbn and P.date= 10/3/2002 and B.title= A random walk down Wall Street User asks for what they need Query processor figures out how to answer the query efficiently Declarative language 15 E-R Diagram Example: EverFail Car Owned by Customer Cust ID Model Name Make VIN Approves PartID Part Descr Part Price WorkID Parts Includes Work Workdescr LaborCharge 16 8

9 The Complete Relations for EverFail Car VIN, Model, Make, CustID Customer CustID, Name, Address, Phone Work WorkID, Workdescr, LaborCharge, CustID Parts PartsID, PartDescr, PartPrice PartsUsed WorkID, PartsID, Qty 17 Querying a relational database (S)tructured (Q)uery (L)anguage intergalactic dataspeak Basic SQL query SELECT [DISTINCT] target-list FROM relation-list WHERE qualification relation-list A list of relation names (possibly with a range-variable after each name). target-list A list of attributes of relations in relation-list qualification Comparisons (Attr op const or Attr1 op Attr2, where op is one of ) combined using AND, OR and NOT <, >, =,,, 18 9

10 What can we do? Retrieve a subset of rows ( selection ) Retrieve a subset of columns ( projection ) Connect relations (a join ) Union, intersect relations 19 Example We will use these instances of the Sailors and Reserves relations in our examples. bid is Boat-id If the key for the Reserves relation contained only the attributes sid and day, how would the semantics differ? S1 S2 R1 sid bid day /10/ /12/96 sid sname rating age 22 dustin lubber rusty sid sname rating age 28 yuppy lubber guppy rusty

11 Example Query SELECT S.sname FROM Sailors S, Reserves R WHERE S.sid=R.sid AND R.bid=103 (sid) sname rating age (sid) bid day 22 dustin /10/96 22 dustin /12/96 31 lubber /10/96 31 lubber /12/96 58 rusty /10/96 58 rusty /12/96 21 Conceptual Evaluation Strategy Compute the cross-product of relation-list All the ways to combine the tuples in the relations Discard resulting tuples if they fail qualifications Delete attributes that are not in target-list If DISTINCT is specified, eliminate duplicate rows This strategy is probably the least efficient way to compute a query! An optimizer will find more efficient strategies to compute the same answers 22 11

12 Find sailors who ve reserved at least one boat SELECT S.sid FROM Sailors S, Reserves R WHERE S.sid=R.sid What is the effect of replacing S.sid by S.sname in the SELECT clause? Would adding DISTINCT to this variant of the query make a difference? 23 Find the age of the youngest sailor for each rating with age 18 SELECT S.rating, MIN (S.age) FROM Sailors S WHERE S.age >= 18 GROUP BY S.rating Only S.rating and S.age are mentioned in the SELECT and GROUP BY clauses; other attributes `unnecessary 2nd column of result is unnamed sid sname rating age 22 dustin lubber zorba horatio brutus rusty rating age Answer relation rating

13 Conceptual Evaluation The cross-product of relation-list is computed, tuples that fail qualification are discarded, `unnecessary fields are deleted, and the remaining tuples are partitioned into groups by the value of attributes in grouping-list The group-qualification is then applied to eliminate some groups. Expressions in group-qualification must have a single value per group! One answer tuple is generated per qualifying group. 25 Triggers Trigger: procedure that starts automatically if specified changes occur to the DBMS Three parts: Event (activates the trigger) Condition (tests whether the triggers should run) Action (what happens if the trigger runs) Turns the database into an active component E.g., alert (or act!) when inventory is low Help with decision-support 26 13

14 SQL examples Find sailors who have reserved boat 103 SELECT S.sname FROM Sailors S WHERE EXISTS (SELECT * FROM Reserves R WHERE R.bid=103 AND S.sid=R.sid)7 Find sid s of sailors who ve reserved both a red and a green boat: SELECT S.sid FROM Sailors S, Boats B, Reserves R WHERE S.sid=R.sid AND R.bid=B.bid AND B.color= red AND S.sid IN (SELECT S2.sid FROM Sailors S2, Boats B2, Reserves R2 WHERE S2.sid=R2.sid AND R2.bid=B2.bid AND B2.color= green ) 27 Isn t Implementing a Database System Simple? Relations Statements Results 28 14

15 Introducing the Database Management System The latest from Megatron Labs Incorporates latest relational technology UNIX compatible 29 Megatron 3000 Implementation Details Relations stored in files (ASCII) e.g., relation R is in /usr/db/r Smith # 123 # CS Jones # 522 # EE

16 Megatron 3000 Implementation Details Directory file (ASCII) in /usr/db/directory R1 # A # INT # B # STR R2 # C # STR # A # INT. 31 Megatron 3000 Sample Sessions % MEGATRON3000 Welcome to MEGATRON 3000! &. & quit % 32 16

17 Megatron 3000 Sample Sessions & select * from R # & Relation R A B C SMITH 123 CS 33 Megatron 3000 Sample Sessions & select A,B from R,S where R.A = S.A and S.C > 100 # & A B 123 CAR 522 CAT 34 17

18 Megatron 3000 Sample Sessions & select * from R LPR # & Result sent to LPR (printer). 35 Megatron 3000 Sample Sessions & select * from R where R.A < 100 T # & New relation T created

19 Megatron 3000 To execute select * from R where condition : (1) Read dictionary to get R attributes (2) Read R file, for each line: (a) Check condition (b) If OK, display 37 Megatron 3000 To execute select * from R where condition T : (1) Process select as before (2) Write results to new file T (3) Append new line to dictionary 38 19

20 Megatron 3000 To execute select A,B from R,S where condition : (1) Read dictionary to get R,S attributes (2) Read R file, for each line: (a) Read S file, for each line: (i) Create join tuple (ii) Check condition (iii) Display if OK 39 What s wrong with the Megatron 3000 DBMS? 40 20

21 What s wrong with the Megatron 3000 DBMS? Tuple layout on disk e.g., - Change string from Cat to Cats and we have to rewrite file - ASCII storage is expensive - Deletions are expensive 41 What s wrong with the Megatron 3000 DBMS? Search expensive; no indexes e.g., - Cannot find tuple with given key quickly - Always have to read full relation 42 21

22 What s wrong with the Megatron 3000 DBMS? Brute force query processing e.g., select * from R,S where R.A = S.A and S.B > Do select first? - More efficient join? 43 What s wrong with the Megatron 3000 DBMS? No buffer manager e.g., Need caching No concurrency control No reliability e.g., - Can lose data - Can leave operations half done No security e.g., - File system insecure - File system security is coarse No application program interface (API) e.g., How can a payroll program get at the data? No interoperability with other databases Poor dictionary facilities No GUI 44 22

23 System Structure Strategy Selector Query Parser User User Transaction Transaction Manager Concurrency Control Buffer Manager Recovery Manager Lock Table File Manager M.M. Buffer Log Statistical Data Indexes User Data System Data 45 Some Terms Database system Transaction processing system File access system Information retrieval system 46 23

24 ιαδικαστικά Μάθηµα: Πέµπτη 12-3, αίθουσα 606 ιάλειµµα 15, ~1:40 «Γραφείο»: Εργ. Τεχνητής Νοηµοσύνης, 4ος όροφος Αντωνιάδου, τηλ 160 Ώρες γραφείου: Τρίτη/Πέµπτη 3:30-4:30, άλλες ώρες µε ραντεβού Βοηθός: Μάγδα Ειρηνάκη «Γραφείο»: 3ος όροφος, Κορδιγκτώνος 12 Ώρες γραφείου: Τετάρτη οµή µαθήµατος υο εργασίες: 15% του βαθµού Χρήση online συστήµατος για τις εργασίες Τελικό διαγώνισµα: 85% του βαθµού Προαιρετική βιβλιογραφική εργασία: 10% bonus ιαφάνειες του µαθήµατος διαθέσιµες στο Κυρίως στα αγγλικά 48 24

25 Ύλη µαθήµατος Εισαγωγή Ευρετήρια και κατακερµατισµός (Indexes and hashing) Επεξεργασία και βελτιστοποίηση επερωτήσεων (Query processing and optimization) Ανάνηψη (Crash Recovery) Θεωρία Ταυτοχρονισµού (Concurrency Control theory) Επεξεργασία οσοληψιών (Transaction processing) Συµπερασµατικές και Λογικές Βάσεις εδοµένων (Deductive and Logic Databases) Ενεργές Βάσεις εδοµένων (Active Data Bases) Αποθήκες εδοµένων (Data Warehouses) 49 Acknowledgement Slides mostly based on the ones provided by Hector Garcia Molina Thanks! 50 25

SQL: Queries, Programming, Triggers

SQL: Queries, Programming, Triggers SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in

More information

Example Instances. SQL: Queries, Programming, Triggers. Conceptual Evaluation Strategy. Basic SQL Query. A Note on Range Variables

Example Instances. SQL: Queries, Programming, Triggers. Conceptual Evaluation Strategy. Basic SQL Query. A Note on Range Variables SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Example Instances We will use these instances of the Sailors and Reserves relations in our

More information

SQL: Queries, Programming, Triggers. Instructor: Alessandra La Spina

SQL: Queries, Programming, Triggers. Instructor: Alessandra La Spina SQL: Queries, Programming, Triggers Instructor: Alessandra La Spina laspina@dm.unipi.it SQL Data Definition Language (DDL): subset of SQL that supports creation, deletion, and modification of definitions

More information

SQL: Queries, Programming, Triggers

SQL: Queries, Programming, Triggers SQL: Queries, Programming, Triggers CSC343 Introduction to Databases - A. Vaisman 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for

More information

SQL: Queries, Constraints, Triggers

SQL: Queries, Constraints, Triggers SQL: Queries, Constraints, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Example Instances We will use these instances of the Sailors and Reserves relations in our

More information

Database Systems. Course Administration

Database Systems. Course Administration Database Systems ( ) September 27, 200 Lecture # By Hao-hua Chu ( ) 1 Course Administration Assignment #1 is due today. Assignment #2 is out on the home webpage. It is due one week from today. Next week

More information

Database Systems I. SQL Queries

Database Systems I. SQL Queries Database Systems I SQL Queries CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 90 Introduction We now introduce SQL, the standard query language for relational DBS. As RA, an SQL query takes

More information

SQL: Queries, Constraints, Triggers. Basic SQL Query. Conceptual Evaluation Strategy. A Note on Range Variables. Example of Conceptual Evaluation

SQL: Queries, Constraints, Triggers. Basic SQL Query. Conceptual Evaluation Strategy. A Note on Range Variables. Example of Conceptual Evaluation SQL: Queries, Constraints, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in

More information

Relational Algebra and SQL

Relational Algebra and SQL Relational Algebra and SQL Johannes Gehrke johannes@cs.cornell.edu http://www.cs.cornell.edu/johannes Slides from Database Management Systems, 3 rd Edition, Ramakrishnan and Gehrke. Database Management

More information

Overview. Key Features. Some Facts. DB2 Objects. Data Storage Structure: Tablespace

Overview. Key Features. Some Facts. DB2 Objects. Data Storage Structure: Tablespace Overview IBM DB2 UDB Background Key Features User Tools DB2 advantages/disadvantages Pricing Future of DB2 References Database Management Systems 1 Database Management Systems 2 Some Facts DB2 UDB suports

More information

GROUP BY and HAVING. SELECT MIN (S.age) FROM Sailors S WHERE S.rating = i. For i = 1, 2,..., 10:

GROUP BY and HAVING. SELECT MIN (S.age) FROM Sailors S WHERE S.rating = i. For i = 1, 2,..., 10: SQL - 4 Week 9 GROUP BY and HAVING So far, we ve applied aggregate operators to all (qualifying) tuples. Sometimes, we want to apply them to each of several groups of tuples. Consider: Find the age of

More information

Basic form of SQL Queries

Basic form of SQL Queries SQL - 1 Week 6-1 Basic form of SQL Queries SELECT FROM WHERE target-list relation-list qualification target-list A list of attributes of output relations in relation-list relation-list A list of relation

More information

Example Instances. SQL: Queries, Constraints, Triggers. Basic SQL Query. Conceptual Evaluation Strategy. A Note on Range Variables

Example Instances. SQL: Queries, Constraints, Triggers. Basic SQL Query. Conceptual Evaluation Strategy. A Note on Range Variables SQL: Queries, Constraints, Triggers Chapter 5 1 Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for the Reserves relation contained only

More information

Chapter 5. SQL: Queries, Constraints, Triggers

Chapter 5. SQL: Queries, Constraints, Triggers Chapter 5 SQL: Queries, Constraints, Triggers 1 Overview: aspects of SQL DML: Data Management Language. Pose queries (Ch. 5) and insert, delete, modify rows (Ch. 3) DDL: Data Definition Language. Creation,

More information

Basic SQL Query SQL. SQL Query. Conceptual Evaluation Strategy. Example of Conceptual Evaluation. A Slightly Modified Query

Basic SQL Query SQL. SQL Query. Conceptual Evaluation Strategy. Example of Conceptual Evaluation. A Slightly Modified Query Basic SQL Query SQL SELECT FROM [WHERE [DISTINCT] target-list relation-list condition] SELECT S.Name WHERE S.Age > 25 SELECT DISTINCT S.Name WHERE S.Age > 25 Default is that duplicates are not eliminated!

More information

SQL: Queries, Programming, Triggers

SQL: Queries, Programming, Triggers SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Example Instances We will use these instances of the Sailors and Reserves relations in our examples.

More information

SQL: The Query Language Part 2. Example Instances. Conceptual Evaluation. sid bid day /10/ /12/96. Queries With GROUP BY

SQL: The Query Language Part 2. Example Instances. Conceptual Evaluation. sid bid day /10/ /12/96. Queries With GROUP BY SQL: The Query Language Part Lecture 10 R & G - Chapter 5 The important thing is not to stop questioning. Albert Einstein Reserves Example Instances Sailors Boats Queries With GROUP BY To generate values

More information

Rika Yunitarini M.Kautsar Sophan

Rika Yunitarini M.Kautsar Sophan SQL Part 1 Rika Yunitarini M.Kautsar Sophan Intro Structured Query Language (SQL) is the most widely used commercial relational database language. Intro The SQL language has several aspects to it: 1. The

More information

The Database Language SQL (iii)

The Database Language SQL (iii) ICS 321 Spring 2012 The Database Language SQL (iii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 03/05/2012 Lipyeow Lim -- University of Hawaii at Manoa

More information

CSCI-GA Database Systems. Mohamed Zahran (aka Z)

CSCI-GA Database Systems. Mohamed Zahran (aka Z) CSCI-GA.2433-001 Database Systems Lecture 5: SQL I Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com SQL? Structured query language Originally developed by IBM It is now de facto standard.

More information

Rika Yunitarini M.Kautsar Sophan

Rika Yunitarini M.Kautsar Sophan SQL Part 2 Rika Yunitarini M.Kautsar Sophan Intro One of the most powerful features of SQL is nested queries. A nested query is a query that has another query embedded within it; the embedded query is

More information

Introduction to SQL and the Relational Model

Introduction to SQL and the Relational Model Introduction to SQL and the Relational Model Data Boot Camp! May 20, 2014 Michael Cafarella 5/20/14 1 Relational Databases The most common kind is a relational database The software is called a Relational

More information

CS275 Intro to Databases SQL SQL 10/18/2012. SQL Chap.5. Structured Query Language (SQL) Select Insert Update Delete

CS275 Intro to Databases SQL SQL 10/18/2012. SQL Chap.5. Structured Query Language (SQL) Select Insert Update Delete CS275 Intro to Databases SQL Chap.5 SQL Structured Query Language (SQL) Widely used SQL:2011 is the latest standard Select Insert Update Delete SQL 1 Select Basic form [DISTINCT] select list FROM from

More information

SQL. UVic C SC 370. Dr. Daniel M. German Department of Computer Science. June 3, 2004 Version: SQL (1.1.2) CSC 370

SQL. UVic C SC 370. Dr. Daniel M. German Department of Computer Science. June 3, 2004 Version: SQL (1.1.2) CSC 370 SQL UVic C SC 370 Dr. Daniel M. German Department of Computer Science June 3, 2004 Version: 1.1.2 5 1 SQL (1.1.2) CSC 370 dmgerman@uvic.ca Overview A review of SQL Basic Select statements UNION, INTERSECT,

More information

MIS Database Systems SQL: Queries, Constraints, Triggers

MIS Database Systems SQL: Queries, Constraints, Triggers MIS 335 - Database Systems SQL: Queries, Constraints, Triggers http://www.mis.boun.edu.tr/durahim/ Ahmet Onur Durahim Learning Objectives Basics of SQL Conceptual Evaluation of SQL Queries Range Variables,

More information

CS 542: Distributed Database Systems

CS 542: Distributed Database Systems CS 542: Distributed Database Systems Relational Database Overview Prof. Chris Clifton 14 January 2009 Based on 3 Key Features Simple data structures: 2-dimensional tables physical data independence Solid

More information

Relational Algebra and Calculus

Relational Algebra and Calculus Relational Algebra and Calculus UVic C SC 370 Daniel M German Relational Algebra and Calculus (1.2.0) CSC 370 8/5/2005 22:36 p.1/29 Overview The mathematical foundation of query languages such as SQL Relational

More information

sid sname rating age sid bid day bid bname Color

sid sname rating age sid bid day bid bname Color SQL - 2 Week 6-2 Sailors sid sname rating age 22 Dustin 7 45.0 29 Brutus 1 33.0 31 Lubber 8 55.5 32 Andy 8 25.5 58 Rusty 10 35.0 64 Horatio 7 35.0 71 Zorba 10 16.0 74 Horatio 9 35.0 85 Art 3 25.5 95 Bob

More information

Relational Algebra. CS430/630 Lecture 2. Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke

Relational Algebra. CS430/630 Lecture 2. Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Relational Algebra CS430/630 Lecture 2 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Relational Query Languages Query languages: Allow manipulation and retrieval of data

More information

Chapter 5 SQL: QUERIES, CONSTRAINTS, TRIGGERS INTRODUCTION

Chapter 5 SQL: QUERIES, CONSTRAINTS, TRIGGERS INTRODUCTION Chapter 5 SQL: QUERIES, CONSTRAINTS, TRIGGERS 1 INTRODUCTION - The current presentation is consistent with both SQL-92 and SQL: 99 (differences will be noted when necessary). - We shall cover - query capabilities

More information

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

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML? CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 Introduction to Databases CS2 Spring 2005 (LN5) 1 Why databases? Why not use XML? What is missing from XML: Consistency

More information

Boats bid bname color 101 Interlake blue 102 Interlake red 103 Clipper green 104 Marine red. Figure 1: Instances of Sailors, Boats and Reserves

Boats bid bname color 101 Interlake blue 102 Interlake red 103 Clipper green 104 Marine red. Figure 1: Instances of Sailors, Boats and Reserves Tutorial 5: SQL By Chaofa Gao Tables used in this note: Sailors(sid: integer, sname: string, rating: integer, age: real); Boats(bid: integer, bname: string, color: string); Reserves(sid: integer, bid:

More information

QUERIES, PROGRAMMING, TRIGGERS

QUERIES, PROGRAMMING, TRIGGERS 5 SQL: QUERIES, PROGRAMMING, TRIGGERS What men or gods are these? What maidens loth? What mad pursuit? What struggle to escape? What pipes and timbrels? What wild ecstasy? What is the average salary in

More information

Relational Algebra. Yanlei Diao UMass Amherst 9/22/09. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Relational Algebra. Yanlei Diao UMass Amherst 9/22/09. Slides Courtesy of R. Ramakrishnan and J. Gehrke Relational Algebra Yanlei Diao UMass Amherst 9/22/09 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Outline Conceptual Design: ER model Logical Design: ER to relational model Querying and manipulating

More information

Relational Algebra. Relational Query Languages

Relational Algebra. Relational Query Languages Relational Algebra Chapter 4 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational

More information

Relational Algebra. Relational Query Languages. Formal Relational Query Languages. Chapter 4, Part A

Relational Algebra. Relational Query Languages. Formal Relational Query Languages. Chapter 4, Part A Relational Algebra Chapter 4, Part A Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database.

More information

Relational Algebra. Chapter 4, Part A

Relational Algebra. Chapter 4, Part A Relational Algebra Chapter 4, Part A 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Strong formal

More information

Relational Algebra. Module 3, Lecture 1. Database Management Systems, R. Ramakrishnan 1

Relational Algebra. Module 3, Lecture 1. Database Management Systems, R. Ramakrishnan 1 Relational Algebra Module 3, Lecture 1 Database Management Systems, R. Ramakrishnan 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model

More information

Database Management Systems. Chapter 1

Database Management Systems. Chapter 1 Database Management Systems Chapter 1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2 What Is a Database/DBMS? A very large, integrated collection of data. Models real-world scenarios

More information

Introduction to Databases

Introduction to Databases Page 1 of 5 Introduction to Databases An introductory example What is a database? Why do we need Database Management Systems? The three levels of data abstraction What is a Database Management System?

More information

Relational Algebra. Instructor: Alessandra La Spina

Relational Algebra. Instructor: Alessandra La Spina Relational Algebra Instructor: Alessandra La Spina laspina@dm.unipi.it Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple,

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Database System Concepts, 5th Ed. See www.db book.com for conditions on re use Chapter 1: Introduction Purpose of Database Systems View of Data Database Languages Relational Databases

More information

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

Chapter 1: Introduction. Database Management System (DBMS) University Database Example This image cannot currently be displayed. Chapter 1: Introduction Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Database Management System (DBMS) DBMS contains information

More information

The Relational Model of Data (i)

The Relational Model of Data (i) ICS 321 Spring 2013 The Relational Model of Data (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1/14/2013 Lipyeow Lim -- University of Hawaii at Manoa

More information

1 File Processing Systems

1 File Processing Systems COMP 378 Database Systems Notes for Chapter 1 of Database System Concepts Introduction A database management system (DBMS) is a collection of data and an integrated set of programs that access that data.

More information

CSE 562 Database Systems

CSE 562 Database Systems UB CSE Database Courses CSE 562 Database Systems CSE 462 Database Concepts Introduction CSE 562 Database Systems Some slides are based or modified from originals by Database Systems: The Complete Book,

More information

Relational Query Languages. Relational Algebra. Formal Relational Query Languages. Preliminaries. Example Instances. Relational Algebra

Relational Query Languages. Relational Algebra. Formal Relational Query Languages. Preliminaries. Example Instances. Relational Algebra Relational Query Languages Relational Algebra Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Strong formal foundation based on

More information

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries COMP 5138 Relational Database Management Systems Week 5 : Basic COMP5138 "Relational Database Managment Systems" J. Davis 2006 5-1 Today s Agenda Overview Basic Queries Joins Queries Aggregate Functions

More information

Relational Algebra and Calculus. Relational Query Languages

Relational Algebra and Calculus. Relational Query Languages Relational Algebra and Calculus Chapter 4 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database.

More information

CS 220 Relational Algebra 2/3/2015

CS 220 Relational Algebra 2/3/2015 CS 220 Relational Algebra 2/3/2015 Relational Query Languages Query = retrieval program Language examples: Theoretical: 1. Relational Algebra 2. Relational Calculus a. tuple relational calculus (TRC) b.

More information

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

BBM371- Data Management. Lecture 1: Course policies, Introduction to DBMS BBM371- Data Management Lecture 1: Course policies, Introduction to DBMS 4.10.2016 Today Introduction About the class Organization of this course Introduction to DBMS Reference Book Database Management

More information

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

Topics. Introduction to Database Management System. What Is a DBMS? DBMS Types Introduction to Database Management System Linda Wu (CMPT 354 2004-2) Topics What is DBMS DBMS types Files system vs. DBMS Advantages of DBMS Data model Levels of abstraction Transaction management DBMS

More information

Overview of Query Evaluation. Overview of Query Evaluation

Overview of Query Evaluation. Overview of Query Evaluation Overview of Query Evaluation Chapter 12 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Overview of Query Evaluation Plan: Tree of R.A. ops, with choice of alg for each op. Each operator

More information

3. Relational Model and Relational Algebra

3. Relational Model and Relational Algebra ECS-165A WQ 11 36 3. Relational Model and Relational Algebra Contents Fundamental Concepts of the Relational Model Integrity Constraints Translation ER schema Relational Database Schema Relational Algebra

More information

UNIT 6. Structured Query Language (SQL) Text: Chapter 5

UNIT 6. Structured Query Language (SQL) Text: Chapter 5 UNIT 6 Structured Query Language (SQL) Text: Chapter 5 Learning Goals Given a database (a set of tables ) you will be able to express a query in SQL, involving set operators, subqueries and aggregations

More information

Databases and BigData

Databases and BigData Eduardo Cunha de Almeida eduardo.almeida@uni.lu Outline of the course Introduction Database Systems (E. Almeida) Distributed Hash Tables and P2P (C. Cassagnes) NewSQL (D. Kim and J. Meira) NoSQL (D. Kim)

More information

CSCI-GA Database Systems. Mohamed Zahran (aka Z)

CSCI-GA Database Systems. Mohamed Zahran (aka Z) CSCI-GA.2433-001 Database Systems Lecture 6: SQL II Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Aggregate Operators Powerful class of constructs to calculate aggregate values. Useful

More information

BCA. Database Management System

BCA. Database Management System BCA IV Sem Database Management System Multiple choice questions 1. A Database Management System (DBMS) is A. Collection of interrelated data B. Collection of programs to access data C. Collection of data

More information

Relational Query Languages. Relational Algebra. Preliminaries. Formal Relational Query Languages. Example Instances. Relational Algebra

Relational Query Languages. Relational Algebra. Preliminaries. Formal Relational Query Languages. Example Instances. Relational Algebra Relational Algebra Lecture 9 R &G, Chapter 4 By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental

More information

Database Systems. Lecture 1: Introduction

Database Systems. Lecture 1: Introduction Database Systems Lecture 1: Introduction General Information Professor: Leonid Libkin Contact: libkin@ed.ac.uk Lectures: Tuesday, 11:10am 1 pm, AT LT4 Website: http://homepages.inf.ed.ac.uk/libkin/teach/dbs09/index.html

More information

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

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added? DBMS Questions 1.) Which type of file is part of the Oracle database? A.) B.) C.) D.) Control file Password file Parameter files Archived log files 2.) Which statements are use to UNLOCK the user? A.)

More information

Introduction to Database Systems. Module 1, Lecture 1. Instructor: Raghu Ramakrishnan raghu@cs.wisc.edu UW-Madison

Introduction to Database Systems. Module 1, Lecture 1. Instructor: Raghu Ramakrishnan raghu@cs.wisc.edu UW-Madison Introduction to Database Systems Module 1, Lecture 1 Instructor: Raghu Ramakrishnan raghu@cs.wisc.edu UW-Madison Database Management Systems, R. Ramakrishnan 1 What Is a DBMS? A very large, integrated

More information

ECS 165A: Introduction to Database Systems

ECS 165A: Introduction to Database Systems ECS 165A: Introduction to Database Systems Todd J. Green based on material and slides by Michael Gertz and Bertram Ludäscher Winter 2011 Dept. of Computer Science UC Davis ECS-165A WQ 11 1 1. Introduction

More information

Chapter 2 Database System Concepts and Architecture

Chapter 2 Database System Concepts and Architecture Chapter 2 Database System Concepts and Architecture Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Outline Data Models, Schemas, and Instances Three-Schema Architecture

More information

Overview of Data Management

Overview of Data Management Overview of Data Management Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2015 CS 348 (Intro to DB Mgmt) Overview of Data Management

More information

The Relational Model. Module 1, Lecture 2. Database Management Systems, R. Ramakrishnan 1

The Relational Model. Module 1, Lecture 2. Database Management Systems, R. Ramakrishnan 1 The Relational Model Module 1, Lecture 2 Database Management Systems, R. Ramakrishnan 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy

More information

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

ICOM 6005 Database Management Systems Design. Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 August 23, 2001 ICOM 6005 Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 August 23, 2001 Readings Read Chapter 1 of text book ICOM 6005 Dr. Manuel

More information

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

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1 The Relational Model Ramakrishnan&Gehrke, Chapter 3 CS4320 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models

More information

Still More Operators: Outer Join

Still More Operators: Outer Join Still More Operators: Outer Join outer join is an extension of the join operation to deal with missing information three types: left outer join, right outer join, and full outer join left outer join computes

More information

Steps in Query Processing Query Query Parser Parsed query. Query Evaluation and Optimization. An Overview. Plan Generator

Steps in Query Processing Query Query Parser Parsed query. Query Evaluation and Optimization. An Overview. Plan Generator Query Evaluation and Optimization An Overview Web Forms Application FEs SQL Interface Plan Executor Operator Evaluator Parser Optimizer Query Evaluation Engine Concurrency Control Transaction Manager Lock

More information

Null Values. SQL Constraints

Null Values. SQL Constraints Null Values. SQL Constraints CS430/630 Lecture 10 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Null Values Field values in a tuple may sometimes be unknown: e.g., a rating

More information

Ques 1. Define dbms and file management system? Ans- Database management system (DBMS) A file management system

Ques 1. Define dbms and file management system? Ans- Database management system (DBMS) A file management system UNIT-1 Ques 1. Define dbms and file management system? Ans- Database management system (DBMS) is a collection of interrelated data and a set of programs to access those data. Some of the very well known

More information

Overview of Database Management

Overview of Database Management Overview of Database Management M. Tamer Özsu David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Fall 2012 CS 348 Overview of Database Management

More information

CSE 132A. Database Systems Principles

CSE 132A. Database Systems Principles CSE 132A Database Systems Principles Prof. Victor Vianu 1 Data Management An evolving, expanding field: Classical stand-alone databases (Oracle, DB2, SQL Server) Computer science is becoming data-centric:

More information

Relational Query Optimization 2

Relational Query Optimization 2 Relational Query Optimization 2 R&G - Chapter 14 For ease and speed in doing a thing do not give the work lasting solidity or exactness of beauty. Plutarch, Life of Pericles Query Optimization Query can

More information

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

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations 1 Topics for this week: 1. Good Design 2. Functional Dependencies 3. Normalization Readings for this week: 1. E&N, Ch. 10.1-10.6; 12.2 2. Quickstart, Ch. 3 3. Complete the tutorial at http://sqlcourse2.com/

More information

METU Department of Computer Eng. Ceng 302 Introduction to DBMS. Basic Concepts. by Pinar Senkul. resources: mostly froom Elmasri, Navathe

METU Department of Computer Eng. Ceng 302 Introduction to DBMS. Basic Concepts. by Pinar Senkul. resources: mostly froom Elmasri, Navathe METU Department of Computer Eng Ceng 302 Introduction to DBMS Basic Concepts by Pinar Senkul resources: mostly froom Elmasri, Navathe and other books Data Models Data Model: A set of concepts to describe

More information

SQL Queries and Subqueries Zaki Malik September Sept 04, 2008

SQL Queries and Subqueries Zaki Malik September Sept 04, 2008 SQL Queries and Subqueries Zaki Malik September 04, 2008 Basic SQL Query SELECT [DISTINCT] target list FROM relation list WHERE qualification; Relation list: A list of relation names (possibly with range

More information

Relational Calculus. Chapter Comp 521 Files and Databases Spring

Relational Calculus. Chapter Comp 521 Files and Databases Spring Relational Calculus Chapter 4.3-4.5 Comp 521 Files and Databases Spring 2010 1 Relational Calculus Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus has

More information

Overview of Database Systems. Kanda Runapongsa Dept of Computer Engineering Khon Kaen University

Overview of Database Systems. Kanda Runapongsa Dept of Computer Engineering Khon Kaen University Overview of Database Systems Kanda Runapongsa (krunapon@kku.ac.th) Dept of Computer Engineering Khon Kaen University Overview What is a Database, in particular, a relational DBMS? Why should we consider

More information

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

Overview. Introduction to Database Systems. Motivation... Motivation: how do we store lots of data? Introduction to Database Systems UVic C SC 370 Overview What is a DBMS? what is a relational DBMS? Why do we need them? How do we represent and store data in a DBMS? How does it support concurrent access

More information

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

Introduction. Introduction: Database management system. Introduction: DBS concepts & architecture. Introduction: DBS versus File system Introduction: management system Introduction s vs. files Basic concepts Brief history of databases Architectures & languages System User / Programmer Application program Software to process queries Software

More information

Chapter 1: Introduction. Database Management System (DBMS)

Chapter 1: Introduction. Database Management System (DBMS) Chapter 1: Introduction Purpose of Database Systems View of Data Data Models Data Definition Language Data Manipulation Language Transaction Management Storage Management Database Administrator Database

More information

Introduction: Database management system

Introduction: Database management system Introduction Databases vs. files Basic concepts Brief history of databases Architectures & languages Introduction: Database management system User / Programmer Database System Application program Software

More information

Database System Concepts

Database System Concepts s Design Chapter 1: Introduction Departamento de Engenharia Informática Instituto Superior Técnico 1 st Semester 2008/2009 Slides (fortemente) baseados nos slides oficiais do livro c Silberschatz, Korth

More information

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203.

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : II / III Section : CSE - 1 & 2 Subject Code : CS 6302 Subject Name : Database

More information

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

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2016 1 Why Study the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, etc. It is simple,

More information

www.gr8ambitionz.com

www.gr8ambitionz.com Data Base Management Systems (DBMS) Study Material (Objective Type questions with Answers) Shared by Akhil Arora Powered by www. your A to Z competitive exam guide Database Objective type questions Q.1

More information

Introduction to database management systems

Introduction to database management systems Introduction to database management systems Database management systems module Myself: researcher in INRIA Futurs, Ioana.Manolescu@inria.fr The course: follows (part of) the book "", Fourth Edition Abraham

More information

DBMS Interview Questions

DBMS Interview Questions DBMS Interview Questions 1. What is database? A database is a collection of information that is organized. So that it can easily be accessed, managed, and updated. 2. What is DBMS? DBMS stands for Database

More information

Query Optimization. From Chapter 15. Database Management Systems, R. Ramakrishnan and Johannes Gehrke

Query Optimization. From Chapter 15. Database Management Systems, R. Ramakrishnan and Johannes Gehrke Query Optimization From Chapter 15 Schema for Examples Sailors (sid: integer, sname: string, rating: integer, age: real) Reserves (sid: integer, bid: integer, day: dates, rname: string) Reserves: Each

More information

The Relational Model. Why Study the Relational Model?

The Relational Model. Why Study the Relational Model? The Relational Model Chapter 3 Instructor: Vladimir Zadorozhny vladimir@sis.pitt.edu Information Science Program School of Information Sciences, University of Pittsburgh 1 Why Study the Relational Model?

More information

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

æ A collection of interrelated and persistent data èusually referred to as the database èdbèè. CMPT-354-Han-95.3 Lecture Notes September 10, 1995 Chapter 1 Introduction 1.0 Database Management Systems 1. A database management system èdbmsè, or simply a database system èdbsè, consists of æ A collection

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Purpose of Database Systems View of Data Data Models Data Definition Language Data Manipulation Language Transaction Management Storage Management Database Administrator Database

More information

DATABASE SYSTEM OVERVIEW

DATABASE SYSTEM OVERVIEW DATABASE SYSTEM OVERVIEW 1. Database System (DBS) Definition: Database Management System (DBMS) + Database. DBMS: Computer Software for storage, access, and manipulation of data. Database: Collection of

More information

Basic Concepts of Database Systems

Basic Concepts of Database Systems CS2501 Topic 1: Basic Concepts 1.1 Basic Concepts of Database Systems Example Uses of Database Systems - account maintenance & access in banking - lending library systems - airline reservation systems

More information

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

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World COSC 304 Introduction to Systems Introduction Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca What is a database? A database is a collection of logically related data for

More information

Aveek Gupta, CISA. IPCC Paper 7A: Information Technology Chapter 2

Aveek Gupta, CISA. IPCC Paper 7A: Information Technology Chapter 2 Aveek Gupta, CISA IPCC Paper 7A: Information Technology Chapter 2 * DBMS/RDBMS 1 Administration 2 3 4 5 6 6 7 Models DML and DDL Data Dictionaries Distributed DataBases Object Oriented DataBases Client

More information

SQL: The Query Language Part 3

SQL: The Query Language Part 3 SQL: The Query Language Part 3 R &G - Chapter 5 Lecture 13 It is not every question that deserves an answer. Publius Syrus. 42 B. C. Schedule Today: Embedded SQL, Cursors, Stored Procedures Dynamic SQL,

More information

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives CHAPTER 6 DATABASE MANAGEMENT SYSTEMS Management Information Systems, 10 th edition, By Raymond McLeod, Jr. and George P. Schell 2007, Prentice Hall, Inc. 1 Learning Objectives Understand the hierarchy

More information