Examples of Relational Value Assignments

Size: px
Start display at page:

Download "Examples of Relational Value Assignments"

Transcription

1 Examples of Relational Value Assignments Example Relvars - First Set Let relvar EMP contain sample data of the ID number and name of employees, displayed in tabular format as :- No Name 1 Jack 2 Jill Example Assignments Insertion Tuples may be inserted into EMP as follows :- EMP Insert Relational_Expression where Relational_Expression can be any relational expression whose value is of the same type as that of EMP. This can include relational literal values and relvar names, on their own or as part of a larger relational expression. or EMP <--Insert { { No <-- 3; Name <-- Fred } { No <-- 4; Name <-- Jane EMP <--Insert { { 3; Fred } { 4; Jane These two insertions, of a relvalue of 2 tuples, are logically equivalent. The former is a long-hand syntax; it specifies which value is assigned to which attribute within each tuple value. The latter is an abbreviated form; it requires the attribute values to be written in the default order, which is always the same order as that in which the attributes were specified in the declaration of the relvar; thus it is assumed that in the declaration of EMP, attribute No was specified first followed by attribute Name. The longhand forms allow the attribute values to be specified in any order, e.g. :- or Another example :- EMP <--Insert { { Name <-- Fred ; No <-- 3 } { No <-- 4; Name <-- Jane EMP <--Insert { { Name <-- Fred ; No <-- 3 } { Name <-- Jane ; No <-- 4 EMP <--Insert TempEMP Restrict[ No > 21 ] Page 1 of 14

2 Here a restriction is used to extract some tuples (the number is indeterminable from the expression alone) from relvar TempEMP and insert them into EMP. (TempEMP and EMP must have the same type). These two kinds of insertion could be combined, as follows :- or EMP <--Insert TempEMP Restrict[ No > 21 ] Union { { Name <-- Fred ; No <-- 3 } { No <-- 4; Name <-- Jane EMP <--Insert TempEMP Restrict[ No > 21 ] Intersect { { Name <-- Fred ; No <-- 3 } { No <-- 4; Name <-- Jane Note that the relvalue of the RH operand must be disjoint from the relvalue of the LH operand; otherwise an error will be returned instead of an insertion being carried out. Deletion Tuples may be deleted from EMP as follows :- EMP Delete Relational_Expression where Relational_Expression is defined as before. If EMP has received insertions similar to those above, then the following might be possible deletions :- or EMP <--Delete TempEMP Restrict[ No > 21 ] Union { { Name <-- Jack ; No <-- 1 } { No <-- 2; Name <-- Jill EMP <--Insert TempEMP Restrict[ No > 21 ] Intersect { { Name <-- Jack ; No <-- 1 } { No <-- 2; Name <-- Jill Note that the relvalue of the RH operand must be a subset, not necessarily a proper subset, of the relvalue of the LH operand; otherwise an error will be returned instead of a deletion being carried out. Another example :- EMP <--Delete EMP Restrict[ No < 2 ] This assignment deletes all tuples from EMP whose No attribute value is less than 2. This example would cause the deletion of one tuple, i.e. { No <-- 1; Name <-- Jack }. This assignment could also be expressed as :- Page 2 of 14

3 EMP Restrict[ No < 2 represents the value of the LH operand - whatever its nature - before the deletion. It can therefore always be used; indeed it is preferable to use it because it is simpler to write and avoids errors in copying out the LH operand 1. Amendment Tuples may be amended in EMP as follows :- EMP Amend[ attribute-assignment(s) ] where attribute-assignment(s) are a set of value assignments to named attributes. For each such assignment, every tuple in EMP has that attribute s value replaced as specified by the assignment. EMP Amend[ No <-- No + 1 ] This increments the No attribute value by one in every attribute of EMP. Multiple attributes, all of those in the relvar if required, can have their values amended in one assignment. EMP Amend[ No <-- No + 1; Name <-- Name Cat Joyous ] additionally concatenates Joyous to the end of the Name attribute in every tuple of EMP. For :- EMP Amend[ No <-- 1 ] every tuple in EMP would be amended to have 1 as the value of its No attribute, because the value to be assigned no longer depends on the attribute s original value. If No is a Candidate Key of EMP, then this would generate an error (unless EMP contains only zero or one tuples). Sometimes only certain of a relvar s tuples are to be updated. In this case the LH operand should comprise a relational expression that evaluates to the set of tuples to be amended. ( EMP Restrict[ No = 1 ] ) Amend[ Name <-- Joyous ] amends the Name attribute to have the value Joyous in the tuple whose No attribute has the value 1. If No is not a Candidate Key of EMP, then this would change the Name attribute value in every tuple whose No attribute has the value 1. The parentheses are required around the LH operand expression to avoid the assignment attempting to amend a Restrict operation, thereby causing a semantic error. If the LH operand is not a relvar name but a relational algebra expression involving more than a relvar name, then the LH operand is treated as an unnamed view. Thus any expression can occur as the LH operand, as long as it is logically possible to amend the underlying relvar(s) of the unnamed view. can be used as (part of) the RH operand of any relational assignment, but is of most practical use in deletions. Page 3 of 14

4 ( EMP Join[[ No ] OtherEMP ) Amend[ Name <-- Joyous ] Here a left semijoin with OtherEMP is used to specify the tuples of EMP to be amended. In the following examples, the LH operand specifies just those attributes whose values are to be amended :- ( EMP Project[ No ] ) Amend[ No <-- No + 1 ] ( EMP Restrict[ No = 1 ] Project[ Name ] ) Amend[ Name <-- Joyous ] However this is not necessary as long as all the attributes named in the <--Amend parameter exist within the LH operand. Example Relvars - Second Set Since it is possible for a relvar to contain nested relvalues as attribute values, it is worthwhile to consider how the value assignments operate when they are present, and how they can be applied to nested relvalue parts of a relvar. Thus the example data is expanded to the following :- Let relvar EMP1 contain sample data of the ID number, name, and salary history of employees :- No Name SalHist 1 Jack Start Sal Date[ 1; 3;1998 ] Date[ 1; 2; 2003 ] Date[ 1; 10; 2009 ] Jill Start Sal Date[ 1; 12; 2004 ] Date[ 1; 11; 2007 ] Let relvar EMP2 contain sample data of the ID number, name, and project history of employees :- Page 4 of 14

5 No Name ProjHist 1 Jack ProjNo P7 Time Start End Date[ 1; 12; 2004 ] Date[ 20; 4; 2005 ] Date[ 1; 11; 2007 ] Date[ 9; 8; 2008 ] 2 Jill ProjNo P7 P8 Time Start End Date[ 1; 9; 2002 ] Date[ 1; 9; 2004 ] Start End Date[ 1; 2; 2005 ] Date[ 8; 4; 2006 ] Overview In handling nested relvalues and part-relvars, it can be convenient to use the Nest and/or Unnest operators to handle nested relvalues and ensure that the same level of nesting applies within the RH relvalue and the LH relvar. In general, it is possible to assign to a specific nested relvalue. For example, to insert into a relvalue that is nested one level down :- ( R Restrict[ Key = 1 ] Project[ A ] Unnest[ A ] ) <--Insert relexpression The relevant tuple of the relvar is picked out using a restriction on the key attribute, the attribute holding the nested relvalue projected out, and the nested relvalue unnested to allow the insertion directly into it. This strategy can be continued for a relvalue two levels of nesting down as follows :- ( R Restrict[ Key = 1 ] Project[ A ] Unnest[ A ] Restrict[ KeyN = 1 ] Project[ AN ] Unnest[ AN ] ) <--Insert relexpression And so on down to any required depth :- Page 5 of 14

6 ( R Restrict[ Key = 1 ] Project[ A ] Unnest[ A ] Restrict[ KeyN = 1 ] Project[ AN ] Unnest[ AN ] Restrict[ KeyNN= 1 ] Project[ ANN ] Unnest[ ANN ].... ) <--Insert relexpression And similarly for deletion and amendment. Where insertion and deletion to nested relvalues are concerned, there are in fact two categories of assignment : the assignment of a single relvalue to a single relvar, the assignment of a single relvalue to n part-relvars that are nested within a single relvar. The second category can allow a layer of unnesting to be omitted. The variations in assignment of relvalues to relvars can in general terms be illustrated graphically as follows :- Assign a relvalue to a relvar. Assign a relvalue to 2 nested part-relvars. Assign a relvalue to a relvar. Both have the same nested relational structure. Page 6 of 14

7 Two assignments to a relvar : 1. A relvalue to a single relvalue nested at the deepest level within the relvar. 2. A relvalue to a single relvalue nested one level down inside the relvar. Note that when an amendment is to be carried out on an attribute value, and that attribute value is a nested relvalue, that amendment can be : 1. an amendment to attribute values within the nested relvalue, 2. an insertion of tuples into the nested relvalue, 3. a deletion of tuples from the nested relvalue. Examples involving nested relvalues are now given. Insertion Insert a single relvalue into a single relvar. 1. Insert a third tuple into EMP1. The following two insertions use the abbreviated and the long-hand equivalents of relation-valued literals to insert the same third tuple :- EMP1 <--Insert { { 3; Fred ; { { Date[ 10; 9; 2006 ]; } { Date[ 6; 8; 2009 ]; EMP1 <--Insert { { No <-- 3; Name <-- Fred ; SalHist <--Insert { { Start <-- Date[ 10; 9; 2006 ]; Sal < } { Start <-- Date[ 6; 8; 2009 ]; Sal < A relvalue of one tuple is inserted into EMP1; the attribute SalHist in the tuple is a nested relvalue of 2 tuples. Page 7 of 14

8 2. Insert a third tuple into EMP2. The following two insertions use the abbreviated and the long-hand equivalents of relation-valued literals to insert the same third tuple :- EMP2 <--Insert { { 3; Fred ; { { P6 ; { { Date[ 10; 5; 2006 ]; Date[ 19; 8; 2008 ] EMP2 <--Insert { { No <-- 3; Name <-- Fred ; ProjHist <--Insert { { ProjNo <-- P6 ; Time <--Insert { { Start <-- Date[ 10; 5; 2006 ]; End <-- Date[ 19; 8; 2008 ] A relvalue of one tuple is inserted into EMP2; the tuple s ProjHist attribute is a nested relvalue of one tuple, which itself consists of the scalar attribute ProjNo and the relation-valued attribute Time which also has a relvalue of one tuple. Insert a single relvalue into each nested relvalue of a relvar. 3. Insert two tuples into each of the SalHist nested relvalues of EMP1. The following two insertions use the abbreviated and the long-hand equivalents of relation-valued literals to insert the same two tuples into every SalHist nested relvalue :- ( EMP1 Project[ SalHist ] ) <--Insert { { Date[ 8; 7; 2003 ]; } { Date[ 11; 4; 2007 ]; ( EMP1 Project[ SalHist ] ) <--Insert { { Start <-- Date[ 8; 7; 2003 ]; Sal < } { Start <-- Date[ 11; 4; 2007 ]; Sal < The LHS of the insertion is an unnamed view (based on EMP1) whose type is a set of unary tuples, each of whose attribute values consists of a relvalue of binary tuples. The RHS relvalue has the same type as the nested relvalues of the unnamed view. Therefore the RHS relvalue is inserted into each of the nested SalHist part-relvars. (A part-relvar is a component part of a relvar). This is an example of where one RHS relvalue is inserted into n LHS partrelvars, in this case where n = 3 (after the previous insertion). The question may be raised as to what would happen if the RHS relvalue had consisted of 3 tuple values of the correct type, as opposed to the 2 in the above example. Would each of the 3 tuples of the RHS relvalue be inserted into its own corresponding LHS part-relvar because there is now the same number of tuple values on the RHS as there are nested part-relvars on the LHS. The answer is no. The question is a red herring. Assignments assign Page 8 of 14

9 relvalues to relvars or part-relvars, and the number of tuples in a relvalue is irrelevant. Insert a single relvalue into a particular nested relvalue of a relvar. 4. Insert two tuples into one specific SalHist nested relvalue. ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] ) <--Insert { { Date[ 10; 9; 2006 ]; } { Date[ 6; 8; 2009 ]; ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] ) <--Insert { { Start <-- Date[ 10; 9; 2006 ]; Sal < } { Start <-- Date[ 6; 8; 2009 ]; Sal < The unnamed view on the LHS represents a part-relvar consisting of one attribute of one tuple, whose value is a nested relvalue. These statements insert a relvalue of 2 tuples into that part-relvar. The LH operand is an unnamed view expressing a relvalue nested within a relvalue; i.e. the LH operand is a set of n part-relvars where n = 1. Therefore the ability to assign to a nested relvalue is still useful even in this case, as it obviates the need to Unnest the LH operand so as to ensure the LHS and RHS have identical types. Of course, Unnest could be used if required to execute the logically equivalent insertion as follows (abbreviated version) :- ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] Unnest[ SalHist ] ) <--Insert { { Date[ 10; 9; 2006 ]; } { Date[ 6; 8; 2009 ]; This inserts a single relvalue into a single part-relvar. 5. Insert one tuple into one specific Time nested relvalue. ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] ) <--Insert { { Date[ 15; 3; 2004 ]; Date[ 19; 12; 2008 ] ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] ) <--Insert { { Start <-- Date[ 15; 3; 2004 ]; End <-- Date[ 19; 12; 2008 ] As the nested relvalues of the Time attribute are nested two levels down, the Unnest operation is required so that the second restriction is applied to a relational valued attribute whose own attributes are called ProjNo and Time. Note a second Unnest could be applied to the LH operand but it is not necessary; instead the RH relvalue is inserted into a set of one nested relvalue. If a second Unnest were used, the logically equivalent insertion would be (abbreviated version) :- Page 9 of 14

10 ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] Unnest[ Time ] ) <--Insert { { Date[ 15; 3; 2004 ]; Date[ 19; 12; 2008 ] Note that inserting a relvalue into every Time nested part-relvar cannot be reliably carried out. Consider how it might be written :- ( EMP2 Project[ ProjHist ] Unnest[ ProjHist ] Project[ Time ] Unnest[ Time ] ) <--Insert { { Date[ 15; 3; 2004 ]; Date[ 19; 12; 2008 ] The lack of restrictions picking out individual tuples means the unnesting of ProjHist and of Time may result in duplicate tuples of attributes Start and End arising, and the duplicates being removed; thus the view update mechanism cannot guarantee to carry out the correct insertions into EMP2. Deletion The deletion examples given are the direct inverses of the above insertion examples. Delete a single relvalue from a single relvar. 1. Delete a tuple from EMP1. The following are equivalent ways of expressing the same deletion :- EMP1 <--Delete { { 3; Fred ; { { Date[ 10; 9; 2006 ]; } { Date[ 6; 8; 2009 ]; EMP1 <--Delete { { No <-- 3; Name <-- Fred ; SalHist <--Insert { { Start <-- Date[ 10; 9; 2006 ]; Sal < } { Start <-- Date[ 6; 8; 2009 ]; Sal < EMP1 <--Delete EMP1 Restrict[ No = 3 ] EMP1 Restrict[ No = 3 ] The first two statements use relation-valued literals. Despite a deletion being carried out, the long-hand relation-valued literal uses an insertion within the RH operand because the <--Insert is here the set equivalent of a scalar value assignment - 2 tuples are being put into the SalHist empty relation. The 3 rd and 4 th statements use a relational algebra expression to pick out the 1-tuple relvalue that is to be deleted from EMP1, rather than writing out its literal value. Any suitable restriction condition could be used. It is here assumed that attribute No is a candidate key and so can be reliably used to pick out a single tuple. The 4 th statement instead of EMP1. 2. Delete a tuple from EMP2. The following are equivalent ways of expressing the same deletion :- Page 10 of 14

11 EMP2 <--Delete { { 3; Fred ; { { P6 ; { { Date[ 10; 5; 2006 ]; Date[ 19; 8; 2008 ] EMP2 Restrict[ No = 3 ] For convenience here and from now on, the use of a long-hand relation-valued literal is omitted, as is the use of a restriction Both the omitted variants can always be used if preferred. Note that the RH operand does not need to refer to the LH operand, either directly or indirectly. EMP2 <--Delete Special1EMP Join[ ProjHist ] Special2EMP Nest[ Time <-- Start, End ] Here Special1EMP and Special2EMP are 2 completely different relvars that are joined together and restructured by the nest operation so that the result has the same type as EMP2. (The result of the join must include one level of nesting corresponding to ProjHist so that only one more level of nesting must be applied after the join). The result of the RH expression comprises the relvalue of tuples to be deleted from EMP2. Delete a single relvalue from each nested relvalue of a relvar. 3. Delete tuples from each of the SalHist nested relvalues of EMP1. The following two deletions correspond to the insertion of two tuples into every SalHist nested relvalue :- ( EMP1 Project[ SalHist ] ) <--Delete { { Date[ 8; 7; 2003 ]; } { Date[ 11; 4; 2007 ]; ( EMP1 Project[ SalHist ] ) Restrict[ Sal = Or ( Sal = ) ] The RHS relvalue has the same type as the nested relvalues of the unnamed view. In the latter example, this is deduced from the attribute names used in the restriction condition; if there is no way of doing this, a restriction cannot be used. The RHS relvalue is deleted from each of the nested SalHist part-relvars in parallel; all the deletions must succeed or the deletion as a whole fails and EMP1 is left unaffected. Therefore in the case where the RH operand is a literal relvalue, that relvalue must exist in every nested part-relvar so that it may be deleted. In the case of the restriction expression, it likewise must always evaluate to a relvalue which exists in every nested part-relvar so that it may be deleted. However the restriction will always succeed, even though it may delete different tuples from each nested SalHist relvalue or even delete no tuples at all from any or all of them. This is because the restriction may yield a different relvalue for each of the nested SalHist relvalues. (@ represents each nested SalHist relvalue Page 11 of 14

12 for each restriction, which logically occur in parallel). Furthermore, even if the restriction yields an empty relvalue, that relvalue is still a valid subset of the nested SalHist relvalue and so may be deleted from it. Delete a single relvalue from a particular nested relvalue of a relvar. 4. Delete tuples from one specific SalHist nested relvalue. ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] ) <--Delete { { Date[ 10; 9; 2006 ]; } { Date[ 6; 8; 2009 ]; ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] ) Restrict[ Sal = Or ( Sal = ) ] 5. Delete tuples from one specific Time nested relvalue. ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] ) <--Delete { { Date[ 15; 3; 2004 ]; Date[ 19; 12; 2008 ] ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] ) Restrict[ Start = Date[ 15; 3; 2004 ] ] The restriction condition assumes that the values of Start can be used to pick out the required tuples for deletion. Amendment For convenience, the examples assume the initial relvalues of EMP1 and EMP2 - in fact the example deletions will have reversed the example insertions anyway. Amend an entire relvar. 1. Amend all tuples in EMP1. EMP1 <--Amend[ No <-- No + 1; SalHist <--Amend[ Start <-- Start + Day[2] ] ] Note that an amendment applies to the whole of the LH operand, in this case to every tuple in EMP1. All No attribute values are increased by 1, and all SalHist attribute values have all their Start attribute values increased by 2 days. Because the entire amendment to EMP1 has to succeed, or the entire amendment fail, then the amendments themselves need to be of such a nature that they can be applied to every tuple in the relvalue. Thus if the amendment of the No attribute value had been No <-- 1 then all the No attribute values in EMP1 would have been changed to 1; if Page 12 of 14

13 attribute No is a candidate key of EMP1, then this would have triggered an error and the entire statement would have failed. 2. Amend all tuples in EMP2. EMP2 <--Amend[ ProjHist Restrict[ ProjNo = P7 ] ] In this case, the amendment is to all the ProjHist attribute values of EMP1, and consists in deleting all tuples in every ProjHist relvalue whose ProjNo attribute value is P7. This statement will succeed even if no ProjHist attribute value contains a tuple whose ProjNo attribute value is P7, because in such cases the RH operand of the deletion will be an empty set that can always be deleted from the LH operand (and will not affect its value). Amend each nested relvalue of a relvar. 3. Amend tuples in each of the SalHist nested relvalues of EMP1. ( EMP1 Project[ SalHist ] ) <--Amend[ SalHist <--Amend[ Start <-- Start + Day[2] ] ] This amends every SalHist attribute relvalue in the LH operand by adding 2 days to every Start scalar value in every SalHist attribute relvalue. EMP1 <--Amend[ SalHist Restrict[ Start < Date[ 1; 1; 2000 ] ] Every SalHist attribute relvalue in the LH operand that contains any tuples whose Start date is earlier than 1 st January 2000 is amended by having those tuples deleted from it. Amend a particular nested relvalue of a relvar. 4. Amend one specific SalHist nested relvalue. ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] ) <--Amend[ SalHist <--Insert { { Date[ 10; 5; 2006 ]; Date[ 19; 8; 2008 ] ] One SalHist attribute value is amended by having a 1-tuple relvalue inserted into it. If Unnest is included in the LH operand as follows :- ( EMP1 Restrict[ No = 1 ] Project[ SalHist ] Unnest[ SalHist ] ) <--Amend[ SalHist <--Insert { { Date[ 10; 5; 2006 ]; Date[ 19; 8; 2008 ] ] Page 13 of 14

14 then the view updating mechanism when applied to the LH operand will execute the same amendment as the previous case. 5. Amend one specific Time nested relvalue. ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] ) <--Amend[ End <--Amend[ End <-- End - Month[1] ] ] For employee number 2 s P7 project, this moves the End date forward by a month in all tuples (actually only one in this case) of nested relvalue Time. The following does the same but using a second unnest operation :- ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] Unnest[ Time ] ) <--Amend[ End <--Amend[ End <-- End - Month[1] ] ] Complex Example The examples conclude with a complex example to demonstrate the power of the assignments. Every employee is given a 10% pay rise on 28 th February Update the SalHist attribute of EMP1 to reflect this. EMP1 <--Amend[ SalHist <--Insert { { Start <-- Date[ 28; 2; 2010 ] ; Sal <-- SalHist GroupBy[ ] With[ Result <-- Bag[ Sal ] Max ] Unnest * 1.1 ] For each tuple in EMP1, the SalHist nested relvalue has another tuple inserted into it. That tuple consists of the date of the 28 th February 2010, and the new salary. Assuming the highest salary of each employee is the current salary, the new salary is calculated by using a GroupBy operation to determine the highest salary and multiplying that by 1.1. Note that the result of the GroupBy operation is a relvalue of a single tuple and a single attribute; therefore it needs to be unnested to yield a scalar value which can be multiplied by 1.1 and then assigned as a scalar value to Sal within the SalHist nested relvalue. Finally, since a RAQUEL statement can incorporate multiple assignments, it is possible to check the result of a relvalue assignment is what is expected by retrieving that result. For example (retrieving the result to a sink s ) :- s <--Retrieve ( EMP2 Restrict[ No = 2 ] Project[ ProjHist ] Unnest[ ProjHist ] Restrict[ ProjNo = P7 ] Project[ Time ] ) <--Amend[ End <--Amend[ End <-- End - Month[1] ] ] Page 14 of 14

Illustrative Example of Logical Database Creation

Illustrative Example of Logical Database Creation Illustrative Example of Logical Database Creation A small RAQUEL DB is created to illustrate what is involved as regards the logical schemas of a RAQUEL DB. Create a Database or ExampleDB

More information

RAQUEL s Relational Operators

RAQUEL s Relational Operators Contents RAQUEL s Relational Operators Introduction 2 General Principles 2 Operator Parameters 3 Ordinary & High-Level Operators 3 Operator Valency 4 Default Tuples 5 The Relational Algebra Operators in

More information

The Syntax of Relational Operators

The Syntax of Relational Operators The Syntax of Relational Operators This document records the syntax i.e. keywords and parameters - of all the operators at the relational level of abstraction. Note : these operators are all members of

More information

Illustrative Example of Logical Database Creation

Illustrative Example of Logical Database Creation Illustrative Example of Logical Database Creation A small RAQUEL DB is created to illustrate what is involved as regards the logical schemas of a RAQUEL DB. Create a Database or ExampleDB

More information

Stored Relvars 18 th April 2013 (30 th March 2001) David Livingstone. Stored Relvars

Stored Relvars 18 th April 2013 (30 th March 2001) David Livingstone. Stored Relvars Stored Relvars Introduction The purpose of a Stored Relvar (= Stored Relational Variable) is to provide a mechanism by which the value of a real (or base) relvar may be partitioned into fragments and/or

More information

Generalising Relational Algebra Set Operators

Generalising Relational Algebra Set Operators Generalising Relational lgebra Set Operators Introduction The relational algebra join operators, Natural Join and Generalised (or Theta) Join, can both be generalised to so that they incorporate semi joins

More information

Amendments & Transactions

Amendments & Transactions Slide 1 Amendments & Transactions Objectives of the Lecture : To consider amendments to a relation; To consider transactions in SQL. Slide 2 Relational Amendment Strictly speaking, relational amendment

More information

Database Modelling. Lecture 5 Part 1: Updating Database 1/6/2015 1

Database Modelling. Lecture 5 Part 1: Updating Database 1/6/2015 1 Database Modelling Lecture 5 Part 1: Updating Database 1/6/2015 1 Learning Objectives 1. To consider how to do insertions and deletions in SQL 2. To consider amendments (updates) to a relation 3. To consider

More information

The Logical Design of the Tokeniser

The Logical Design of the Tokeniser Page 1 of 21 The Logical Design of the Tokeniser Purpose 1. To split up a character string holding a RAQUEL statement expressed in linear text, into a sequence of character strings (called word tokens),

More information

NULLs & Outer Joins. Objectives of the Lecture :

NULLs & Outer Joins. Objectives of the Lecture : Slide 1 NULLs & Outer Joins Objectives of the Lecture : To consider the use of NULLs in SQL. To consider Outer Join Operations, and their implementation in SQL. Slide 2 Missing Values : Possible Strategies

More information

Further GroupBy & Extend Operations

Further GroupBy & Extend Operations Slide 1 Further GroupBy & Extend Operations Objectives of the Lecture : To consider whole relation Grouping; To consider the SQL Grouping option Having; To consider the Extend operator & its implementation

More information

Illustrative Example of Physical Schema Usage

Illustrative Example of Physical Schema Usage Example of Physical Usage 14 th February 2014 (30 th March 2001) Illustrative Example of Physical Usage The example assumes that a small RAQUEL DB and its relational model schemas have already been created.

More information

RAQUEL Parser Code Design

RAQUEL Parser Code Design Parser Input A sequence of pointers-to-tokens. RAQUEL Parser Code Design Parser Output A tree of tokens linked together by pointers AND a sequence of error codes. Pre Conditions None. Post Conditions Length(

More information

The Relational Algebra

The Relational Algebra The Relational Algebra Relational Algebra Relational algebra is the basic set of operations for the relational model These operations enable a user to specify basic retrieval requests (or queries) 27-Jan-14

More information

Ian Kenny. November 28, 2017

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

More information

School of Computing, Engineering and Information Sciences University of Northumbria. Set Operations

School of Computing, Engineering and Information Sciences University of Northumbria. Set Operations Set Operations Aim: To understand how to do the equivalent of the UNION, DIFFERENCE and INTERSECT set operations in SQL. Outline of Session: Do some example SQL queries to learn to differentiate between

More information

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions. COSC 304 Introduction to Database Systems Relational Model and Algebra Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was

More information

Relational Data Model

Relational Data Model Relational Data Model 1. Relational data model Information models try to put the real-world information complexity in a framework that can be easily understood. Data models must capture data structure

More information

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

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

More information

Chapter 12: Query Processing

Chapter 12: Query Processing Chapter 12: Query Processing Overview Catalog Information for Cost Estimation $ Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Transformation

More information

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra Note: Slides are posted on the class website, protected by a password written on the board Reading: see class home page www.cs.umb.edu/cs630. Relational Algebra CS430/630 Lecture 2 Relational Query Languages

More information

Chapter 12: Query Processing. Chapter 12: Query Processing

Chapter 12: Query Processing. Chapter 12: Query Processing Chapter 12: Query Processing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 12: Query Processing Overview Measures of Query Cost Selection Operation Sorting Join

More information

Lyublena Antova, Christoph Koch, and Dan Olteanu Saarland University Database Group Saarbr ucken, Germany Presented By: Rana Daud

Lyublena Antova, Christoph Koch, and Dan Olteanu Saarland University Database Group Saarbr ucken, Germany Presented By: Rana Daud Lyublena Antova, Christoph Koch, and Dan Olteanu Saarland University Database Group Saarbr ucken, Germany 2007 1 Presented By: Rana Daud Introduction Application Scenarios I-SQL World-Set Algebra Algebraic

More information

CPS 216 Spring 2003 Homework #1 Assigned: Wednesday, January 22 Due: Monday, February 10

CPS 216 Spring 2003 Homework #1 Assigned: Wednesday, January 22 Due: Monday, February 10 CPS 216 Spring 2003 Homework #1 Assigned: Wednesday, January 22 Due: Monday, February 10 Note: This is a long homework. Start early! If you have already taken CPS 196.3 or an equivalent undergraduate course

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions

More information

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 4 Database Programming PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL) AGENDA 6. Stored Functions Procedural Database Programming

More information

3. Relational Data Model 3.5 The Tuple Relational Calculus

3. Relational Data Model 3.5 The Tuple Relational Calculus 3. Relational Data Model 3.5 The Tuple Relational Calculus forall quantification Syntax: t R(P(t)) semantics: for all tuples t in relation R, P(t) has to be fulfilled example query: Determine all students

More information

CS233:HACD Introduction to Relational Databases Notes for Section 4: Relational Algebra, Principles and Part I 1. Cover slide

CS233:HACD Introduction to Relational Databases Notes for Section 4: Relational Algebra, Principles and Part I 1. Cover slide File: CS233-HACD-Notes4.doc Printed at: 16:15 on Friday, 28 October, 2005 CS233:HACD Introduction to Relational Databases Notes for Section 4: Relational Algebra, Principles and Part I 1. Cover slide In

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

Relational Algebra. Note: Slides are posted on the class website, protected by a password written on the board

Relational Algebra. Note: Slides are posted on the class website, protected by a password written on the board Note: Slides are posted on the class website, protected by a password written on the board Reading: see class home page www.cs.umb.edu/cs630. Relational Algebra CS430/630 Lecture 2 Slides based on Database

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

Creating SQL Tables and using Data Types

Creating SQL Tables and using Data Types Creating SQL Tables and using Data Types Aims: To learn how to create tables in Oracle SQL, and how to use Oracle SQL data types in the creation of these tables. Outline of Session: Given a simple database

More information

Instructor: Craig Duckett. Lecture 11: Thursday, May 3 th, Set Operations, Subqueries, Views

Instructor: Craig Duckett. Lecture 11: Thursday, May 3 th, Set Operations, Subqueries, Views Instructor: Craig Duckett Lecture 11: Thursday, May 3 th, 2018 Set Operations, Subqueries, Views 1 MID-TERM EXAM GRADED! Assignment 2 is due LECTURE 12, NEXT Tuesday, May 8 th in StudentTracker by MIDNIGHT

More information

Chapter 6 Part I The Relational Algebra and Calculus

Chapter 6 Part I The Relational Algebra and Calculus Chapter 6 Part I The Relational Algebra and Calculus Copyright 2004 Ramez Elmasri and Shamkant Navathe Database State for COMPANY All examples discussed below refer to the COMPANY database shown here.

More information

Contents Contents Introduction Basic Steps in Query Processing Introduction Transformation of Relational Expressions...

Contents Contents Introduction Basic Steps in Query Processing Introduction Transformation of Relational Expressions... Contents Contents...283 Introduction...283 Basic Steps in Query Processing...284 Introduction...285 Transformation of Relational Expressions...287 Equivalence Rules...289 Transformation Example: Pushing

More information

Query Processing SL03

Query Processing SL03 Distributed Database Systems Fall 2016 Query Processing Overview Query Processing SL03 Distributed Query Processing Steps Query Decomposition Data Localization Query Processing Overview/1 Query processing:

More information

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

T h i r d M a n i f e s t o (version dated February 7th, 2013, superseding all previous versions)

T h i r d M a n i f e s t o (version dated February 7th, 2013, superseding all previous versions) T h e T h i r d M a n i f e s t o (version dated February 7th, 2013, superseding all previous versions)... the powerful plain third manifesto with apologies to Stephen Spender These principles are eternal,

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

Chapter 4 RM PRESCRIPTIONS

Chapter 4 RM PRESCRIPTIONS RM PRESCRIPTIONS Chapter 4 T h e T h i r d M a n i f e s t o RM Prescriptions RM Proscriptions OO Prescriptions OO Proscriptions RM Very Strong Suggestions OO Very Strong Suggestions Recent Manifesto changes

More information

x = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0

x = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0 6 Statements 43 6 Statements The statements of C# do not differ very much from those of other programming languages. In addition to assignments and method calls there are various sorts of selections and

More information

CS411 Database Systems. 04: Relational Algebra Ch 2.4, 5.1

CS411 Database Systems. 04: Relational Algebra Ch 2.4, 5.1 CS411 Database Systems 04: Relational Algebra Ch 2.4, 5.1 1 Basic RA Operations 2 Set Operations Union, difference Binary operations Remember, a relation is a SET of tuples, so set operations are certainly

More information

Relational Database Model. III. Introduction to the Relational Database Model. Relational Database Model. Relational Terminology.

Relational Database Model. III. Introduction to the Relational Database Model. Relational Database Model. Relational Terminology. III. Introduction to the Relational Database Model Relational Database Model In 1970, E. F. Codd published A Relational Model of Data for Large Shared Data Banks in CACM. In the early 1980s, commercially

More information

SQL Queries. COSC 304 Introduction to Database Systems SQL. Example Relations. SQL and Relational Algebra. Example Relation Instances

SQL Queries. COSC 304 Introduction to Database Systems SQL. Example Relations. SQL and Relational Algebra. Example Relation Instances COSC 304 Introduction to Database Systems SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Queries Querying with SQL is performed using a SELECT statement. The general

More information

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

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

More information

BOOLEAN ALGEBRA AND CIRCUITS

BOOLEAN ALGEBRA AND CIRCUITS UNIT 3 Structure BOOLEAN ALGEBRA AND CIRCUITS Boolean Algebra and 3. Introduction 3. Objectives 3.2 Boolean Algebras 3.3 Logic 3.4 Boolean Functions 3.5 Summary 3.6 Solutions/ Answers 3. INTRODUCTION This

More information

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 5 Structured Query Language Hello and greetings. In the ongoing

More information

Databases-1 Lecture-01. Introduction, Relational Algebra

Databases-1 Lecture-01. Introduction, Relational Algebra Databases-1 Lecture-01 Introduction, Relational Algebra Information, 2018 Spring About me: Hajas Csilla, Mathematician, PhD, Senior lecturer, Dept. of Information Systems, Eötvös Loránd University of Budapest

More information

LECTURE 8: SETS. Software Engineering Mike Wooldridge

LECTURE 8: SETS. Software Engineering Mike Wooldridge LECTURE 8: SETS Mike Wooldridge 1 What is a Set? The concept of a set is used throughout mathematics; its formal definition matches closely our intuitive understanding of the word. Definition: A set is

More information

2.2.2.Relational Database concept

2.2.2.Relational Database concept Foreign key:- is a field (or collection of fields) in one table that uniquely identifies a row of another table. In simpler words, the foreign key is defined in a second table, but it refers to the primary

More information

CS Summer 2013

CS Summer 2013 CS 1110 - Summer 2013 intro to programming -- how to think like a robot :) we use the Python* language (www.python.org) programming environments (many choices): Eclipse (free from www.eclipse.org), or

More information

Chapter 2: Relational Model

Chapter 2: Relational Model Chapter 2: Relational Model Database System Concepts, 5 th Ed. See www.db-book.com for conditions on re-use Chapter 2: Relational Model Structure of Relational Databases Fundamental Relational-Algebra-Operations

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

More information

QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E)

QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E) QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E) 2 LECTURE OUTLINE Query Processing Methodology Basic Operations and Their Costs Generation of Execution Plans 3 QUERY PROCESSING IN A DDBMS

More information

Relational Algebra. Relational Algebra Overview. Relational Algebra Overview. Unary Relational Operations 8/19/2014. Relational Algebra Overview

Relational Algebra. Relational Algebra Overview. Relational Algebra Overview. Unary Relational Operations 8/19/2014. Relational Algebra Overview The Relational Algebra Relational Algebra Relational algebra is the basic set of operations for the relational model These operations enable a user to specify basic retrieval requests (or queries) Relational

More information

CS 377 Database Systems

CS 377 Database Systems CS 377 Database Systems Relational Algebra and Calculus Li Xiong Department of Mathematics and Computer Science Emory University 1 ER Diagram of Company Database 2 3 4 5 Relational Algebra and Relational

More information

XACML Function Annotations

XACML Function Annotations XACML Function Annotations Prathima Rao Dan Lin Elisa Bertino Department of Computer Science Purdue University {prao,lindan,bertino}@cs.purdue.edu Abstract XACML is being increasingly adopted in large

More information

To understand the concept of candidate and primary keys and their application in table creation.

To understand the concept of candidate and primary keys and their application in table creation. CM0719: Database Modelling Seminar 5 (b): Candidate and Primary Keys Exercise Aims: To understand the concept of candidate and primary keys and their application in table creation. Outline of Activity:

More information

COSC 304 Introduction to Database Systems SQL. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 304 Introduction to Database Systems SQL. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 304 Introduction to Database Systems SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Queries Querying with SQL is performed using a SELECT statement. The general

More information

Chapter 12: Query Processing

Chapter 12: Query Processing Chapter 12: Query Processing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Overview Chapter 12: Query Processing Measures of Query Cost Selection Operation Sorting Join

More information

Database System Concepts

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

More information

Cursors Christian S. Jensen, Richard T. Snodgrass, and T. Y. Cliff Leung

Cursors Christian S. Jensen, Richard T. Snodgrass, and T. Y. Cliff Leung 17 Cursors Christian S. Jensen, Richard T. Snodgrass, and T. Y. Cliff Leung The cursor facility of SQL2, to be useful in TSQL2, must be revised. Essentially, revision is needed because tuples of TSQL2

More information

What is an algebra? A formal system of manipulation of symbols to deal with general statements of relations.

What is an algebra? A formal system of manipulation of symbols to deal with general statements of relations. Lecture 4. Relational Algebra By now, we know that (a) All data in a relational DB is stored in tables (b) there are several tables in each DB (because of Normalization), and (c) often the information

More information

Chapter 13: Query Processing

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

More information

Functional programming with Common Lisp

Functional programming with Common Lisp Functional programming with Common Lisp Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 81 Expressions and functions

More information

A l Ain University Of Science and Technology

A l Ain University Of Science and Technology A l Ain University Of Science and Technology 6 Handout(6) Database Management Principles and Applications Relational algebra http://alainauh.webs.com/ 1 Handout Outines 6 Basic operations in relational

More information

CPS122 Lecture: From Python to Java

CPS122 Lecture: From Python to Java Objectives: CPS122 Lecture: From Python to Java last revised January 7, 2013 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

Topic Maps Reference Model, version 6.0

Topic Maps Reference Model, version 6.0 Topic Maps Reference Model, 13250-5 version 6.0 Patrick Durusau Steven R. Newcomb July 13, 2005 This is a working draft of the Topic Maps Reference Model. It focuses on the integration of Robert Barta

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 6 Basic SQL Slide 6-2 Chapter 6 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features

More information

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays A Beginner s Guide to Programming Logic, Introductory Chapter 6 Arrays Objectives In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Alexandra Roatiş David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2016 CS 348 SQL Winter

More information

Lists. Michael P. Fourman. February 2, 2010

Lists. Michael P. Fourman. February 2, 2010 Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce

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

Output: For each size provided as input, a figure of that size is to appear, followed by a blank line.

Output: For each size provided as input, a figure of that size is to appear, followed by a blank line. Problem 1: Divisor Differences Develop a program that, given integers m and k satisfying m > k > 0, lists every pair of positive integers (i,j) such that j i = k and both i and j are divisors of m. Input:

More information

The New C Standard (Excerpted material)

The New C Standard (Excerpted material) The New C Standard (Excerpted material) An Economic and Cultural Commentary Derek M. Jones derek@knosof.co.uk Copyright 2002-2008 Derek M. Jones. All rights reserved. 985 postfix-expression syntax postfix-expression:

More information

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 1 NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 2 LECTURE OUTLINE More Complex SQL Retrieval Queries Self-Joins Renaming Attributes and Results Grouping, Aggregation, and Group Filtering

More information

! A relational algebra expression may have many equivalent. ! Cost is generally measured as total elapsed time for

! A relational algebra expression may have many equivalent. ! Cost is generally measured as total elapsed time for Chapter 13: Query Processing Basic Steps in Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 1. Parsing and

More information

Chapter 13: Query Processing Basic Steps in Query Processing

Chapter 13: Query Processing Basic Steps in Query Processing Chapter 13: Query Processing Basic Steps in Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 1. Parsing and

More information

UNIT 3 DATABASE DESIGN

UNIT 3 DATABASE DESIGN UNIT 3 DATABASE DESIGN Objective To study design guidelines for relational databases. To know about Functional dependencies. To have an understanding on First, Second, Third Normal forms To study about

More information

Introduction. 1. Introduction. Overview Query Processing Overview Query Optimization Overview Query Execution 3 / 591

Introduction. 1. Introduction. Overview Query Processing Overview Query Optimization Overview Query Execution 3 / 591 1. Introduction Overview Query Processing Overview Query Optimization Overview Query Execution 3 / 591 Query Processing Reason for Query Optimization query languages like SQL are declarative query specifies

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

Implementing mapping composition

Implementing mapping composition The VLDB Journal (2008) 17:333 353 DOI 10.1007/s00778-007-0059-9 SPECIAL ISSUE PAPER Implementing mapping composition Philip A. Bernstein Todd J. Green Sergey Melnik Alan Nash Received: 17 February 2007

More information

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

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

More information

Chapter 11: Query Optimization

Chapter 11: Query Optimization Chapter 11: Query Optimization Chapter 11: Query Optimization Introduction Transformation of Relational Expressions Statistical Information for Cost Estimation Cost-based optimization Dynamic Programming

More information

Optimization of Nested Queries in a Complex Object Model

Optimization of Nested Queries in a Complex Object Model Optimization of Nested Queries in a Complex Object Model Based on the papers: From Nested loops to Join Queries in OODB and Optimisation if Nested Queries in a Complex Object Model by Department of Computer

More information

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU Relational Algebra 1 Structure of Relational Databases A relational database consists of a collection of tables, each of which is assigned a unique name. A row in a table represents a relationship among

More information

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships

More information

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

More information

II. Review/Expansion of Definitions - Ask class for definitions

II. Review/Expansion of Definitions - Ask class for definitions CS352 Lecture - The Entity-Relationship Model last revised July 25, 2008 Objectives: 1. To discuss using an ER model to think about a database at the conceptual design level. 2. To show how to convert

More information

Advanced Databases. Lecture 4 - Query Optimization. Masood Niazi Torshiz Islamic Azad university- Mashhad Branch

Advanced Databases. Lecture 4 - Query Optimization. Masood Niazi Torshiz Islamic Azad university- Mashhad Branch Advanced Databases Lecture 4 - Query Optimization Masood Niazi Torshiz Islamic Azad university- Mashhad Branch www.mniazi.ir Query Optimization Introduction Transformation of Relational Expressions Catalog

More information

Chapter 2: Intro to Relational Model

Chapter 2: Intro to Relational Model Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns) tuples (or rows) 2.2 Attribute Types The

More information

Relational Algebra. Algebra of Bags

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

More information

Relational Algebra and SQL. Basic Operations Algebra of Bags

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

More information

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.) Chapter 10 Normalization Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information in Tuples and Update Anomalies 1.3 Null

More information

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) Learning Language Reference Manual 1 George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) A. Introduction Learning Language is a programming language designed

More information

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

CPS122 Lecture: From Python to Java last revised January 4, Objectives: Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

Query Processing. Debapriyo Majumdar Indian Sta4s4cal Ins4tute Kolkata DBMS PGDBA 2016

Query Processing. Debapriyo Majumdar Indian Sta4s4cal Ins4tute Kolkata DBMS PGDBA 2016 Query Processing Debapriyo Majumdar Indian Sta4s4cal Ins4tute Kolkata DBMS PGDBA 2016 Slides re-used with some modification from www.db-book.com Reference: Database System Concepts, 6 th Ed. By Silberschatz,

More information

SQL. SQL DDL Statements

SQL. SQL DDL Statements SQL Structured Query Language Declarative Specify the properties that should hold in the result, not how to obtain the result Complex queries have procedural elements International Standard SQL1 (1986)

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information