Can We Trust SQL as a Data Analytics Tool?

Size: px
Start display at page:

Download "Can We Trust SQL as a Data Analytics Tool?"

Transcription

1 Can We Trust SQL as a Data nalytics Tool?

2 SQL The query language for relational databases International Standard since 1987 Implemented in all systems (free and commercial) $30B/year business Most common tool used by data scientists

3 Main Questions Do we understand SQL queries, even simple ones? nd if we think we do, do query results make sense?

4 sking these questions now? bit of history: before 1969, various ad-hoc database modes (network, hierarchical) writing queries: a very elaborate task ll changed in 1969: Codd s relational model; now dominates the world. Query writing made easy: SQL

5 Relational Model Orders Pay Customer ORDER_ID TITLE PRICE Ord1 Big Data 30 Ord2 SQL 35 Ord3 Logic 50 CUST_ID c1 c2 ORDER Ord1 Ord2 CUST_ID c1 c2 NME John Mary

6 Relational Model Orders Pay Customer ORDER_ID TITLE PRICE Ord1 Big Data 30 Ord2 SQL 35 Ord3 Logic 50 CUST_ID c1 c2 ORDER Ord1 Ord2 CUST_ID c1 c2 NME John Mary Language: Relational lgebra (R) projection π (find book titles) selection σ (find books that cost at least 40) Cartesian product union difference -

7 Queries Find ids of customers who buy all books: πcust_id (Pay) - πcust_id ((π cust_id(pay) πtitle(order)) - πcust_id,title (σorder_id=order (Order Pay)))

8 Queries Find ids of customers who buy all books: πcust_id (Pay) - πcust_id ((π cust_id(pay) πtitle(order)) - πcust_id,title (σorder_id=order (Order Pay))) That s not pretty. But here is a better idea (1971): express queries in logic

9 Queries Find ids of customers who buy all books: πcust_id (Pay) - πcust_id ((π cust_id(pay) πtitle(order)) - πcust_id,title (σorder_id=order (Order Pay))) That s not pretty. But here is a better idea (1971): express queries in logic {c (o,t,p) Order (o,t,p ) Order: (c,o ) Pay}

10 Queries Find ids of customers who buy all books: πcust_id (Pay) - πcust_id ((π cust_id(pay) πtitle(order)) - πcust_id,title (σorder_id=order (Order Pay))) That s not pretty. But here is a better idea (1971): express queries in logic {c (o,t,p) Order (o,t,p ) Order: (c,o ) Pay} This is first-order logic (FO). Codd 1971: R = FO.

11 History continued Of course programmers don t write logical sentences, they need a programming syntax. Enters SQL: SELECT P.cust_id FROM P WHERE NOT EXISTS (SELECT * FROM Order O WHERE NOT EXISTS (SELECT * FROM Order O1 WHERE O1.title=O.title ND O1.order_id=P.order))

12 History continued Of course programmers don t write logical sentences, they need a programming syntax. Enters SQL: SELECT P.cust_id FROM P WHERE NOT EXISTS xf(x) = (SELECT * FROM Order O x F(x) WHERE NOT EXISTS (SELECT * FROM Order O1 WHERE O1.title=O.title ND O1.order_id=P.order))

13 History continued Of course programmers don t write logical sentences, they need a programming syntax. Enters SQL: SELECT P.cust_id FROM P WHERE NOT EXISTS (SELECT * FROM Order O WHERE NOT EXISTS (SELECT * FROM Order O1 WHERE O1.title=O.title ND O1.order_id=P.order)) xf(x) = x F(x) Take FO and turn into into programming syntax: Committee design! Then use R to implement queries.

14 SQL development Standards: SQL-86, SQL-89, SQL-92, SQL:1999, SQL:2003, SQL:2008, SQL:2011, SQL:2016 The latest standard will make you $1000 poorer The core remains the same. nd yet things are not as obvious as they should be. Now a few quiz-type slides.

15 TSK: Relations R(), S() Compute R - S.

16 TSK: Relations R(), S() Compute R - S. Every student will write: select R. from R where R. not in (select S. from S)

17 TSK: Relations R(), S() Compute R - S. Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : select R. from R where not exists (select S. from S where S.=R.)

18 TSK: Relations R(), S() Compute R - S. Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : select R. from R where not exists (select S. from S where S.=R.) and that they can do it directly in SQL: select * from r except select * from s

19 TSK: Relations R(), S() Compute R - S. R 1 null S null Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : select R. from R where not exists (select S. from S where S.=R.) and that they can do it directly in SQL: select * from r except select * from s

20 TSK: Relations R(), S() Compute R - S. R 1 null S null Outputs: Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : select R. from R where not exists (select S. from S where S.=R.) and that they can do it directly in SQL: select * from r except select * from s

21 TSK: Relations R(), S() Compute R - S. R 1 null S null Outputs: Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : select R. from R where not exists (select S. from S where S.=R.) and that they can do it directly in SQL: select * from r except select * from s

22 TSK: Relations R(), S() Compute R - S. R 1 null S null Outputs: Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : 1 null select R. from R where not exists (select S. from S where S.=R.) and that they can do it directly in SQL: select * from r except select * from s

23 TSK: Relations R(), S() Compute R - S. R 1 null S null Outputs: Every student will write: select R. from R where R. not in (select S. from S) nd they are taught it is equivalent to : 1 null select R. from R where not exists (select S. from S where S.=R.) and that they can do it directly in SQL: select * from r except select * from s 1

24 SELECT * should be simple, no? R Q = SELECT R., R. FROM R on 1 gives 1 1

