QUEL - Computerinfo.in

advertisement
CS 222
Database Management System
Spring 2010-11
Lecture 3 b
Korra Sathya Babu
Department of Computer Science
NIT Rourkela
4/9/2015
Lecture 3
1
Query Language (QUEL)
• QBE is graphical based
• QUEL is a relational database access language similar to SQL
• It was created as a part of the Ingres effort at University of California,
Berkeley, based on Codd's earlier suggested but not implemented Data
Sub-Language ALPHA
• QUEL was used for a short time in most products based on the freelyavailable Ingres source code, most notably Informix
• QUEL continues to be available as a part of the Ingres DBMS
• QUEL is purely based on TRC
• It can be embedded with ‘C’ only
4/9/2015
Lecture 3
2
Example
Sno
Sname
Rating
Age
Sid
bid
day
bid
bname
color
22
Dustine
7
45.0
22
101
10/10/08
101
Interlake
Blue
29
Brutus
1
33.0
22
102
10/10/08
102
Interlake
Red
31
Lubber
8
55.5
22
103
10/08/08
103
Clipper
Green
32
Andy
8
25.5
22
104
10/07/08
104
Marine
red
58
Rusty
10
35.0
31
102
10/10/08
64
Horatio
7
35.0
31
103
11/06/08
71
Zorba
10
16.0
31
104
11/12/08
74
Horatio
9
35.0
64
101
09/05/08
85
Art
3
25.5
64
102
09/08/08
95
Bob
3
63.5
74
103
09/08/08
Instance of Sailors
4/9/2015
Instance of Boats
Instance of Reserves
Lecture 3
3
Query Language (QUEL)
Query Language (QUEL)
Has three clauses
range of
retrieve
where
All queries are
represented with
these clauses
Syntax
range of of t is R
retrieve t
where Predicate
Similar to ∃(t(R))
Similar to Select Clause in SQL
Similar to where in SQL
Relational Operators used in the Predicate are
<,>,≤,≥,≠,=, ∧,∨,
Equivalence
{U r | (t )....(t )(R (t )  ... R (t )  U [1]  t [ j ]  ... U [r ]  t [ j ]  Conditon)}
1
k
1
1
k
k
i1
1
ir
r
The above TRC query can be written in QUEL as
range of t1 is R1
.
.
range of tk is Rk
retrieve (ti1.A1,…,tir.Ar)
where Ψ (condition)
Statements in QUEL
Retrieve into :
Used to create a newfile and insert tuples
range of t1 is R1
.
.
range of of tk is Rk
retrieve into S (A1=W1,…,An=Wn)
where Ψ (t1 ,…,tn)
• The above query creates a newfile and insert tuples
into the file
• Retrieve is similar to SELECT operation in Relation
Algebra
Statements in QUEL
Delete:
Used to calculate the set difference
range of t is R
delete t
where Ψ (t)
Delete from R all tuples where Ψ (t)
Statements in QUEL
append to:
to append tuples to existing relation
range of t1 is R1
.
.
range of of tk is Rk
append to S (A1=W1,…,An=Wn)
where Ψ (t1 ,…,tn)
• append to is similar to Set Union operation of
Relational Algebra
Completeness of QUEL
• Lets evaluate with the Five basic operations
Suppose R(A1,...,An) and S(B1,...,Bm) are two relations and T is a new
relation name
Union (T=R U S) (assuming m=n)
range of r is R
append to T (C1=r.A1,…, Cn=r.An)
range of s is S
append to T (C1=s.A1,…, Cn=s.Bn)
Completeness of QUEL
Suppose R(A1,...,An) and S(B1,...,Bm) are two relations and T is a new
relation name
Set Difference(T=R - S) (assuming m=n)
range of r is R
append to T (C1=r.A1,…, Cn=r.An)
range of s is S
range of t is T
delete t where s.B1=t. C1 and … and s.Bn=t.Cn)
Completeness of QUEL
Suppose R(A1,...,An) and S(B1,...,Bm) are two relations and T is a new
relation name
Cartesian Product (T=R X S)
range of r is R
range of s is S
append to T (C1=r.A1,…, Cn=r.An, Cn+1=s.B1 ,… , Cn+m=s.Bm)
Completeness of QUEL
Suppose R(A1,...,An) and S(B1,...,Bm) are two relations and T is a new
relation name
Selection (σF(R))
range of r is R
append to T (C1=r.A1,…, Cn=r.An) where F
Completeness of QUEL
Suppose R(A1,...,An) and S(B1,...,Bm) are two relations and T is a new
relation name
Projection (Пi1,... ik (R) )
range of r is R
append to T (C1=r.A i ,…, Ck=r.A i )
1
k
Example
Find the name and rating of Sailors whose rating is greater than 7
range of t is Sailors
retrieve into SN (S=s.Name,R=s.Rating)
where rating > 7
Summary
• QUEL is purely based on TRC.
• It is quite expressive (relationally complete).
• Majority of the DBMS incorporated earlier with
QUEL are replaced by SQL.
• Still lives in the open source community.
Download