Do we really understand SQL?

Size: px
Start display at page:

Download "Do we really understand SQL?"

Transcription

1 Do we really understand SQL? Leonid Libkin University of Edinburgh Joint work with Paolo Guagliardo, also from Edinburgh

2 Basic questions We are taught that the core of SQL is essentially syntax for relational calculus (first-order logic). Is it true? We are taught that core SQL can be translated into relational algebra. Is it true? We are taught that SQL needs 3-valued logic to deal with missing information (nulls). Is it true?

3 Motivation Why even ask such questions? It s the stuff from the 1980s (or earlier). It s all in database textbooks and taught in all database courses. This is exactly what we thought until we got into some specific problems related to real-life SQL So we start with a bit of history

4 Old days (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

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) Idea: Take FO and turn into into programming syntax. Then use R to implement queries.

14 SQL development SQL has since become the dominant language for relational databases Standards: SQL-86, SQL-89, SQL-92, SQL:1999, SQL:2003, SQL:2008, SQL:2011, SQL:2016 The latest standard is in 9 parts, will make you $1000 poorer if you buy them all. But the core remains the same, essentially FO. nd it is the main big data tool!

15 Data scientists favorite tools 70% TOOLS LNGUGES, DT PLTFORMS, NLYTICS 60% Share of Respondents 50% 40% 30% 20% 10% 0% SQL Excel Python R MySQL Python: numpy, scipy, scikit-learn ggplot Microsoft SQL Server Tableau JavaScript Matplotlib (Python) Java PostgreSQL Oracle D3 Homegrown analysis tools Hive Spark Cloudera Visual Basic/VB MongoDB pache Hadoop SS C++ PowerPivot Scala Tool: language, data platform, analytics SQLite C Pig mazon RedShift Weka Hbase mazon Elastic MapReduce (EMR) Perl SPSS Teradata

16 Future data scientists favorite tools

17 But do we understand it? Even the basic fragment, that stays the same in all the Standards: does it have the power of R? Does it have the power of FO? Is there a formal semantics of it? Let s do a little quiz and see how well we know the basics.

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

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

20 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.)

21 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

22 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

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 : 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

24 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

25 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

26 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

27 n exam question that nicely brings down the average grade What is the output of these queries? SELECT 1 FROM S WHERE (null = ((null = ((null = ((null = null) is null)) is null)) is null)) is null SELECT 1 FROM S WHERE (null = ((null = ((null = ((null = null) is null)) is null)) is null))

28 n exam question that nicely brings down the average grade What is the output of these queries? SELECT 1 FROM S WHERE (null = ((null = ((null = ((null = null) is null)) is null)) is null)) is null 1 SELECT 1 FROM S WHERE (null = ((null = ((null = ((null = null) is null)) is null)) is null))

29 SQL vs Relational lgebra: attributes may repeat Q = SELECT R., R. FROM R on 1 gives 1 1 null null null

30 SQL vs Relational lgebra: attributes may repeat Q = SELECT R., R. FROM R on 1 gives 1 1 null null null Let s use it as a subquery: Q = SELECT * FROM (Q) S T

31 SQL vs Relational lgebra: attributes may repeat Q = SELECT R., R. FROM R on 1 gives 1 1 null null null Let s use it as a subquery: Q = SELECT * FROM (Q) S T Output: Postgres: as above Oracle, MS SQL Server: compile-time error

32 SQL vs Relational lgebra: attributes may repeat Q = SELECT R., R. FROM R on 1 gives 1 1 null null null 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 )

33 SQL vs Relational lgebra: attributes may repeat Q = SELECT R., R. FROM R on 1 gives 1 1 null null null 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 null

34 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. Under these assumptions several semantics exist ( ) but they do not model the real language.

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

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

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

38 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

39 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:

40 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

41 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

42 The infamous NULL Comparisons with nulls, like 2 = NULL, result in truth value unknown It then propagates: true unknown = unknown, true unknown = true rules of propositional 3-valued logic of Kleene When condition is evaluated, only tuples for which it is true are returned false and unknown are treated the same It s a weird logic and it is not the 3-valued predicate calculus!

43 The bottom line Many spherical cows out there but no real one. There are lots and lots of issues to address to give proper semantics of SQL None of the simplified semantics came even close. We do it for the basic fragment of SQL: SELECT-FROM-WHERE without aggregation but with pretty much everything else