25 SELECT * should be simple, no? R Q = SELECT R., R. FROM R on 1 gives 1 1 Let s use it as a subquery: Q = SELECT * FROM (Q) S T

26 SELECT * should be simple, no? R Q = SELECT R., R. FROM R on 1 gives 1 1 Let s use it as a subquery: Q = SELECT * FROM (Q) S T Output: Postgres: as above Oracle, MS SQL Server: compile-time error

27 SELECT * should be simple, no? R Q = SELECT R., R. FROM R on 1 gives 1 1 Let s use it as a subquery: Q = SELECT * FROM (Q) S T Output: Postgres: as above Oracle, MS SQL Server: compile-time error SELECT R. FROM R WHERE EXISTS (Q )

28 SELECT * should be simple, no? R Q = SELECT R., R. FROM R on 1 gives 1 1 Let s use it as a subquery: Q = SELECT * FROM (Q) S T Output: Postgres: as above Oracle, MS SQL Server: compile-time error SELECT R. FROM R WHERE EXISTS (Q ) nswer: 1

29 SELECT * should be simple, no? R Q = SELECT R., R. FROM R on 1 gives 1 1 Let s use it as a subquery: Q = SELECT * FROM (Q) S T Output: Postgres: as above Oracle, MS SQL Server: compile-time error SELECT R. FROM R WHERE EXISTS (Q ) nswer: 1 Except in MySQL

30 nother example: Query equivalences Q1(x) :- T(x,y) Q2(x) :- T(x,y), T(u,v)

31 nother example: Query equivalences Q1(x) :- T(x,y) Q2(x) :- T(x,y), T(u,v) In theory: equivalent; on B return 1 3

32 nother example: Query equivalences Q1(x) :- T(x,y) Q2(x) :- T(x,y), T(u,v) In theory: equivalent; on B return 1 3 Now the same in SQL:

33 nother example: Query equivalences Q1(x) :- T(x,y) Q2(x) :- T(x,y), T(u,v) In theory: equivalent; on B return 1 3 Now the same in SQL: Q1 = SELECT R. FROM R returns 1 3

34 nother example: Query equivalences Q1(x) :- T(x,y) Q2(x) :- T(x,y), T(u,v) In theory: equivalent; on B return 1 3 Now the same in SQL: Q1 = SELECT R. FROM R returns 1 3 Q2 = SELECT R1. FROM R R1, R R2 returns

35 Why do we find these questions difficult? Reason 1: there is no formal semantics of SQL. The Standard is rather vague, not written formally, and different vendors interpret it differently. Reason 2: theory works with a simplified model, no nulls, no duplicates, no repeated attributes. Under these assumptions several semantics exist ( ) but they do not model the real language.

36 It is much harder to deal with the real thing than with theoretical abstractions

37 It is much harder to deal with the real thing than with theoretical abstractions

38 From spherical to real cows We do it for the basic fragment of SQL: SELECT-FROM-WHERE without aggregation but with pretty much everything else [G.,L. Formal Semantics of SQL Queries, its Validation and pplications. PVLDB 2017]

39 Syntax : := T 1 S N 1,..., T k S N k for =(T 1,...,T k ), =(N 1,...,N k ), k > 0 : 0 := t 1 S N1, 0..., t m S Nk 0 for =(t 1,...,t m ), 0 =(N1,...,N 0 m), 0 m>0 Queries: Q := SELECT [ DISTINCT ] : 0 FROM : WHERE SELECT [ DISTINCT ] FROM : WHERE Q (UNION INTERSECT EXCEPT) [LL ] Q Conditions: := TRUE FLSE P (t 1,...,t k ),P2P t IS [ NOT ] NULL t [ NOT ] IN Q EXISTS Q ND OR NOT P Names: either simple (R, ) or composite (R.) Terms t: constants, nulls, or composite names Predicates: anything you want on constants

