Translating SQL into the Relational Algebra
|
|
|
- Alaina Watson
- 9 years ago
- Views:
Transcription
1 Translating SQL into the Relational Algebra Jan Van den Bussche Stijn Vansummeren Required background Before reading these notes, please ensure that you are familiar with (1) the relational data model as defined in Section 2.2 of Database Management Systems: The Complete Book (second edition) (hereafter abbreviated as TCB ); (2) the set-based relational algebra as defined in section 2.4 of TCB; its bag-based variant and extension as defined in sections 5.1 and 5.2 of TCB; and (3) the SQL query language as defined in chapter 6 of TCB. Throughout these notes we will use the following example database schema about movies, as introduced in TCB Figure 2.5. The attributes of the primary key are underlined. Movie(title: string, year: int, length: int, genre: string, studioname: string, producerc#: int) MovieStar(name: string, address: string, gender: char, birthdate: date) StarsIn(movieTitle: string, movieyear: string, starname: string) MovieExec(name: string, address: string, CERT#: int, networth: int) Studio(name: string, address: string, presc#: int) 1 Introduction Translating an arbitrary SQL query into a logical query plan (i.e., a relational algebra expression) is a complex task. In these course notes we try to explain the most important elements of this translation by making the following simplifying assumptions: Since the latest version of SQL is a very large and complex language (including features like recursion, stored procedures, user defined functions,... ) we will focus here on the so-called SQL-92 subset of the language, which can be considered as the traditional heart of SQL 1
2 (comprising only the traditional select-from-where queries, aggregation, etc). In addition, we will consider a set-based semantics of SQL. Recall that in a set-based semantics, no duplicates occur in input relations or query results. The real semantics of SQL, in contrast, is bag-based. In a bag-based semantics duplicates do occur in relations and query results. Although the presence or absence of duplicates can often be ignored (as we do in these notes), they can lead to different results for queries involving aggregation (e.g., when we want to sum the query results). In practice, therefore, the translation of SQL into a logical query plan is even more involved than described here. It is nevertheless founded on the same principles. We will use expressions in the extended relational algebra (see section 5.2 in the book) interpreted over sets as logical query plans. Provisio To exclude ambiguities, we will assume without loss of generality in what follows that all occurrences of relation symbols in a SQL statement are assigned a distinct name through the alias mechanism of SQL. In other words: we hence assume implicitly that SQL statements in which a relation symbol occurs multiple times, like, for example, SELECT * FROM R, R is rewritten into a SQL statement of the form SELECT * FROM R, R R2 in which each occurrence is given a distinct (alias) name. Such rewriting is straightforward to do algorithmically, and can hence be done as a preprocessing step before execution of the algorithm described below. 2 Select-from-where statements without subqueries Consider a general SELECT-FROM-WHERE statement of the form SELECT Select-list FROM R 1,..., R 2 T 2,... WHERE Where-condition When the statement does not use subqueries in its where-condition, we can easily translate it into the relational algebra as follows: Note that: π Select-list σ Where-condition (R 1 ρ T2 (R 2 ) ). 2
3 1. An alias R 2 T 2 in the FROM-clause corresponds to a renaming ρ T2 (R 2 ). 2. It is possible that there is no WHERE clause. In that case, it is of course unnecessary to include the selection σ in the relational algebra expression. 3. If we omit the projection (π) we obtain the translation of the following special case: SELECT * FROM R 1,..., R 2 T 2,... WHERE Where-condition Example 1. Consider the following SELECT-FROM-WHERE statement. SELECT movietitle FROM StarsIn, MovieStar WHERE starname = name AND birthdate = 1960 Its translation is as follows: π movietitle σ starname=name (StarsIn MovieStar). birthdate= Normalizing Where-subqueries into Exists and Not Exists form In Section 2 we have considered the special case of translating select-fromwhere statements in which subqueries do not occur. In general, however, we also have to be able to translate statements in which such subqueries do occur. Subqueries can occur in the WHERE clause through the operators =, <, >, <=, >=, <>; through the quantifiers ANY, or ALL; or through the operators EXISTS and IN and their negations NOT EXISTS and NOT IN. We can easily rewrite all of these cases using only EXISTS and NOT EXISTS, however, as illustrated next. Example 2. The SQL-statement SELECT movietitle FROM StarsIn WHERE starname IN (SELECT name FROM MovieStar WHERE birthdate = 1960) can be rewritten equivalently as 3
4 SELECT movietitle FROM StarsIn WHERE EXISTS (SELECT name FROM MovieStar WHERE birthdate = 1960 AND name = starname) Example 3. The SQL-statement SELECT name FROM MovieExec WHERE networth >= ALL (SELECT E.netWorth FROM MovieExec E) can be rewritten equivalently as SELECT name FROM MovieExec WHERE NOT EXISTS(SELECT E.netWorth FROM MovieExec E WHERE networth < E.netWorth) Example 4. Consider relations R(A, B) and S(C). Then SELECT C FROM S WHERE C IN (SELECT SUM(B) FROM R GROUP BY A) can be rewritten as SELECT C FROM S WHERE EXISTS (SELECT SUM(B) FROM R GROUP BY A HAVING SUM(B) = C) Without loss of generality we will hence assume in what follows that all subqueries in the WHERE conditions are of the form EXISTS or NOT EXISTS. 4 Context relations To translate a query with subqueries into the relational algebra, it seems a logical strategy to work by recursion: first translate the subqueries and then combine the translated results into a translation for the entire SQL statement. If the subqueries contain subqueries themselves, we again translate the latter first continuing recursively until we reach a level that does not contain subqueries. 4
5 For subqueries that do not contain subqueries themselves, we could think that we can simply apply the method from Section 2. There is one complication, however: the subquery can refer to attributes of relations appearing in the FROM list of one of the outer lying queries. This is known as correlated subqueries. Example 5. The following query contains a subquery that refers to the starname attribute of the outer relation StarsIn. SELECT movietitle FROM StarsIn WHERE EXISTS (SELECT name FROM MovieStar WHERE birthdate = 1960 AND name = starname) We call the outer relations from which a correlated subquery uses certain attributes context relations for the subquery. Note that a subquery can have multiple context relations. We call the attributes of the context relations the parameters of the subquery. Note that not all of the parameters must actually occur in the subquery. Example 6. In Example 5, StarsIn is hence a context relation for the subquery. (In this example, it is also the only context relation.) The corresponding parameters are all attributes of StarsIn, i.e., movietitle, movieyear, and starname. Translating select-from-where subqueries To translate a SELECT FROM WHERE statement that is used as a subquery we must make the following modifications to the method from Section 2: We must add all context relations to the cartesian product of the relations in the FROM list; We must add all parameters as attributes to the projection π. Example 7. With these modifications, the subquery from Example 5: SELECT name FROM MovieStar WHERE birthdate = 1960 AND name = starname is translated into π movietitle,movieyear,starname,name σ birthdate=1960 (StarsIn MovieStar). name=starname Note how we have added the context relation StarsIn to the cartesian product, and how we have added the parameters movietitle, movieyear and starname (the attributes of StarsIn) to the projection π. 5
6 5 De-correlation of subqueries appearing in a conjunctive Where condition Consider again a general statement of the form SELECT Select-list FROM From-list WHERE Where-condition in which subqueries may occur in the WHERE condition. In the previous two examples we have only translated the subqueries. In this section we discuss how we can translate the select-statements in which these subqueries occur. For the time being we will make the following simplifying assumption (it will be lifted in Section 7): The WHERE-condition is a conjunction (AND) of select-from-where subqueries, possibly with an additional condition that does not contain subqueries. In other words, the WHERE-condition is of the form ψ AND EXISTS(Q) AND AND NOT EXISTS(P ) AND where ψ denotes the subquery-free condition and Q and P are select-statements (possibly with further select-statement subqueries of their own). The translation proceeds in four steps: 1. Translate the subquery-free part 2. De-correlate the EXISTS subqueries 3. De-correlate the NOT EXISTS subqueries 4. Apply the projection π Select-list We detail these steps next. Careful! Our statement contains subqueries, but we must not forget that the statement itself can be a subquery of a containing query! 5.1 Translating the subquery-free part Consider the subquery-free part of our query, ignore the Select-list: SELECT * FROM From-list WHERE ψ 6
7 We will translate it using the method of Section 2, but need to also include the following context relations: When translating the subquery-free part we must include all context relations for which parameters occur in ψ. In addition, we must also include all context relations for which parameters only occur in NOT EXISTS subqueries. Context relations whose parameters only occur in EXISTS subqueries need not be taken into account when translating the subquery-free part. The relational algebra expression that we hence obtain is of the form σ ψ (E), where E is a cartesian product of all relations in the From-list, to which we add context relations for which parameters occur in ψ, or for which parameters occur in some NOT EXISTS subquery. In what follows, we will gradually adapt and refine E when de-correlating the subqueries. Example 8. Consider the following nested statement over the relations R(A, B) and S(C): SELECT R1.A, R1.B FROM R R1, S WHERE EXISTS (SELECT R2.A, R2.B FROM R R_2 WHERE R2.A = R1.B AND EXISTS (SELECT R3.A, R3.B FROM R R3 WHERE R3.A = R2.B AND R3.B = S.C)) Let us denote the entire query by Q 1 ; the middle subquery by Q 2 ; and the inner subquery by Q 3. Now assume that we are currently translating Q 2. The subquery-free part of Q 2 is as follows: SELECT * FROM R R_2 WHERE R_2.A = R_1.B Its translation is hence: σ R2.A=R 1.B(ρ R2 (R) ρ R1 (R)) ( ) Note that, although S is a context relation for Q 2, it does not appear in the translation. This is because the parameter S.C does not occur in the 7
8 subquery-free part of Q 2, but only in the subquery Q 3 itself. Since Q 3 is an EXISTS subquery, S does not need to be included in the cartesian product. In contrast, had Q 3 been a NOT EXISTS subquery, then we would have needed to include S. 5.2 De-correlating EXISTS subqueries After we have translated the subquery-free part, we translate all subqueries EXISTS(Q) in turn. By applying the entire translation algorithm described in these notes recursively to Q, we can already translate Q into a relational algebra expression E Q. Example 9. Let us continue the translation of Q 2 from Example 8. We must then first translate Q 3 as follows: σ R3.A=R 2.B (ρ R3 (R) ρ R2 (R) S) R 3.B=S.C Note that E Q3 query already specifies for which tuples in R 2 and R 3 correct tuples in S exist (together with the values of these tuples). We can use this information to de-correlate Q 2 as follows. Let A 1,..., A p be the list of all parameters of context relations of Q. We can translate EXISTS(Q) by joining E with the space of parameters for E Q, namely π A1,...,A p (E Q ): E := E π A1,...,A p (E Q ). Example 10. Let us continue the translation of Q 2 from Examples 8 and 9. We have so far: E = ρ R2 (R) ρ R1 (R) E Q3 = σ R3.A=R 2.B (ρ R3 (R) ρ R2 (R) S) R 3.B=S.C By joining E and E Q3 on the parameters of Q 3 (i.e., R 2.A and R 2.B) we ensure that we link the correct tuples from E with the correct tuples of E Q3. In particular, we calculate the tuples in R 1 for which tuples in R 2, R 3, and S exist that satisfy the requirements of Q 2 (together with the values of these tuples). Actually, we can simplify this expression somewhat. Indeed, note that the following are equivalent because we join R 2 with a subset of itself: (ρ R1 (R) ρ R2 (R)) π R2.A,R 2.B,S.C σ R3.A=R 2.B (ρ R3 (R) ρ R2 (R) S) R 3.B=S.C and ρ R1 (R) π R2.A,R 2.B,S.C σ R3.A=R 2.B (ρ R3 (R) ρ R2 (R) S) R 3.B=S.C 8
9 This simplification can always be done: before joining with π A1,...,A p (E Q ), we can remove from E all context relations for Q. Indeed, all relevant tuples for these context relations are already present in the parameter space. Hence, if we denote the omission of the context relations in E by Ê, we can summarize the adaption of E as follows: E := Ê π A 1,...,A p (E Q ) Example 11. By combining Examples 8 and 9 we can translate Q 2 from Example 8 as follows: σ R2.A=R 1.B(ρ R1 (R) π R2.A,R 2.B,S.C σ R3.A=R 2.B (ρ R3 (R) ρ R2 (R) S)) R 3.B=S.C Notice that we have been able to remove the relation ρ R2 (R) from the cartesian product ( ) that was the translation of the subquery-free part of Q 2 in Example 8. Because of this omission, the reduces to a cartesian product. (Indeed, recall that the natural join of two relations without common attributes is equivalent to the cartesian product of those two relations.) Let us denote the expression above by E 2. The translation of the entire query Q 1 from Example 8 then is as follows. π R1.A,R 1.B(E 2 ) Here, we have been able to remove both ρ R1 (R) and S from the cartesian product originating from translation of the subquery-free part of Q 1. This finishes our discussion on how we can de-correlate subqueries of the form EXISTS(Q). We repeat this method for all EXISTS subqueries, one by one. For each such subquery, we hence add a join to E, and remove if possible context relations from the cartesian product. It is important to stress that each relation can only be removed once; if a relation has only been removed when de-correlating a previous subquery, then we cannot remove this relation again when translating the current subquery. 5.3 De-correlating NOT EXISTS subqueries After de-correlation of the EXISTS(Q) subqueries we can de-correlate the NOT EXISTS(P ) subqueries. Just as in the case of the EXISTS subqueries, this will require modifying E. We start by translating P into a relational algebra expression E P. Again we consider the list A 1,..., A p of all parameters of context relations of P. Since we now have to express NOT EXISTS(P ) we do not join E with E P, but perform an anti-join of E with E P : E := E π A1,...,A p (E P ) Here, the antijoin of two relations R and S is defined as R (R S). In an antijoin, it is required that R contains all attributes of S. 9
10 We add such an anti-join to E for every NOT EXISTS subquery. Note, however, that in this case we cannot remove context relations from the cartesian product obtained by translating the From-list. (Why not?) 5.4 Translating the select list Finally, we must apply to E the projection π Select-list. If the query that we are translating is used itself as a subquery in an outer lying query, then we must of course take care to add all parameters to Select-list. 6 Operations on relations SQL-expressions do not simply consist of select-statements, but can also be formed using the operations UNION, INTERSECT, and EXCEPT (possibly in conjunction with the modifier ALL); and with the join-operations CROSS JOIN, NATURAL JOIN, JOIN ON, and OUTER JOIN. Notice that such expressions may also occur as subqueries. In this section, we discuss how to translate these operations. We begin with the join operations. 6.1 Join operations Consider first the SQL-expression Q 1 CROSS JOIN Q 2 ( ) where Q 1 and Q 2 are themselves also SQL-expressions. We first translate Q 1 and Q 2 into the relational algebra; which yields relational algebra expressions E 1 and E 2. At first sight we may think that we can then simply translate the expression ( ) above as E 1 E 2. This translation is incorrect, however, when Q 1 CROSS JOIN Q 2 is used as a subquery. Indeed, in that case, Q 1 and Q 2 can be correlated subqueries that may have parameters in common. In order to be able to continue using the translation strategy from Section 5, we need to synchronize the correlated subqueries on the common parameters. This can be done using a natural join over the common parameters, simply taking: E 1 E 2 instead of E 1 E 2. (Since, according to the SQL specification, the operands of a CROSS JOIN must have disjoint sets of attributes, any attributes common to both E 1 and E 2 must be parameters. Hence, it is not necessary to specify that only the parameters should be equal using a theta-join. A natural join suffices.) Example 12. To illustrate this discussion, consider the relations R(A, B) and S(C), as well as the following query. 10
11 SELECT S1.C, S2.C FROM S S1, S S2 WHERE EXISTS ( (SELECT R1.A, R1.B FROM R R1 WHERE A = S1.C AND B = S2.C) CROSS JOIN (SELECT R2.A, R2.B FROM R R2 WHERE B = S1.C) ) Let us translate its EXISTS subquery containing the cross join. The translations of Q 1 and Q 2 are as follows. E 1 = π S1.C,S 2.C,R 1.A,R 1.B σ A=S1.C (ρ R1 (R) ρ S1 (S) ρ S2 (S)) B=S 2.C E 2 = π S1.C,R 2.A,R 2.B σ B=S1.C (ρ R2 (R) ρ S1 (S)) Notice that Q 1 and Q 2 have one context relation in common, namely S 1. The translation of the EXISTS subquery is then: E 1 E 2. Notice that the natural join occurs only on the common parameter S 1.C. In a similar manner we can translate the other SQL join-operations. We only have to take care to use the correct algebra operator in the translation: for NATURAL JOIN; theta-join for JOIN ON; and outer join o for OUTER JOIN. Example 13. Here is a simple example of a theta-join. The join expression is not a correlated subquery, and hence we do not need to take into account context relations. Movie JOIN StarsIn ON title = movietitle AND year = movieyear It is translated as follows: Movie StarsIn. title=movietitle year=movieyear 6.2 Union, Intersect and Except Next consider a SQL-expression Q 1 UNION Q 2 ( ) 11
12 As before, we first translate Q 1 and Q 2 into the relational algebra-expressions E 1 and E 2. Unfortunately, however, we cannot simply translate by E 1 E 2 : in the relational algebra, both operands of a union must have the same set of attributes in their schema (see Section 2.2 in TCB). When Q 1 and Q 2 have different context relations, they will also have different sets of parameters. In that case, E 1 and E 2 will have different sets of attributes in their schema. Example 14. Let us reconsider the query from Example 12. Suppose that we replace the CROSS JOIN by UNION. We cannot simply take the union E 1 E 2 : E 1 has four attributes, whereas E 2 only has three. The solution consists of padding E 1 with the context relations of Q 2 and, vice versa, padding E 2 with the contex relations of Q 1. This padding is done by means of a cartesian product. Formally, let: V 1,..., V m be the context relations of Q 1 that do not occur in Q 2 ; W 1,..., W n be the context relations of Q 2 that do not occur in Q 1. We then translate SQL-expression ( ) as: π... (E 1 W 1 W n ) π... (E 2 V 1 V m ) Here, the projections π... need to ensure that the parameters of a context relation occur in the same column position in both subexpressions, and that the other attributes have the same name. Example 15. Consider the translation of the EXISTS subquery from Example 12, but with UNION instead of CROSS JOIN. There is only one V, namely S 2. There are no W s because the only context relation of Q 2 is S 1, which is also a context relation of Q 1. The translation of the EXISTS subquery is hence: π S1.C,S 2.C,R 1.A A,R 1.B B(E 1 ) π S1.C,S 2.C,R 2.A A,R 2.B B(E 2 ρ S2 (S)) In a similar manner we can translate INTERSECT and EXCEPT using instead of for INTERSECT and instead of for EXCEPT. Example 16. Here is a simple example of an EXCEPT expression. This is not a correlated subquery, and hence there is no need to take context relations into account. (SELECT name, address from MovieStar) EXCEPT (SELECT name, address from MovieExec) Its translation is (π name,address (MovieStar) π name,address (MovieExec)). 12
13 7 The non-conjunctive case How can we translate WHERE-conditions that contain subqueries, but that are not of the conjunctive form required in Section 5? We first note that we can always rewrite any WHERE condition as a disjunction (OR) of the form: ϕ 1 OR ϕ 2 OR... where every ϕ i is a conjunction (AND) of subqueries, possibly with an additional subquery-free condition. Rewriting an arbitrary WHERE condition into this so-called disjunctive normal form can be done by repeatedly applying the laws of De Morgan 1 and distributivity 2 of AND over OR. Example 17. The WHERE condition NOT EXISTS Q AND (A=B OR C<6) with Q a subquery is already in normal form: it is a conjunction of a subquery and a condition without subqueries. In this case there is hence only one conjunction: the entire condition itself. The WHERE condition A=B OR EXISTS Q is also in normal form. In this case there are two conjunctions, each consisting of a single atomic condition. The WHERE condition A=B AND NOT(EXISTS Q AND C<6) is not in normal form. We can rewrite it into the desired form by one application of De Morgan followed by one application of distributivity: A=B AND (NOT EXISTS Q OR C>=6) (A=B AND NOT EXISTS Q) OR (A=B AND C>=6) To translate an arbitrary select-statement we hence first rewrite its WHERE condition into disjunctive normal form: 1 (p q) = p q, (p q) = p q. 2 (p q) r = (p r) (q r) 13
14 SELECT Select-list FROM From-list WHERE ϕ 1 OR ϕ 2 OR... We then treat the disjunction as a union: (SELECT Select-list UNION (SELECT Select-list UNION... FROM From-list FROM From-list WHERE ϕ 1 ) WHERE ϕ 2 ) Since every select-statement subquery of this union has a conjunctive WHERE condition ϕ i, we can translate these subqueries using the method from paragraph 5. The UNION operations themselves can then be translated as discussed in Section Group by and Having Up until now we have only considered select-from-where statements without aggregation. In general, however, a select-statement can also contain GROUP BY and HAVING clauses: SELECT Select-list FROM From-list WHERE Where-condition GROUP BY Group-list HAVING Having-condition Note that such a statement can also occur as a subquery! To translate such a statement, we first translate its FROM WHERE part: SELECT * FROM From-list WHERE Where-condition Let E be the relational algebra expression hence obtained. (Note in particular that the where-condition may contain subqueries in non-conjunctive form, in which case we have to apply the techniques from Section 7 to obtain E). Let A 1,..., A n be the parameters of the statement (if it occurs as a subquery). The translation of the entire statement then is the following. π A1,...,A n,select-list σ Having-condition γ A1,...,A n,group-list,agg-list(e). Here, Agg-list consists of all aggregation operations performed in the Having condition or Select-list. If the HAVING clause is absent, then the σ can be omitted. Example 18. The SQL statement 14
15 SELECT name, SUM(length) FROM MovieExec, Movie WHERE cert# = producerc# GROUP BY name HAVING MIN(year) < 1930 is thus translated into π name,sum(length) σ MIN(year)<1930 γ name,min(year),sum(length) σ cert#=producerc# (MovieExec Movie). Example 19. The subquery from Example 4: SELECT SUM(B) FROM R GROUP BY A HAVING SUM(B) = C is translated into π C,SUM(B) σ C=SUM(B) γ C,A,SUM(B) (R S). Notice how we have added the context relation S to the cartesian product, and how we have added the parameter C to the operators γ and π. 9 Subqueries in the From-list Subqueries in SQL can not only occur in the WHERE condition of a query, but also in the FROM list. Example 20. The following statement contains a subquery in its From-list: SELECT movietitle FROM StarsIn, (SELECT name FROM MovieStar WHERE birthdate = 1960) M WHERE starname = M.name The translation of such FROM-subqueries is straightforward. Just like we normally translate a From-list without subqueries by means of a cartesian product: FROM R 1, R 2,... (R 1 R 2 ) we translate a From-list with subqueries analogously: FROM (Q 1 ), (Q 2 ),... (E 1 E 2 ) Here, E 1, E 2,..., are the relational algebra translations of Q 1, Q 2,... 15
16 Example 21. We hence translate the query from Example 20 as follows: π movietitle σ starname=m.name (StarsIn ρ M π name σ birthdate=1960 (MovieStar)). 9.1 Lateral subqueries in SQL-99 SQL-99 also allows FROM-subqueries to be correlated with relations or subqueries that precede it in the From-list. Example 22. The following statement is legal in SQL-99 (but not in SQL- 92). It uses the keyword LATERAL to indicate that a subquery is correlated. SELECT S.movieTitle FROM (SELECT name FROM MovieStar WHERE birthdate = 1960) M, LATERAL (SELECT movietitle FROM StarsIn WHERE starname = M.name) S To translate such subqueries it suffices to replace the cartesian product (which we normally use to translate From-lists) by a natural join of the parameters. It is important to note, however, that context relations need no longer be base relations, but can themselves also be translations of earlier subqueries in the From-list. Just as with EXISTS subqueries, we can omit preceding context relations if those are already contained in the parameters space of a subsequent subquery. Example 23. We translate the statement from Example 22 as follows. We start by translating the first subquery: E 1 = π name σ birthdate=1960 (MovieStar). We then translate the second subquery, which has E 1 as a context relation: E 2 = π name,movietitle σ starname=name (StarsIn E 1 ). We would then translate the entire FROM clause by means of a join and not by means of a cartesian product (because of the correlation): π movietitle (E 1 E 2 ). In this example, however, all relevant tuples from E 1 are already contained in E 2, and hence we can omit E 1. The obtained end result is then π movietitle (E 2 ). 16
17 10 Subqueries in the Select-list Finally, SQL also allows subqueries in the Select-list; the so-called scalar subqueries. These subqueries must always return a single value. They can nevertheless be correlated. In that case they must hence return a single value for each possible assignment of values to the parameters. Example 24. Consider the relations R(A, B) and S(C), and assume that A is a key for R. Then the following query is allowed in SQL. SELECT C, (SELECT B FROM R WHERE A=C) FROM S Consider in addition a relation T (D, E). The following is also allowed. SELECT D, (SELECT B FROM R WHERE A=D AND B>SUM(E)) FROM T GROUP BY D Scalar subqueries in the select-list can be rewritten as LATERAL subqueries in de From-list. Since we already know how to translate the latter, we hence also know how to translate the former. Formally, the rewriting of subqueries in the select-list goes as follows. Consider a general selectstatement with a subquery in its select-list. SELECT Select-list, (Q) FROM... WHERE... GROUP BY... HAVING... Since Q must be a scalar subquery, it can only have one output attribute, say attribute A. We then rewrite as follows: SELECT Select-list, T.A FROM (SELECT * WHERE... GROUP BY... HAVING... ), LATERAL (Q) T If the subquery has parameters that are aggregation operators (such as, e.g., the parameter SUM(E) in the second expression of Example 24) we need to fine-tune this rewriting by including these aggregations to the γ operator in the translation of the first subquery (which corresponds to the original statement). 17
18 Remark: In practice a query processor need not implement subqueries in the select list in this manner. It is often more efficient to leave the subquery correlated, and to execute it separately for each possible assignment of values to the parameters. In this way, it is also easier to verify that the subquery always returns only in a single value. 11 The Count bug There is a type of subqueries for which the translation algorithm above is incorrect, namely the subqueries that use COUNT without an accompanying GROUP BY. To illustrate, consider the following example query over the relations R(A, B) and T (A, C): SELECT T.A FROM T WHERE T.C = (SELECT COUNT(R.B) FROM R WHERE R.A=T.A) If T contains the tuple (5, 0) and R contains no tuple with A = 5, then the output of the query certainly contains the value 5. Let us translate this query into the relational algebra. First, we rewrite the subquery into the EXISTS form: SELECT T.A FROM T WHERE EXISTS (SELECT COUNT(R.B) FROM R WHERE R.A=T.A HAVING COUNT(R.B) = T.C) The relational algebra translation is then: π T.A σ COUNT(R.B)=T.C γ T.A,T.C,COUNT(R.B) σ R.A=T.A (R T ) If R contains no tuple with A = 5, then the section σ R.A=T.A will eliminate the T -tupel (5, 0). Hence, in that case, 5 will not occur in the output, which is incorrect. This problem is well-known and only poses itself with these kinds of subqueries. The solution here consists in replacing the cartesian product with the context relations (in our example: T ) by an outer join. This way, the parameters for which the subquery yields an empty results are still retained in the parameter space. Concretely, our example subquery would then be translated as π T.A σ COUNT(R.B)=T.C γ T.A,T.C,COUNT(R.B) (R o R R.A=T.A (Here, o R denotes the right outer join.) On our hypothetical database, the outer join produces a tuple (T.A = 5, T.C = 0, R.A =, R.B = ). T ). 18
19 If we then implement the aggregation operator γ in such a way that the COUNT of a single equals 0, the evaluation proceeds correctly. 19
Relational Databases
Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 18 Relational data model Domain domain: predefined set of atomic values: integers, strings,... every attribute
Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries
Relational Algebra. Basic Operations Algebra of Bags
Relational Algebra 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 --- symbols
Chapter 5. SQL: Queries, Constraints, Triggers
Chapter 5 SQL: Queries, Constraints, Triggers 1 Overview: aspects of SQL DML: Data Management Language. Pose queries (Ch. 5) and insert, delete, modify rows (Ch. 3) DDL: Data Definition Language. Creation,
Execution Strategies for SQL Subqueries
Execution Strategies for SQL Subqueries Mostafa Elhemali, César Galindo- Legaria, Torsten Grabs, Milind Joshi Microsoft Corp With additional slides from material in paper, added by S. Sudarshan 1 Motivation
Introduction to tuple calculus Tore Risch 2011-02-03
Introduction to tuple calculus Tore Risch 2011-02-03 The relational data model is based on considering normalized tables as mathematical relationships. Powerful query languages can be defined over such
Chapter 14: Query Optimization
Chapter 14: Query Optimization Database System Concepts 5 th Ed. See www.db-book.com for conditions on re-use Chapter 14: Query Optimization Introduction Transformation of Relational Expressions Catalog
3. Mathematical Induction
3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)
Relational Database: Additional Operations on Relations; SQL
Relational Database: Additional Operations on Relations; SQL Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin Overview The course packet
MapReduce examples. CSE 344 section 8 worksheet. May 19, 2011
MapReduce examples CSE 344 section 8 worksheet May 19, 2011 In today s section, we will be covering some more examples of using MapReduce to implement relational queries. Recall how MapReduce works from
SUBQUERIES AND VIEWS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6
SUBQUERIES AND VIEWS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6 String Comparisons and GROUP BY 2! Last time, introduced many advanced features of SQL, including GROUP BY! Recall:
Chapter 13: Query Optimization
Chapter 13: Query Optimization Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 13: Query Optimization Introduction Transformation of Relational Expressions Catalog
SQL: Queries, Programming, Triggers
SQL: Queries, Programming, Triggers CSC343 Introduction to Databases - A. Vaisman 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for
Semantic Errors in SQL Queries: A Quite Complete List
Semantic Errors in SQL Queries: A Quite Complete List Christian Goldberg, Stefan Brass Martin-Luther-Universität Halle-Wittenberg {goldberg,brass}@informatik.uni-halle.de Abstract We investigate classes
Relational Division and SQL
Relational Division and SQL Soulé 1 Example Relations and Queries As a motivating example, consider the following two relations: Taken(,Course) which contains the courses that each student has completed,
Testing LTL Formula Translation into Büchi Automata
Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland
Introduction to database design
Introduction to database design KBL chapter 5 (pages 127-187) Rasmus Pagh Some figures are borrowed from the ppt slides from the book used in the course, Database systems by Kiefer, Bernstein, Lewis Copyright
Example Instances. SQL: Queries, Programming, Triggers. Conceptual Evaluation Strategy. Basic SQL Query. A Note on Range Variables
SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Example Instances We will use these instances of the Sailors and Reserves relations in our
SQL: Queries, Programming, Triggers
SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in
Relational Algebra 2. Chapter 5.2 V3.0. Copyright @ Napier University Dr Gordon Russell
Relational Algebra 2 Chapter 5.2 V3.0 Copyright @ Napier University Dr Gordon Russell Relational Algebra - Example Consider the following SQL to find which departments have had employees on the `Further
23. RATIONAL EXPONENTS
23. RATIONAL EXPONENTS renaming radicals rational numbers writing radicals with rational exponents When serious work needs to be done with radicals, they are usually changed to a name that uses exponents,
More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan
More on SQL Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan SELECT A1, A2,, Am FROM R1, R2,, Rn WHERE C1, C2,, Ck Interpreting a Query
COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries
COMP 5138 Relational Database Management Systems Week 5 : Basic COMP5138 "Relational Database Managment Systems" J. Davis 2006 5-1 Today s Agenda Overview Basic Queries Joins Queries Aggregate Functions
Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL
Chapter 9 Joining Data from Multiple Tables Oracle 10g: SQL Objectives Identify a Cartesian join Create an equality join using the WHERE clause Create an equality join using the JOIN keyword Create a non-equality
4. SQL. Contents. Example Database. CUSTOMERS(FName, LName, CAddress, Account) PRODUCTS(Prodname, Category) SUPPLIERS(SName, SAddress, Chain)
ECS-165A WQ 11 66 4. SQL Contents Basic Queries in SQL (select statement) Set Operations on Relations Nested Queries Null Values Aggregate Functions and Grouping Data Definition Language Constructs Insert,
Relational Algebra and SQL
Relational Algebra and SQL Johannes Gehrke [email protected] http://www.cs.cornell.edu/johannes Slides from Database Management Systems, 3 rd Edition, Ramakrishnan and Gehrke. Database Management
Chapter 13: Query Processing. Basic Steps in Query Processing
Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing
Advance DBMS. Structured Query Language (SQL)
Structured Query Language (SQL) Introduction Commercial database systems use more user friendly language to specify the queries. SQL is the most influential commercially marketed product language. Other
Databases 2011 The Relational Model and SQL
Databases 2011 Christian S. Jensen Computer Science, Aarhus University What is a Database? Main Entry: da ta base Pronunciation: \ˈdā-tə-ˌbās, ˈda- also ˈdä-\ Function: noun Date: circa 1962 : a usually
Data Integration. Maurizio Lenzerini. Universitá di Roma La Sapienza
Data Integration Maurizio Lenzerini Universitá di Roma La Sapienza DASI 06: Phd School on Data and Service Integration Bertinoro, December 11 15, 2006 M. Lenzerini Data Integration DASI 06 1 / 213 Structure
Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products
Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing
The SQL Query Language. Creating Relations in SQL. Referential Integrity in SQL. Basic SQL Query. Primary and Candidate Keys in SQL
COS 597A: Principles of Database and Information Systems SQL: Overview and highlights The SQL Query Language Structured Query Language Developed by IBM (system R) in the 1970s Need for a standard since
Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy
Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety
Oracle SQL. Course Summary. Duration. Objectives
Oracle SQL Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row and column data
SQLMutation: A tool to generate mutants of SQL database queries
SQLMutation: A tool to generate mutants of SQL database queries Javier Tuya, Mª José Suárez-Cabal, Claudio de la Riva University of Oviedo (SPAIN) {tuya cabal claudio} @ uniovi.es Abstract We present a
Query Processing. Q Query Plan. Example: Select B,D From R,S Where R.A = c S.E = 2 R.C=S.C. Himanshu Gupta CSE 532 Query Proc. 1
Q Query Plan Query Processing Example: Select B,D From R,S Where R.A = c S.E = 2 R.C=S.C Himanshu Gupta CSE 532 Query Proc. 1 How do we execute query? One idea - Do Cartesian product - Select tuples -
Schema Mappings and Data Exchange
Schema Mappings and Data Exchange Phokion G. Kolaitis University of California, Santa Cruz & IBM Research-Almaden EASSLC 2012 Southwest University August 2012 1 Logic and Databases Extensive interaction
Formal Languages and Automata Theory - Regular Expressions and Finite Automata -
Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March
Integrating Pattern Mining in Relational Databases
Integrating Pattern Mining in Relational Databases Toon Calders, Bart Goethals, and Adriana Prado University of Antwerp, Belgium {toon.calders, bart.goethals, adriana.prado}@ua.ac.be Abstract. Almost a
SQL Query Evaluation. Winter 2006-2007 Lecture 23
SQL Query Evaluation Winter 2006-2007 Lecture 23 SQL Query Processing Databases go through three steps: Parse SQL into an execution plan Optimize the execution plan Evaluate the optimized plan Execution
Exercises. a. Find the total number of people who owned cars that were involved in accidents
42 Chapter 4 SQL Exercises 4.1 Consider the insurance database of Figure 4.12, where the primary keys are underlined. Construct the following SQL queries for this relational database. a. Find the total
SQL SELECT Query: Intermediate
SQL SELECT Query: Intermediate IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview SQL Select Expression Alias revisit Aggregate functions - complete Table join - complete Sub-query in where Limiting
This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.
3. Axioms of Set theory Before presenting the axioms of set theory, we first make a few basic comments about the relevant first order logic. We will give a somewhat more detailed discussion later, but
Reading 13 : Finite State Automata and Regular Expressions
CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model
Basics of Dimensional Modeling
Basics of Dimensional Modeling Data warehouse and OLAP tools are based on a dimensional data model. A dimensional model is based on dimensions, facts, cubes, and schemas such as star and snowflake. Dimensional
Likewise, we have contradictions: formulas that can only be false, e.g. (p p).
CHAPTER 4. STATEMENT LOGIC 59 The rightmost column of this truth table contains instances of T and instances of F. Notice that there are no degrees of contingency. If both values are possible, the formula
Comp 5311 Database Management Systems. 3. Structured Query Language 1
Comp 5311 Database Management Systems 3. Structured Query Language 1 1 Aspects of SQL Most common Query Language used in all commercial systems Discussion is based on the SQL92 Standard. Commercial products
Evaluation of Expressions
Query Optimization Evaluation of Expressions Materialization: one operation at a time, materialize intermediate results for subsequent use Good for all situations Sum of costs of individual operations
Information Systems SQL. Nikolaj Popov
Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria [email protected] Outline SQL Table Creation Populating and Modifying
Inside the PostgreSQL Query Optimizer
Inside the PostgreSQL Query Optimizer Neil Conway [email protected] Fujitsu Australia Software Technology PostgreSQL Query Optimizer Internals p. 1 Outline Introduction to query optimization Outline of
CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs
CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce
C H A P T E R Regular Expressions regular expression
7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun
Relational Algebra. Module 3, Lecture 1. Database Management Systems, R. Ramakrishnan 1
Relational Algebra Module 3, Lecture 1 Database Management Systems, R. Ramakrishnan 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model
9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes
The Scalar Product 9.4 Introduction There are two kinds of multiplication involving vectors. The first is known as the scalar product or dot product. This is so-called because when the scalar product of
Sample Induction Proofs
Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given
Database Constraints and Design
Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of
Mathematical Induction
Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,
26 Integers: Multiplication, Division, and Order
26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue
Lecture 6: Query optimization, query tuning. Rasmus Pagh
Lecture 6: Query optimization, query tuning Rasmus Pagh 1 Today s lecture Only one session (10-13) Query optimization: Overview of query evaluation Estimating sizes of intermediate results A typical query
Chapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
6.2 Permutations continued
6.2 Permutations continued Theorem A permutation on a finite set A is either a cycle or can be expressed as a product (composition of disjoint cycles. Proof is by (strong induction on the number, r, of
Introduction. The Quine-McCluskey Method Handout 5 January 21, 2016. CSEE E6861y Prof. Steven Nowick
CSEE E6861y Prof. Steven Nowick The Quine-McCluskey Method Handout 5 January 21, 2016 Introduction The Quine-McCluskey method is an exact algorithm which finds a minimum-cost sum-of-products implementation
SQL Tables, Keys, Views, Indexes
CS145 Lecture Notes #8 SQL Tables, Keys, Views, Indexes Creating & Dropping Tables Basic syntax: CREATE TABLE ( DROP TABLE ;,,..., ); Types available: INT or INTEGER REAL or FLOAT CHAR( ), VARCHAR( ) DATE,
COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012
Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about
Oracle Database 12c: Introduction to SQL Ed 1.1
Oracle University Contact Us: 1.800.529.0165 Oracle Database 12c: Introduction to SQL Ed 1.1 Duration: 5 Days What you will learn This Oracle Database: Introduction to SQL training helps you write subqueries,
Handout #1: Mathematical Reasoning
Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or
We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b
In this session, we ll learn how to solve problems related to place value. This is one of the fundamental concepts in arithmetic, something every elementary and middle school mathematics teacher should
Regular Expressions and Automata using Haskell
Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions
Applying Constraint Logic Programming to SQL Test Case Generation
Applying Constraint Logic Programming to SQL Test Case Generation Rafael Caballero, Yolanda García-Ruiz and Fernando Sáenz-Pérez Departamento de Sistemas Informáticos y Computación Universidad Complutense
How To Understand The Laws Of Algebra
Welcome to Math 19500 Video Lessons Prof. Department of Mathematics The City College of New York Fall 2013 An important feature of the following Beamer slide presentations is that you, the reader, move
7 Gaussian Elimination and LU Factorization
7 Gaussian Elimination and LU Factorization In this final section on matrix factorization methods for solving Ax = b we want to take a closer look at Gaussian elimination (probably the best known method
14.1 Rent-or-buy problem
CS787: Advanced Algorithms Lecture 14: Online algorithms We now shift focus to a different kind of algorithmic problem where we need to perform some optimization without knowing the input in advance. Algorithms
SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison
SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89 by Joseph Collison Copyright 2000 by Joseph Collison All rights reserved Reproduction or translation of any part of this work beyond that permitted by Sections
Matrix Algebra. Some Basic Matrix Laws. Before reading the text or the following notes glance at the following list of basic matrix algebra laws.
Matrix Algebra A. Doerr Before reading the text or the following notes glance at the following list of basic matrix algebra laws. Some Basic Matrix Laws Assume the orders of the matrices are such that
Boats bid bname color 101 Interlake blue 102 Interlake red 103 Clipper green 104 Marine red. Figure 1: Instances of Sailors, Boats and Reserves
Tutorial 5: SQL By Chaofa Gao Tables used in this note: Sailors(sid: integer, sname: string, rating: integer, age: real); Boats(bid: integer, bname: string, color: string); Reserves(sid: integer, bid:
Introduction to Querying & Reporting with SQL Server
1800 ULEARN (853 276) www.ddls.com.au Introduction to Querying & Reporting with SQL Server Length 5 days Price $4169.00 (inc GST) Overview This five-day instructor led course provides students with the
2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA www.sybex.com
Essential SQL 2 Essential SQL This bonus chapter is provided with Mastering Delphi 6. It is a basic introduction to SQL to accompany Chapter 14, Client/Server Programming. RDBMS packages are generally
8 Divisibility and prime numbers
8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express
6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10
Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you
Continued Fractions and the Euclidean Algorithm
Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction
CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model
CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 The Relational Model CS2 Spring 2005 (LN6) 1 The relational model Proposed by Codd in 1970. It is the dominant data
3. Relational Model and Relational Algebra
ECS-165A WQ 11 36 3. Relational Model and Relational Algebra Contents Fundamental Concepts of the Relational Model Integrity Constraints Translation ER schema Relational Database Schema Relational Algebra
Oracle Database 11g SQL
AO3 - Version: 2 19 June 2016 Oracle Database 11g SQL Oracle Database 11g SQL AO3 - Version: 2 3 days Course Description: This course provides the essential SQL skills that allow developers to write queries
Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation
Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Abstract This paper discusses methods of joining SAS data sets. The different methods and the reasons for choosing a particular
A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX
ISSN: 2393-8528 Contents lists available at www.ijicse.in International Journal of Innovative Computer Science & Engineering Volume 3 Issue 2; March-April-2016; Page No. 09-13 A Comparison of Database
Week 4 & 5: SQL. SQL as a Query Language
Week 4 & 5: SQL The SQL Query Language Select Statements Joins, Aggregate and Nested Queries Insertions, Deletions and Updates Assertions, Views, Triggers and Access Control SQL 1 SQL as a Query Language
discuss how to describe points, lines and planes in 3 space.
Chapter 2 3 Space: lines and planes In this chapter we discuss how to describe points, lines and planes in 3 space. introduce the language of vectors. discuss various matters concerning the relative position
Introducing Microsoft SQL Server 2012 Getting Started with SQL Server Management Studio
Querying Microsoft SQL Server 2012 Microsoft Course 10774 This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server
Chapter 8. SQL-99: SchemaDefinition, Constraints, and Queries and Views
Chapter 8 SQL-99: SchemaDefinition, Constraints, and Queries and Views Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations) of a database
IT2305 Database Systems I (Compulsory)
Database Systems I (Compulsory) INTRODUCTION This is one of the 4 modules designed for Semester 2 of Bachelor of Information Technology Degree program. CREDITS: 04 LEARNING OUTCOMES On completion of this
[Refer Slide Time: 05:10]
Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture
Query Processing in Data Integration Systems
Query Processing in Data Integration Systems Diego Calvanese Free University of Bozen-Bolzano BIT PhD Summer School Bressanone July 3 7, 2006 D. Calvanese Data Integration BIT PhD Summer School 1 / 152
Data Structure: Relational Model. Programming Interface: JDBC/ODBC. SQL Queries: The Basic From
Data Structure: Relational Moel Relational atabases: Schema + Data Schema (also calle scheme): collection of tables (also calle relations) each table has a set of attributes no repeating relation names,
CONTENTS 1. Peter Kahn. Spring 2007
CONTENTS 1 MATH 304: CONSTRUCTING THE REAL NUMBERS Peter Kahn Spring 2007 Contents 2 The Integers 1 2.1 The basic construction.......................... 1 2.2 Adding integers..............................
Optimization of SQL Queries in Main-Memory Databases
Optimization of SQL Queries in Main-Memory Databases Ladislav Vastag and Ján Genči Department of Computers and Informatics Technical University of Košice, Letná 9, 042 00 Košice, Slovakia [email protected]
1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:
Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of
Graham Kemp (telephone 772 54 11, room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.
CHALMERS UNIVERSITY OF TECHNOLOGY Department of Computer Science and Engineering Examination in Databases, TDA357/DIT620 Tuesday 17 December 2013, 14:00-18:00 Examiner: Results: Exam review: Grades: Graham