44 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

45 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 )

46 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)

47 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

48 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 = ;

49 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

50 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

51 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

52 How do we know we got it right? 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.

53 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)

54 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

55 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, we got it right!

56 What can we do with this? Equivalence of basic SQL and Relational lgebra: formally proved for the first time. 3-valued logic of SQL vs the usual Boolean logic: is there any difference?

57 Basic SQL = Relational lgebra We formally prove SQL = Relational lgebra (R) with nulls, subqueries, bags, all there is. nd R has to be defined properly too, to use bags and SQL s 3-valued logic. a small caveat: in R, attributes cannot repeat. So the equality is wrt queries that do not return repeated attributes.

58 3-valued logic of nulls From the early SQL days and database textbooks: if you have nulls, you need 3-valued logic. But 3-valued logic is not the first thing you think of as a logician. nd it makes sense to think as a logician: after all, the core of SQL is claimed to be first-order logic in a different syntax.

59 What would a logician do?

60 What would a logician do? First Order Logic (FO) domain has usual values and NULL Syntactic equality: NULL = NULL but NULL 5 etc Boolean logic rules for,, Quantifiers: is conjunction, is disjunction

61 What did SQL do?

62 What did SQL do? 3-valued FO (a textbook version) domain has usual values and NULL comparisons with NULL result in unknown Kleene logic rules for,, Quantifiers: is conjunction, is disjunction

63 What did SQL do? 3-valued FO (a textbook version) domain has usual values and NULL comparisons with NULL result in unknown Kleene logic rules for,, Quantifiers: is conjunction, is disjunction Seemingly more expressive.

64 What did SQL do? 3-valued FO (a textbook version) domain has usual values and NULL comparisons with NULL result in unknown Kleene logic rules for,, Quantifiers: is conjunction, is disjunction Seemingly more expressive. But does it correspond to reality?

65 SQL logic is NOT 2-valued or 3-valued: it s a mix Conditions in WHERE are evaluated under 3-valued logic. But then only those evaluated to true matter. Studied before only at the level of propositional logic. In 1939, Russian logician Bochvar wanted to give a formal treatment of logical paradoxes. He needed to assert that something is true, and introduced a new connective: p means that p is true. mazingly, 40 years later SQL adopted the same idea.