40 Semantics: labels `(R) = tuple of names provided by the schema `( ) =`(T 1 ) `(T k ) for =(T 1,...,T k ) SELECT [ DISTINCT ] : 0 ` FROM : WHERE = 0 ` SELECT [ DISTINCT ] FROM : WHERE = `( ) ` Q 1 (UNION INTERSECT EXCEPT) [LL ] Q 2 = `(Q 1 )

41 Semantics Q D,η,x Q: query D: database η: environment (values for composite names) x: Boolean switch to account for non-compositional nature of SELECT * (to show where we are in the query)

42 Semantics of terms JtK = J(t 1,...,t n )K = 8 >< () c >: NULL if t = if t = c 2 C if t = NULL Jt 1 K,...,Jt n K

43 Semantics: queries u s FROM : WHERE v SELECT : 0 FROM : WHERE u v SELECT FROM : WHERE u v SELECT FROM : WHERE s SELECT DISTINCT : 0 FROM : WHERE JRK D,,x = R D J : K D,,x = JT 1 K D,,0 JT k K D,,0 for =(T 1,...,T k ) 8 { < } ~ } ~ } ~ { D,,x D,,x D,,0 D,,1 D,,x = : 8 < = r,..., r {z } k times : J K 0,...,J K 0 {z } k times u } SELECT `( : ):`( ) = v FROM : ~ WHERE u = v SELECT c S N } FROM : ~ WHERE D,,1 s { SELECT : = " 0 FROM : WHERE r 2 k J : K D,,0, J K D, 0 = t, 0 = r `( : ) 0 = r `( : ), r 2 k s FROM : WHERE D,,0 for arbitrary c 2 C and N 2 N D,,x! { 9 = ; D,,x 9 = ;

44 Semantics: conditions JP (t 1,...,t k )K D, = Jt IS NULLK D, = 8 >< t if P Jt 1 K,...,Jt k K holds and Jt i K 6= NULL for all i 2{1,...,k} f if P Jt 1 K,...,Jt k K does not hold and Jt i K 6= NULL for all i 2{1,...,k} >: u if Jt i K = NULL for some i 2{1,...,k} ( t if JtK = NULL f if JtK 6= NULL Jt IS NOT NULLK D, = Jt IS NULLK D, n^ J(t 1,...t n )=(t 0 1,...,t 0 n)k D, = Jt i = t 0 ik D, J(t 1,...t n ) 6= (t 0 1,...,t 0 n)k D, = J t IN QK D, = i=1 8 >< t f >: u J t NOT IN QK D, = J t IN QK D, ( t if JQK D,,1 6=? JEXISTS QK D, = f if JQK D,,1 =? n_ Jt i 6= t 0 ik D, if 9 r 2 JQK D,,0 s.t. J t = rk D, = t if 8 r 2 JQK D,,0 s.t. J t = rk D, = f r 2 JQK D,,0 s.t. J t = rk D, = t and 9 r 2 JQK D,,0 s.t. J t = rk D, 6= f i=1 JTRUEK D, = t J 1 ND 2 K D, = J 1 K D, ^ J 2 K D, JNOT K D, = J K D, JFLSEK D, = f J 1 OR 2 K D, = J 1 K D, _ J 2 K D, Truth Tables: ^ t f u t t f u f f f f u u f u _ t f u t t t t f t f u u t u u t f u f t u

45 Semantics: operations JQ 1 UNION LL Q 2 K D,,x = JQ 1 K D,,0 [ JQ 2 K D,,0 JQ 1 INTERSECT LL Q 2 K D,,x = JQ 1 K D,,0 \ JQ 2 K D,,0 JQ 1 EXCEPT LL Q 2 K D,,x = JQ 1 K D,,0 JQ 2 K D,,0 JQ 1 UNION Q 2 K D,,x = " JQ 1 UNION LL Q 2 K D,,x JQ 1 INTERSECT Q 2 K D,,x = " JQ 1 INTERSECT LL Q 2 K D,,x JQ 1 EXCEPT Q 2 K D,,x = " JQ 1 K D,,0 JQ 2 K D,,0 Bag interpretation of operations; is duplicate elimination

46 Looks simple, no? It does not. Such basic things as variable binding changed several times till we got them right. The meaning of the new environment: FROM τ : β WHERE θ D,η,x = r,..., r }{{} k times r k τ : β D,η,0, θ D,η = t, η = η r l(τ : β) in η, unbind every name that occurs among labels of the FROM clause then bind non-repeated names among those to values taken from record r

47 How do we know we this is correct? Since the Standard is rather vague, there is only one way experiments. But what kind of benchmark can we use? For performance studies there are standard benchmarks like TPC-H. But they won t work for us: not enough queries.

48 Experimental Validation Benchmarks have rather few queries (22 in TPC-H). Validating on 22 queries is not a good evidence. But we can look at benchmarks, and then generate lots of queries that look the same. In TPC-H: 8 tables, maximum nesting depth = 3, average number of tables per query = 3.2, at most 8 conditions in WHERE (except two queries)

49 Validation: results Small adjustments of the Standard semantics (for Postgres and Oracle) Random query generator Naive implementation of the semantics Finally: experiments on 100,000 random queries

50 Validation: results Small adjustments of the Standard semantics (for Postgres and Oracle) Random query generator Naive implementation of the semantics Finally: experiments on 100,000 random queries Yes, it is correct!

51 What can we do with this? Equivalence of basic SQL and Relational lgebra: formally proved for the first time Previous attempts (Ceri and Gottlob, Van den Bussche and Vansummeren restricted the language severely: no nulls, for example). 3-valued logic of SQL vs the usual Boolean logic: 3-valued logic does not add expressiveness. lthough it does not mean we should get rid of it now

52 Does it matter which DBMS we use? We already saw it does. In fact in our experiments we adjusted things a bit for Postgres and Oracle. But how much of a difference does it make? We have a random query generator, so let s experiment: generate lots of queries (over 150K) send to standard DBMSs (Oracle, MySQL, MS SQL Server, PostgreSQL, IBM DB2) and see what happens

53 Discrepancies between RDBMSs bout 2% of queries do not behave the same way on different DBMSs and they come from the most basic fragment Lots of issues are minor and syntactic different syntax for set operations (eg EXCEPT vs MINUS) or functions (eg % vs MOD, or substring vs substr) But some are serious - and surprise even people with good SQL knowledge. Four of the most surprising examples to follow

54 Is empty string equal to itself? SELECT * FROM R WHERE =

55 Is empty string equal to itself? SELECT * FROM R WHERE = Usually it is, but not in Oracle: the above query always returns the empty table. Because Oracle implements NULL as Madness? Yes. With a string operation that produces you deal with 3-valued logic before you realize it!

56 Can you divide by zero? SELECT R./S.B FROM R, S R={1}, S={0}

57 Can you divide by zero? SELECT R./S.B FROM R, S R={1}, S={0} Usually not except in MySQL 5.6 It returns NULL OK, they realized it in MySQL 5.7 and now by default it s a warning. But one can go back to the 5.6 mode if one wishes

58 Is equality transitive? x=y and y=z imply x=z, right?

59 Is equality transitive? x=y and y=z imply x=z, right? Usually yes, but not in MySQL x= 1a, y=1, z= 1b Why is this a problem? SQL books teach programmers to overspecify join conditions: to R.=S. ND S.=T. add explicitly R.=T. But now it can turn a true condition into false!

60 Can you compare tuples in IN subqueries? SELECT * FROM R WHERE (R., R.B) IN SELECT (S., S.B FROM S)

61 Can you compare tuples in IN subqueries? SELECT * FROM R WHERE (R., R.B) IN SELECT (S., S.B FROM S) Usually yes, except in MS SQL Server. Why? No clue lso SQL Server has UNION but no UNION LL. Please explain this.

62 simple tool We actually have a tool that lets you: specify parameters of a query workload generate lots of random queries, and run against DBMSs you want to compare Have fun with results at least you know what to expect.

Do we really understand SQL?

Do we really understand SQL? Do we really understand SQL? Leonid Libkin University of Edinburgh Joint work with Paolo Guagliardo, also from Edinburgh Basic questions We are taught that the core of SQL is essentially syntax for relational

More information

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA Introduction to SQL SELECT-FROM-WHERE STATEMENTS MULTIRELATION QUERIES SUBQUERIES 1 SQL SQL is a standard language for accessing databases. SQL stands for Structured Query Language. SQL lecture s material

More information

EECS 647: Introduction to Database Systems

EECS 647: Introduction to Database Systems EECS 647: Introduction to Database Systems Instructor: Luke Huan Spring 2009 Stating Points A database A database management system A miniworld A data model Conceptual model Relational model 2/24/2009

More information

Incomplete Information: Null Values

Incomplete Information: Null Values Incomplete Information: Null Values Often ruled out: not null in SQL. Essential when one integrates/exchanges data. Perhaps the most poorly designed and the most often criticized part of SQL:... [this]

More information

Relational Databases

Relational Databases Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 49 Plan of the course 1 Relational databases 2 Relational database design 3 Conceptual database design 4

More information

Lecture 3 Additional Slides. CSE 344, Winter 2014 Sudeepa Roy

Lecture 3 Additional Slides. CSE 344, Winter 2014 Sudeepa Roy Lecture 3 dditional Slides CSE 344, Winter 014 Sudeepa Roy Note: These slides mostly contain the same material as the lecture notes, and were used as a substitute for a whiteboard in class. lso please

More information

SQL and Incomp?ete Data

SQL and Incomp?ete Data SQL and Incomp?ete Data A not so happy marriage Dr Paolo Guagliardo Applied Databases, Guest Lecture 31 March 2016 SQL is efficient, correct and reliable 1 / 25 SQL is efficient, correct and reliable...

More information

Relational Algebra. Procedural language Six basic operators

Relational Algebra. Procedural language Six basic operators Relational algebra Relational Algebra Procedural language Six basic operators select: σ project: union: set difference: Cartesian product: x rename: ρ The operators take one or two relations as inputs

More information

Multisets and Duplicates. SQL: Duplicate Semantics and NULL Values. How does this impact Queries?

Multisets and Duplicates. SQL: Duplicate Semantics and NULL Values. How does this impact Queries? Multisets and Duplicates SQL: Duplicate Semantics and NULL Values Fall 2015 SQL uses a MULTISET/BAG semantics rather than a SET semantics: SQL tables are multisets of tuples originally for efficiency reasons

More information

The Extended Algebra. Duplicate Elimination. Sorting. Example: Duplicate Elimination

The Extended Algebra. Duplicate Elimination. Sorting. Example: Duplicate Elimination The Extended Algebra Duplicate Elimination 2 δ = eliminate duplicates from bags. τ = sort tuples. γ = grouping and aggregation. Outerjoin : avoids dangling tuples = tuples that do not join with anything.

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Course: 20761 Course Details Audience(s): IT Professional(s) Technology: Microsoft SQL Server 2016 Duration: 24 HRs. ABOUT THIS COURSE This course is designed to introduce

More information

Ian Kenny. November 28, 2017

Ian Kenny. November 28, 2017 Ian Kenny November 28, 2017 Introductory Databases Relational Algebra Introduction In this lecture we will cover Relational Algebra. Relational Algebra is the foundation upon which SQL is built and is

More information

SQL: Data Manipulation Language. csc343, Introduction to Databases Diane Horton Winter 2017

SQL: Data Manipulation Language. csc343, Introduction to Databases Diane Horton Winter 2017 SQL: Data Manipulation Language csc343, Introduction to Databases Diane Horton Winter 2017 Introduction So far, we have defined database schemas and queries mathematically. SQL is a formal language for

More information

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

The SQL data-definition language (DDL) allows defining : Introduction to SQL Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query Structure Additional Basic Operations Set Operations Null Values Aggregate Functions Nested Subqueries

More information

SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji. Winter 2018

SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji. Winter 2018 SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji Winter 2018 Introduction So far, we have defined database schemas and queries mathematically. SQL is a

More information

Relational Model: History

Relational Model: History Relational Model: History Objectives of Relational Model: 1. Promote high degree of data independence 2. Eliminate redundancy, consistency, etc. problems 3. Enable proliferation of non-procedural DML s

More information

Lecture Query evaluation. Combining operators. Logical query optimization. By Marina Barsky Winter 2016, University of Toronto

Lecture Query evaluation. Combining operators. Logical query optimization. By Marina Barsky Winter 2016, University of Toronto Lecture 02.03. Query evaluation Combining operators. Logical query optimization By Marina Barsky Winter 2016, University of Toronto Quick recap: Relational Algebra Operators Core operators: Selection σ

More information

1. Introduction; Selection, Projection. 2. Cartesian Product, Join. 5. Formal Definitions, A Bit of Theory

1. Introduction; Selection, Projection. 2. Cartesian Product, Join. 5. Formal Definitions, A Bit of Theory Relational Algebra 169 After completing this chapter, you should be able to enumerate and explain the operations of relational algebra (there is a core of 5 relational algebra operators), write relational

More information

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s Introduction to SQL Select-From-Where Statements Multirelation Queries Subqueries Slides are reused by the approval of Jeffrey Ullman s 1 Why SQL? SQL is a very-high-level language. Say what to do rather

More information

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra Introduction to Data Management CSE 344 Lectures 8: Relational Algebra CSE 344 - Winter 2016 1 Announcements Homework 3 is posted Microsoft Azure Cloud services! Use the promotion code you received Due

More information

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1 Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations 2016 Zvi M. Kedem 1 Relational Algebra in Context User Level (View Level) Community Level (Base Level) Physical

More information

SQL Part 3: Where Subqueries and other Syntactic Sugar Part 4: Unknown Values and NULLs

SQL Part 3: Where Subqueries and other Syntactic Sugar Part 4: Unknown Values and NULLs SQL Part 3: Where Subqueries and other Syntactic Sugar Part 4: Unknown Values and NULLs 1-1 List of Slides 1 2 More on "where" conditions 3 Esoteric Predicates: Example 4 WHERE Subqueries 5 Overview of

More information

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1 Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations 2014 Zvi M. Kedem 1 Relational Algebra And SQL SQL is based on relational algebra with many extensions Some necessary

More information

Lecture 16. The Relational Model

Lecture 16. The Relational Model Lecture 16 The Relational Model Lecture 16 Today s Lecture 1. The Relational Model & Relational Algebra 2. Relational Algebra Pt. II [Optional: may skip] 2 Lecture 16 > Section 1 1. The Relational Model

More information

4. SQL - the Relational Database Language Standard 4.3 Data Manipulation Language (DML)

4. SQL - the Relational Database Language Standard 4.3 Data Manipulation Language (DML) Since in the result relation each group is represented by exactly one tuple, in the select clause only aggregate functions can appear, or attributes that are used for grouping, i.e., that are also used

More information

Databases Relational algebra Lectures for mathematics students

Databases Relational algebra Lectures for mathematics students Databases Relational algebra Lectures for mathematics students March 5, 2017 Relational algebra Theoretical model for describing the semantics of relational databases, proposed by T. Codd (who authored

More information

Informationslogistik Unit 4: The Relational Algebra

Informationslogistik Unit 4: The Relational Algebra Informationslogistik Unit 4: The Relational Algebra 26. III. 2012 Outline 1 SQL 2 Summary What happened so far? 3 The Relational Algebra Summary 4 The Relational Calculus Outline 1 SQL 2 Summary What happened

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

SQL - Data Query language

SQL - Data Query language SQL - Data Query language Eduardo J Ruiz October 20, 2009 1 Basic Structure The simple structure for a SQL query is the following: select a1...an from t1... tr where C Where t 1... t r is a list of relations

More information

CS143: Relational Model

CS143: Relational Model CS143: Relational Model Book Chapters (4th) Chapters 1.3-5, 3.1, 4.11 (5th) Chapters 1.3-7, 2.1, 3.1-2, 4.1 (6th) Chapters 1.3-6, 2.105, 3.1-2, 4.5 Things to Learn Data model Relational model Database

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

Relational Algebra and SQL

Relational Algebra and SQL Relational Algebra and SQL Relational Algebra. This algebra is an important form of query language for the relational model. The operators of the relational algebra: divided into the following classes:

More information

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

FOUNDATIONS OF DATABASES AND QUERY LANGUAGES

FOUNDATIONS OF DATABASES AND QUERY LANGUAGES FOUNDATIONS OF DATABASES AND QUERY LANGUAGES Lecture 14: Database Theory in Practice Markus Krötzsch TU Dresden, 20 July 2015 Overview 1. Introduction Relational data model 2. First-order queries 3. Complexity

More information

Dr Paolo Guagliardo. Fall 2018

Dr Paolo Guagliardo. Fall 2018 The NULL vale Dr Paolo Gagliardo dbs-lectrer@ed.ac.k Fall 2018 NULL: all-prpose marker to represent incomplete information Main sorce of problems and inconsistencies... this topic cannot be described in

More information

SQL. The Basics Advanced Manipulation Constraints Authorization 1. 1

SQL. The Basics Advanced Manipulation Constraints Authorization 1. 1 SQL The Basics Advanced Manipulation Constraints Authorization 1. 1 Table of Contents SQL 0 Table of Contents 0/1 Parke Godfrey 0/2 Acknowledgments 0/3 SQL: a standard language for accessing databases

More information

Chapter 2: Intro to Relational Model

Chapter 2: Intro to Relational Model Non è possibile visualizzare l'immagine. Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns)

More information

Chapter 3. The Relational Model. Database Systems p. 61/569

Chapter 3. The Relational Model. Database Systems p. 61/569 Chapter 3 The Relational Model Database Systems p. 61/569 Introduction The relational model was developed by E.F. Codd in the 1970s (he received the Turing award for it) One of the most widely-used data

More information

RELATIONAL ALGEBRA II. CS121: Relational Databases Fall 2017 Lecture 3

RELATIONAL ALGEBRA II. CS121: Relational Databases Fall 2017 Lecture 3 RELATIONAL ALGEBRA II CS121: Relational Databases Fall 2017 Lecture 3 Last Lecture 2 Query languages provide support for retrieving information from a database Introduced the relational algebra A procedural

More information

WTF with SQL. It s just not right! Kennie Nybo Pontoppidan Dublin, June 18th 2016

WTF with SQL. It s just not right! Kennie Nybo Pontoppidan Dublin, June 18th 2016 WTF with SQL It s just not right! Kennie Nybo Pontoppidan Dublin, June 18th 2016 Please Visit Sponsors and Enter Raffles Stick around for SWAG! (Prize drawing at 4.15 p.m Be there (in person) or be Volunteers

More information

Chapter 6: Formal Relational Query Languages

Chapter 6: Formal Relational Query Languages Chapter 6: Formal Relational Query Languages Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 6: Formal Relational Query Languages Relational Algebra Tuple Relational

More information

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra Introduction to Data Management CSE 344 Lectures 8: Relational Algebra CSE 344 - Winter 2017 1 Announcements Homework 3 is posted Microsoft Azure Cloud services! Use the promotion code you received Due

More information

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

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13 CS121 MIDTERM REVIEW CS121: Relational Databases Fall 2017 Lecture 13 2 Before We Start Midterm Overview 3 6 hours, multiple sittings Open book, open notes, open lecture slides No collaboration Possible

More information

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

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

More information

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 2: Relations and SQL. September 5, Lecturer: Rasmus Pagh

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 2: Relations and SQL. September 5, Lecturer: Rasmus Pagh Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 2: Relations and SQL September 5, 2005 Lecturer: Rasmus Pagh Today s lecture What, exactly, is the relational data model? What are

More information

Oracle Database 10g: Introduction to SQL

Oracle Database 10g: Introduction to SQL ORACLE UNIVERSITY CONTACT US: 00 9714 390 9000 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database

More information

Relational Database: The Relational Data Model; Operations on Database Relations

Relational Database: The Relational Data Model; Operations on Database Relations Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview

More information

Relational Algebra for sets Introduction to relational algebra for bags

Relational Algebra for sets Introduction to relational algebra for bags Relational Algebra for sets Introduction to relational algebra for bags Thursday, September 27, 2012 1 1 Terminology for Relational Databases Slide repeated from Lecture 1... Account Number Owner Balance

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 19 Query Optimization Introduction Query optimization Conducted by a query optimizer in a DBMS Goal: select best available strategy for executing query Based on information available Most RDBMSs

More information

Introduction to database design

Introduction to database design Introduction to database design First lecture: RG 3.6, 3.7, [4], most of 5 Second lecture: Rest of RG 5 Rasmus Pagh Some figures are taken from the ppt slides from the book Database systems by Kiefer,

More information

Database Technology Introduction. Heiko Paulheim

Database Technology Introduction. Heiko Paulheim Database Technology Introduction Outline The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager Introduction to the Relational Model

More information

CSE Database Management Systems. York University. Parke Godfrey. Winter CSE-4411M Database Management Systems Godfrey p.

CSE Database Management Systems. York University. Parke Godfrey. Winter CSE-4411M Database Management Systems Godfrey p. CSE-4411 Database Management Systems York University Parke Godfrey Winter 2014 CSE-4411M Database Management Systems Godfrey p. 1/16 CSE-3421 vs CSE-4411 CSE-4411 is a continuation of CSE-3421, right?

More information

SQL: Data Manipulation Language

SQL: Data Manipulation Language SQL: Data Manipulation Language CSC 343 Winter 2018 MICHAEL LIUT (MICHAEL.LIUT@UTORONTO.CA) DEPARTMENT OF MATHEMATICAL AND COMPUTATIONAL SCIENCES UNIVERSITY OF TORONTO MISSISSAUGA Why SQL? SQL is a very-high-level

More information

CMPS 277 Principles of Database Systems. https://courses.soe.ucsc.edu/courses/cmps277/fall11/01. Lecture #3

CMPS 277 Principles of Database Systems. https://courses.soe.ucsc.edu/courses/cmps277/fall11/01. Lecture #3 CMPS 277 Principles of Database Systems https://courses.soe.ucsc.edu/courses/cmps277/fall11/01 Lecture #3 1 Summary of Lectures #1 and #2 Codd s Relational Model based on the concept of a relation (table)

More information

CS 582 Database Management Systems II

CS 582 Database Management Systems II Review of SQL Basics SQL overview Several parts Data-definition language (DDL): insert, delete, modify schemas Data-manipulation language (DML): insert, delete, modify tuples Integrity View definition

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL SQL Join Operators Join operation merges rows from two tables and returns the rows with one of the following:

More information

Today s topics. Null Values. Nulls and Views in SQL. Standard Boolean 2-valued logic 9/5/17. 2-valued logic does not work for nulls

Today s topics. Null Values. Nulls and Views in SQL. Standard Boolean 2-valued logic 9/5/17. 2-valued logic does not work for nulls Today s topics CompSci 516 Data Intensive Computing Systems Lecture 4 Relational Algebra and Relational Calculus Instructor: Sudeepa Roy Finish NULLs and Views in SQL from Lecture 3 Relational Algebra

More information

Database Languages. A DBMS provides two types of languages: Language for accessing & manipulating the data. Language for defining a database schema

Database Languages. A DBMS provides two types of languages: Language for accessing & manipulating the data. Language for defining a database schema SQL 1 Database Languages A DBMS provides two types of languages: DDL Data Definition Language Language for defining a database schema DML Data Manipulation Language Language for accessing & manipulating

More information

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

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1 Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished

More information

Chapter 6 The Relational Algebra and Relational Calculus

Chapter 6 The Relational Algebra and Relational Calculus Chapter 6 The Relational Algebra and Relational Calculus Fundamentals of Database Systems, 6/e The Relational Algebra and Relational Calculus Dr. Salha M. Alzahrani 1 Fundamentals of Databases Topics so

More information

Structured Query Language Continued. Rose-Hulman Institute of Technology Curt Clifton

Structured Query Language Continued. Rose-Hulman Institute of Technology Curt Clifton Structured Query Language Continued Rose-Hulman Institute of Technology Curt Clifton The Story Thus Far SELECT FROM WHERE SELECT * SELECT Foo AS Bar SELECT expression SELECT FROM WHERE LIKE SELECT FROM

More information

SQL Part 2. Kathleen Durant PhD Northeastern University CS3200 Lesson 6

SQL Part 2. Kathleen Durant PhD Northeastern University CS3200 Lesson 6 SQL Part 2 Kathleen Durant PhD Northeastern University CS3200 Lesson 6 1 Outline for today More of the SELECT command Review of the SET operations Aggregator functions GROUP BY functionality JOIN construct

More information

Why SQL? SQL is a very-high-level language. Database management system figures out best way to execute query

Why SQL? SQL is a very-high-level language. Database management system figures out best way to execute query Basic SQL Queries 1 Why SQL? SQL is a very-high-level language Say what to do rather than how to do it Avoid a lot of data-manipulation details needed in procedural languages like C++ or Java Database

More information

Relational Algebra and SQL. Basic Operations Algebra of Bags

Relational Algebra and SQL. Basic Operations Algebra of Bags Relational Algebra and SQL Basic Operations Algebra of Bags 1 What is an Algebra Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators

More information

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and Chapter 6 The Relational Algebra and Relational Calculus Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 Outline Unary Relational Operations: SELECT and PROJECT Relational

More information

Mahathma Gandhi University

Mahathma Gandhi University Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed

More information

Databasesystemer, forår 2006 IT Universitetet i København. Forelæsning 9: Mere om SQL. 30. marts Forelæser: Esben Rune Hansen

Databasesystemer, forår 2006 IT Universitetet i København. Forelæsning 9: Mere om SQL. 30. marts Forelæser: Esben Rune Hansen Databasesystemer, forår 2006 IT Universitetet i København Forelæsning 9: Mere om SQL 30. marts 2006 Forelæser: Esben Rune Hansen Today s lecture Subqueries in SQL. Set operators in SQL. Security and authorization

More information

Basant Group of Institution

Basant Group of Institution Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of

More information

CSE 344 Midterm Exam

CSE 344 Midterm Exam CSE 344 Midterm Exam February 9, 2015 Question 1 / 10 Question 2 / 39 Question 3 / 16 Question 4 / 28 Question 5 / 12 Total / 105 The exam is closed everything except for 1 letter-size sheet of notes.

More information

Optimization Overview

Optimization Overview Lecture 17 Optimization Overview Lecture 17 Lecture 17 Today s Lecture 1. Logical Optimization 2. Physical Optimization 3. Course Summary 2 Lecture 17 Logical vs. Physical Optimization Logical optimization:

More information

Subqueries. Must use a tuple-variable to name tuples of the result

Subqueries. Must use a tuple-variable to name tuples of the result Subqueries A parenthesized SELECT-FROM-WHERE statement (subquery) can be used as a value in a number of places, including FROM and WHERE clauses Example: in place of a relation in the FROM clause, we can

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the fundamentals of SQL and PL/SQL along with the

More information

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17 Announcement CompSci 516 Database Systems Lecture 10 Query Evaluation and Join Algorithms Project proposal pdf due on sakai by 5 pm, tomorrow, Thursday 09/27 One per group by any member Instructor: Sudeepa

More information

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109 Index A abbreviations in field names, 22 in table names, 31 Access. See under Microsoft acronyms in field names, 22 in table names, 31 aggregate functions, 74, 375 377, 416 428. See also AVG; COUNT; COUNT(*);

More information

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 Relational Databases: Tuples, Tables, Schemas, Relational Algebra Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Overview

More information

Database Usage (and Construction)

Database Usage (and Construction) Lecture 7 Database Usage (and Construction) More SQL Queries and Relational Algebra Previously Capacity per campus? name capacity campus HB2 186 Johanneberg HC1 105 Johanneberg HC2 115 Johanneberg Jupiter44

More information

CIS 330: Applied Database Systems

CIS 330: Applied Database Systems 1 CIS 330: Applied Database Systems Lecture 7: SQL Johannes Gehrke johannes@cs.cornell.edu http://www.cs.cornell.edu/johannes Logistics Office hours role call: Mondays, 3-4pm Tuesdays, 4:30-5:30 Wednesdays,

More information

Detecting Logical Errors in SQL Queries

Detecting Logical Errors in SQL Queries Detecting Logical Errors in SQL Queries Stefan Brass Christian Goldberg Martin-Luther-Universität Halle-Wittenberg, Institut für Informatik, Von-Seckendorff-Platz 1, D-06099 Halle (Saale), Germany (brass

More information

CMPT 354: Database System I. Lecture 3. SQL Basics

CMPT 354: Database System I. Lecture 3. SQL Basics CMPT 354: Database System I Lecture 3. SQL Basics 1 Announcements! About Piazza 97 enrolled (as of today) Posts are anonymous to classmates You should have started doing A1 Please come to office hours

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Relational DB Languages Relational Algebra, Calculus, SQL Lecture 05 zain 1 Introduction Relational algebra & relational calculus are formal languages associated with the relational

More information

Introduction to Data Management. Lecture #14 (Relational Languages IV)

Introduction to Data Management. Lecture #14 (Relational Languages IV) Introduction to Data Management Lecture #14 (Relational Languages IV) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 It s time again for...

More information

COSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1

COSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1 COSC344 Database Theory and Applications σ a= c (P) S P Lecture 3 The Relational Data π A, C (H) Model COSC344 Lecture 3 1 Overview Last Lecture Database design ER modelling This Lecture Relational model

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

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

Database System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See   for conditions on re-use Database System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use " Data Definition! Basic Query Structure! Set Operations! Aggregate Functions! Null Values!

More information

Silberschatz, Korth and Sudarshan See for conditions on re-use

Silberschatz, Korth and Sudarshan See   for conditions on re-use Chapter 3: SQL Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 3: SQL Data Definition Basic Query Structure Set Operations Aggregate Functions Null Values Nested

More information

Agenda. Database Systems. Session 5 Main Theme. Relational Algebra, Relational Calculus, and SQL. Dr. Jean-Claude Franchitti

Agenda. Database Systems. Session 5 Main Theme. Relational Algebra, Relational Calculus, and SQL. Dr. Jean-Claude Franchitti Database Systems Session 5 Main Theme Relational Algebra, Relational Calculus, and SQL Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences

More information

Midterm Review. Winter Lecture 13

Midterm Review. Winter Lecture 13 Midterm Review Winter 2006-2007 Lecture 13 Midterm Overview 3 hours, single sitting Topics: Relational model relations, keys, relational algebra expressions SQL DDL commands CREATE TABLE, CREATE VIEW Specifying

More information

SOFTWARE ENGINEERING DESIGN I

SOFTWARE ENGINEERING DESIGN I 2 SOFTWARE ENGINEERING DESIGN I 3. Schemas and Theories The aim of this course is to learn how to write formal specifications of computer systems, using classical logic. The key descriptional technique

More information

What happens. 376a. Database Design. Execution strategy. Query conversion. Next. Two types of techniques

What happens. 376a. Database Design. Execution strategy. Query conversion. Next. Two types of techniques 376a. Database Design Dept. of Computer Science Vassar College http://www.cs.vassar.edu/~cs376 Class 16 Query optimization What happens Database is given a query Query is scanned - scanner creates a list

More information

Semantic Errors in Database Queries

Semantic Errors in Database Queries Semantic Errors in Database Queries 1 Semantic Errors in Database Queries Stefan Brass TU Clausthal, Germany From April: University of Halle, Germany Semantic Errors in Database Queries 2 Classification

More information

Handling Environments in a Nested Relational Algebra with Combinators and an Implementation in a Verified Query Compiler

Handling Environments in a Nested Relational Algebra with Combinators and an Implementation in a Verified Query Compiler Handling Environments in a Nested Relational Algebra with Combinators and an Implementation in a Verified Query Compiler Joshua Auerbach, Martin Hirzel, Louis Mandel, Avi Shinnar and Jérôme Siméon IBM

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course Code: M20761 Vendor: Microsoft Course Overview Duration: 5 RRP: 2,177 Querying Data with Transact-SQL Overview This course is designed to introduce students to Transact-SQL. It is designed in such

More information

Query Evaluation and Optimization

Query Evaluation and Optimization Query Evaluation and Optimization Jan Chomicki University at Buffalo Jan Chomicki () Query Evaluation and Optimization 1 / 21 Evaluating σ E (R) Jan Chomicki () Query Evaluation and Optimization 2 / 21

More information

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #3: SQL and Rela2onal Algebra- - - Part 1

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #3: SQL and Rela2onal Algebra- - - Part 1 CS 4604: Introduc0on to Database Management Systems B. Aditya Prakash Lecture #3: SQL and Rela2onal Algebra- - - Part 1 Reminder: Rela0onal Algebra Rela2onal algebra is a nota2on for specifying queries

More information

CMPS 277 Principles of Database Systems. Lecture #4

CMPS 277 Principles of Database Systems.  Lecture #4 CMPS 277 Principles of Database Systems http://www.soe.classes.edu/cmps277/winter10 Lecture #4 1 First-Order Logic Question: What is First-Order Logic? Answer: Informally, First-Order Logic = Propositional

More information

SIT772 Database and Information Retrieval WEEK 6. RELATIONAL ALGEBRAS. The foundation of good database design

SIT772 Database and Information Retrieval WEEK 6. RELATIONAL ALGEBRAS. The foundation of good database design SIT772 Database and Information Retrieval WEEK 6. RELATIONAL ALGEBRAS The foundation of good database design Outline 1. Relational Algebra 2. Join 3. Updating/ Copy Table or Parts of Rows 4. Views (Virtual

More information

Databases Lectures 1 and 2

Databases Lectures 1 and 2 Databases Lectures 1 and 2 Timothy G. Griffin Computer Laboratory University of Cambridge, UK Databases, Lent 2009 T. Griffin (cl.cam.ac.uk) Databases Lectures 1 and 2 DB 2009 1 / 36 Re-ordered Syllabus

More information

Query Processing & Optimization

Query Processing & Optimization Query Processing & Optimization 1 Roadmap of This Lecture Overview of query processing Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Introduction

More information

Chapter 6 The database Language SQL as a tutorial

Chapter 6 The database Language SQL as a tutorial Chapter 6 The database Language SQL as a tutorial About SQL SQL is a standard database language, adopted by many commercial systems. ANSI SQL, SQL-92 or SQL2, SQL99 or SQL3 extends SQL2 with objectrelational

More information

CISC 3140 (CIS 20.2) Design & Implementation of Software Application II

CISC 3140 (CIS 20.2) Design & Implementation of Software Application II CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Email Address: meyer@sci.brooklyn.cuny.edu Course Page: http://www.sci.brooklyn.cuny.edu/~meyer/ CISC3140-Meyer-lec4

More information