66 What did SQL really do? 3-valued FO with : domain has usual values and NULL comparisons with NULL result in unknown Kleene logic rules for,, Quantifiers: is conjunction, is disjunction dd with the semantics true, if φ is true φ = { false, if φ is false or unknown

67 What IS the logic of SQL?

68 What IS the logic of SQL? We have: logician s 2-valued FO 3-valued FO (Kleene logic) 3-valued FO + Bochvar s assertion (SQL logic)

69 What IS the logic of SQL? We have: logician s 2-valued FO 3-valued FO (Kleene logic) 3-valued FO + Bochvar s assertion (SQL logic) ND THEY RE LL THE SME!

70 THEOREM: can be expressed in 3-valued FO. 3-valued FO = 3-valued FO with THEOREM: For every formula φ of 3-valued FO, there is a formula ψ of the usual 2-valued FO such that φ is true ψ is true

71 THEOREM: can be expressed in 3-valued FO. 3-valued FO = 3-valued FO with THEOREM: For every formula φ of 3-valued FO, there is a formula ψ of the usual 2-valued FO such that φ is true ψ is true Translations work at the level of SQL too!

72 2-valued SQL Idea 3 simultaneous translations: conditions P P t and P f Queries Q Q P t and P f are Boolean conditions: P t / P f is true iff P under 3-valued logic is true / false. In Q we simply replace P by P t

73 2-valued SQL: translation P ( t) t = P ( t) P (t 1,...,t k ) f = NOT P (t 1,...,t k ) ND t IS NOT NULL (EXISTS Q) t = EXISTS Q 0 (EXISTS Q) f = NOT EXISTS Q 0 ( 1 ^ 2 ) t = t 1 ^ t 2 ( 1 ^ 2 ) f = f 1 _ f 2 ( 1 _ 2 ) t = t 1 _ t 2 ( 1 _ 2 ) f = f 1 ^ f 2 ( ) t = f ( ) f = t (t IS NULL) t = t IS NULL (t IS NULL) f = t IS NOT NULL ( t IN Q) t = t IN Q 0 (t 1,...,t n ) IN Q f = NOT EXISTS SELECT * FROM Q 0 S N( 1,..., n ) WHERE (t 1 IS NULL OR 1 IS NULL OR t 1 = N. 1 ) ND ND (t n IS NULL OR n IS NULL OR t n = N. n ) 7! 0 Note: a lot of disjunctions with IS NULL conditions

74 Shall we switch to 2-valued SQL? Not so fast perhaps. Two reasons: all the legacy code that uses 3-values using 2 truth values introduces many new disjunctions. nd DBMSs don t like disjunctions!

75 Shall we switch to 2-valued SQL? Not so fast perhaps. Two reasons: all the legacy code that uses 3-values using 2 truth values introduces many new disjunctions. nd DBMSs don t like disjunctions! s to why, this comment line in Postgres optimizer code sheds some light:

76 Shall we switch to 2-valued SQL? Not so fast perhaps. Two reasons: all the legacy code that uses 3-values using 2 truth values introduces many new disjunctions. nd DBMSs don t like disjunctions! s to why, this comment line in Postgres optimizer code sheds some light: /* we stop as soon as we hit a non-nd item */

77 Questions?

Can We Trust SQL as a Data Analytics Tool?

Can We Trust SQL as a Data Analytics Tool? Can We Trust SQL as a Data nalytics Tool? SQL The query language for relational databases International Standard since 1987 Implemented in all systems (free and commercial) $30B/year business Most common

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

Hal Varian, Google s Chief Economist The McKinsey Quarterly, Jan 2009

Hal Varian, Google s Chief Economist The McKinsey Quarterly, Jan 2009 The ability to take data to be able to understand it, to process it, to extract value from it, to visualize it, to communicate it that s going to be a hugely important skill in the next decades, because

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

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

Typed Lambda Calculus

Typed Lambda Calculus Department of Linguistics Ohio State University Sept. 8, 2016 The Two Sides of A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a system of notation for functions

More information

Towards a Logical Reconstruction of Relational Database Theory

Towards a Logical Reconstruction of Relational Database Theory Towards a Logical Reconstruction of Relational Database Theory On Conceptual Modelling, Lecture Notes in Computer Science. 1984 Raymond Reiter Summary by C. Rey November 27, 2008-1 / 63 Foreword DB: 2

More information

Foundations of Databases

Foundations of Databases Foundations of Databases Relational Query Languages with Negation Free University of Bozen Bolzano, 2009 Werner Nutt (Slides adapted from Thomas Eiter and Leonid Libkin) Foundations of Databases 1 Queries

More information

Typed Lambda Calculus for Syntacticians

Typed Lambda Calculus for Syntacticians Department of Linguistics Ohio State University January 12, 2012 The Two Sides of Typed Lambda Calculus A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a

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

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

CITS5501 Software Testing and Quality Assurance Formal methods

CITS5501 Software Testing and Quality Assurance Formal methods CITS5501 Software Testing and Quality Assurance Formal methods Unit coordinator: Arran Stewart May 1, 2018 1 / 49 Sources Pressman, R., Software Engineering: A Practitioner s Approach, McGraw-Hill, 2005

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

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic. Overview CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics Işıl Dillig So far: Automated reasoning in propositional logic. Propositional logic is simple and easy to

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

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Propositional Logic Formal Syntax and Semantics. Computability and Logic Propositional Logic Formal Syntax and Semantics Computability and Logic Syntax and Semantics Syntax: The study of how expressions are structured (think: grammar) Semantics: The study of the relationship

More information

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2018 1. Introduction: Relational Query Languages Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 6 March,

More information

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information

Computation Club: Gödel s theorem

Computation Club: Gödel s theorem Computation Club: Gödel s theorem The big picture mathematicians do a lot of reasoning and write a lot of proofs formal systems try to capture the ideas of reasoning and proof in a purely mechanical set

More information

CSC Discrete Math I, Spring Sets

CSC Discrete Math I, Spring Sets CSC 125 - Discrete Math I, Spring 2017 Sets Sets A set is well-defined, unordered collection of objects The objects in a set are called the elements, or members, of the set A set is said to contain its

More information

Informatics 1: Data & Analysis

Informatics 1: Data & Analysis Informatics 1: Data & Analysis Lecture 5: Relational Algebra Ian Stark School of Informatics The University of Edinburgh Tuesday 31 January 2017 Semester 2 Week 3 https://blog.inf.ed.ac.uk/da17 Tutorial

More information

On the Codd Semantics of SQL Nulls

On the Codd Semantics of SQL Nulls On the Codd Semantics of SQL Nulls Paolo Guagliardo and Leonid Libkin School of Informatics, University of Edinburgh Abstract. Theoretical models used in database research often have subtle differences

More information

Introduction to Data Management. Lecture #13 (Relational Calculus, Continued) It s time for another installment of...

Introduction to Data Management. Lecture #13 (Relational Calculus, Continued) It s time for another installment of... Introduction to Data Management Lecture #13 (Relational Calculus, Continued) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 It s time for another

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

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

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 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

Correctness of SQL Queries on Databases with Nulls

Correctness of SQL Queries on Databases with Nulls Correctness of SQL Queries on Databases with Nulls Paolo Guagliardo School of Informatics The University of Edinburgh pguaglia@inf.ed.ac.uk Leonid Libkin School of Informatics The University of Edinburgh

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

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

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

Virtual views. Incremental View Maintenance. View maintenance. Materialized views. Review of bag algebra. Bag algebra operators (slide 1)

Virtual views. Incremental View Maintenance. View maintenance. Materialized views. Review of bag algebra. Bag algebra operators (slide 1) Virtual views Incremental View Maintenance CPS 296.1 Topics in Database Systems A view is defined by a query over base tables Example: CREATE VIEW V AS SELECT FROM R, S WHERE ; A view can be queried just

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

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 1. Textbook. Practicalities: assessment. Aims and objectives of the course

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 1. Textbook. Practicalities: assessment. Aims and objectives of the course Plan of the lecture G53RDB: Theory of Relational Databases Lecture 1 Practicalities Aims and objectives of the course Plan of the course Relational model: what are relations, some terminology Relational

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

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

Incomplete Data: What Went Wrong, and How to Fix It. PODS 2014 Incomplete Information 1/1

Incomplete Data: What Went Wrong, and How to Fix It. PODS 2014 Incomplete Information 1/1 Incomplete Data: What Went Wrong, and How to Fix It Leonid Libkin (University of Edinburgh) PODS 2014 Incomplete Information 1/1 Incomplete information It is everywhere. The more data we accumulate, the

More information

2.3 Algorithms Using Map-Reduce

2.3 Algorithms Using Map-Reduce 28 CHAPTER 2. MAP-REDUCE AND THE NEW SOFTWARE STACK one becomes available. The Master must also inform each Reduce task that the location of its input from that Map task has changed. Dealing with a failure

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

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

SQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017

SQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017 SQL: Data Definition Language csc343, Introduction to Databases Diane Horton Fall 2017 Types Table attributes have types When creating a table, you must define the type of each attribute. Analogous to

More information

LING 130: Quantified Noun Phrases

LING 130: Quantified Noun Phrases LING 130: Quantified Noun Phrases James Pustejovsky March 15, 2010 1 Syntax for Typed λ-calculus We will now present a language which uses specific types of entities, where the entities are combined with

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

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2011 1. Introduction: Relational Query Languages Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 8 March,

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

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 [talking head] Formal Methods of Software Engineering means the use of mathematics as an aid to writing programs. Before we can

More information

SQL in the Hybrid World

SQL in the Hybrid World SQL in the Hybrid World Tanel Poder a long time computer performance geek 1 Tanel Põder Intro: About me Oracle Database Performance geek (18+ years) Exadata Performance geek Linux Performance geek Hadoop

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

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

Ontology and Database Systems: Foundations of Database Systems

Ontology and Database Systems: Foundations of Database Systems Ontology and Database Systems: Foundations of Database Systems Werner Nutt Faculty of Computer Science Master of Science in Computer Science A.Y. 2014/2015 Incomplete Information Schema Person(fname, surname,

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

Database Theory VU , SS Codd s Theorem. Reinhard Pichler

Database Theory VU , SS Codd s Theorem. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2011 3. Codd s Theorem Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 29 March, 2011 Pichler 29 March,

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 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

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions , Semantics and Pragmatics of NLP, and s Alex Ewan School of Informatics University of Edinburgh 10 January 2008 , 1 2 3 4 Why Bother?, Aim: 1 To associate NL expressions with semantic representations;

More information

SQL. Dean Williamson, Ph.D. Assistant Vice President Institutional Research, Effectiveness, Analysis & Accreditation Prairie View A&M University

SQL. Dean Williamson, Ph.D. Assistant Vice President Institutional Research, Effectiveness, Analysis & Accreditation Prairie View A&M University SQL Dean Williamson, Ph.D. Assistant Vice President Institutional Research, Effectiveness, Analysis & Accreditation Prairie View A&M University SQL 1965: Maron & Levien propose Relational Data File 1968:

More information

CS 377 Database Systems

CS 377 Database Systems CS 377 Database Systems Relational Data Model Li Xiong Department of Mathematics and Computer Science Emory University 1 Outline Relational Model Concepts Relational Model Constraints Relational Database

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

7/25/2016. Example: Addition of Unsigned Bit Patterns. ECE 120: Introduction to Computing. Adding Two Non-Negative Patterns Can Overflow

7/25/2016. Example: Addition of Unsigned Bit Patterns. ECE 120: Introduction to Computing. Adding Two Non-Negative Patterns Can Overflow University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing 2 s Complement Overflow and Boolean Logic Example: ddition of Unsigned Bit Patterns

More information

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 7 This lecture returns to the topic of propositional logic. Whereas in Lecture 1 we studied this topic as a way of understanding proper reasoning

More information

COMP 410 Lecture 1. Kyle Dewey

COMP 410 Lecture 1. Kyle Dewey COMP 410 Lecture 1 Kyle Dewey About Me I research automated testing techniques and their intersection with CS education My dissertation used logic programming extensively This is my second semester at

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

CS 512, Spring 2017: Take-Home End-of-Term Examination

CS 512, Spring 2017: Take-Home End-of-Term Examination CS 512, Spring 2017: Take-Home End-of-Term Examination Out: Tuesday, 9 May 2017, 12:00 noon Due: Wednesday, 10 May 2017, by 11:59 am Turn in your solutions electronically, as a single PDF file, by placing

More information

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m. CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.

More information

Relational Model and Algebra. Introduction to Databases CompSci 316 Fall 2018

Relational Model and Algebra. Introduction to Databases CompSci 316 Fall 2018 Relational Model and Algebra Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Thu. Aug. 30) Sign up for Piazza, NOW! Homework #1 to be posted today; due in 2½ weeks Sign up for Gradiance

More information

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

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Relational Databases Fall 2017 Lecture 1 COURSE OVERVIEW THE RELATIONAL MODEL CS121: Relational Databases Fall 2017 Lecture 1 Course Overview 2 Introduction to relational database systems Theory and use of relational databases Focus on: The Relational

More information

Random Oracles - OAEP

Random Oracles - OAEP Random Oracles - OAEP Anatoliy Gliberman, Dmitry Zontov, Patrick Nordahl September 23, 2004 Reading Overview There are two papers presented this week. The first paper, Random Oracles are Practical: A Paradigm

More information

Schema Mappings and Data Exchange

Schema Mappings and Data Exchange Schema Mappings and Data Exchange Lecture #2 EASSLC 2012 Southwest University August 2012 1 The Relational Data Model (E.F. Codd 1970) The Relational Data Model uses the mathematical concept of a relation

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

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

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

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Introduction to Relational Database Systems Fall 2016 Lecture 1 COURSE OVERVIEW THE RELATIONAL MODEL CS121: Introduction to Relational Database Systems Fall 2016 Lecture 1 Course Overview 2 Introduction to relational database systems Theory and use of relational databases

More information

Data Analytics Job Guarantee Program

Data Analytics Job Guarantee Program Data Analytics Job Guarantee Program 1. INSTALLATION OF VMWARE 2. MYSQL DATABASE 3. CORE JAVA 1.1 Types of Variable 1.2 Types of Datatype 1.3 Types of Modifiers 1.4 Types of constructors 1.5 Introduction

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

Uncertain Data Models

Uncertain Data Models Uncertain Data Models Christoph Koch EPFL Dan Olteanu University of Oxford SYNOMYMS data models for incomplete information, probabilistic data models, representation systems DEFINITION An uncertain data

More information

CSC 501 Semantics of Programming Languages

CSC 501 Semantics of Programming Languages CSC 501 Semantics of Programming Languages Subtitle: An Introduction to Formal Methods. Instructor: Dr. Lutz Hamel Email: hamel@cs.uri.edu Office: Tyler, Rm 251 Books There are no required books in this

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

Logic and Databases. Phokion G. Kolaitis. UC Santa Cruz & IBM Research - Almaden

Logic and Databases. Phokion G. Kolaitis. UC Santa Cruz & IBM Research - Almaden Logic and Databases Phokion G. Kolaitis UC Santa Cruz & IBM Research - Almaden 1 Logic and Databases are inextricably intertwined. C.J. Date -- 2007 2 Logic and Databases Extensive interaction between

More information

CSE 344 Final Review. August 16 th

CSE 344 Final Review. August 16 th CSE 344 Final Review August 16 th Final In class on Friday One sheet of notes, front and back cost formulas also provided Practice exam on web site Good luck! Primary Topics Parallel DBs parallel join

More information

CSE 190D Spring 2017 Final Exam

CSE 190D Spring 2017 Final Exam CSE 190D Spring 2017 Final Exam Full Name : Student ID : Major : INSTRUCTIONS 1. You have up to 2 hours and 59 minutes to complete this exam. 2. You can have up to one letter/a4-sized sheet of notes, formulae,

More information

Today s Topics. What is a set?

Today s Topics. What is a set? Today s Topics Introduction to set theory What is a set? Set notation Basic set operations What is a set? Definition: A set is an unordered collection of objects Examples: Sets can contain items of mixed

More information

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 I. Logic 101 In logic, a statement or proposition is a sentence that can either be true or false. A predicate is a sentence in

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

LOGIC AND DISCRETE MATHEMATICS

LOGIC AND DISCRETE MATHEMATICS LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University

More information

Informatics 1: Data & Analysis

Informatics 1: Data & Analysis Informatics 1: Data & Analysis Lecture 7: SQL Ian Stark School of Informatics The University of Edinburgh Tuesday 4 February 2014 Semester 2 Week 4 http://www.inf.ed.ac.uk/teaching/courses/inf1/da Careers

More information

MITOCW watch?v=kz7jjltq9r4

MITOCW watch?v=kz7jjltq9r4 MITOCW watch?v=kz7jjltq9r4 PROFESSOR: We're going to look at the most fundamental of all mathematical data types, namely sets, and let's begin with the definitions. So informally, a set is a collection

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

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

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

CSE 190D Spring 2017 Final Exam Answers

CSE 190D Spring 2017 Final Exam Answers CSE 190D Spring 2017 Final Exam Answers Q 1. [20pts] For the following questions, clearly circle True or False. 1. The hash join algorithm always has fewer page I/Os compared to the block nested loop join

More information

CS317 File and Database Systems

CS317 File and Database Systems CS317 File and Database Systems Lecture 3 Relational Model & Languages Part-1 September 7, 2018 Sam Siewert More Embedded Systems Summer - Analog, Digital, Firmware, Software Reasons to Consider Catch

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

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

First-Order Predicate Logic. CSCI 5582, Fall 2007

First-Order Predicate Logic. CSCI 5582, Fall 2007 First-Order Predicate Logic CSCI 5582, Fall 2007 What Can t We Do in FOPL? We can t take anything back once we ve asserted it. We can t make statements about relations themselves (e.g., Brother is a commutative

More information

CSE Midterm - Spring 2017 Solutions

CSE Midterm - Spring 2017 Solutions CSE Midterm - Spring 2017 Solutions March 28, 2017 Question Points Possible Points Earned A.1 10 A.2 10 A.3 10 A 30 B.1 10 B.2 25 B.3 10 B.4 5 B 50 C 20 Total 100 Extended Relational Algebra Operator Reference

More information

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until Databases Relational Model, Algebra and operations How do we model and manipulate complex data structures inside a computer system? Until 1970.. Many different views or ways of doing this Could use tree

More information

CERTIFICATE IN SOFTWARE DEVELOPMENT LIFE CYCLE IN BIG DATA AND BUSINESS INTELLIGENCE (SDLC-BD & BI)

CERTIFICATE IN SOFTWARE DEVELOPMENT LIFE CYCLE IN BIG DATA AND BUSINESS INTELLIGENCE (SDLC-BD & BI) CERTIFICATE IN SOFTWARE DEVELOPMENT LIFE CYCLE IN BIG DATA AND BUSINESS INTELLIGENCE (SDLC-BD & BI) The Certificate in Software Development Life Cycle in BIGDATA, Business Intelligence and Tableau program

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

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

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