










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of object query language (oql), an sql-like notation used for expressing queries in object-oriented host languages such as c++, smalltalk, or java. It covers topics like path expressions, select-from-where expressions, modifying the result, complex output types, quantifier expressions, aggregation expressions, union, intersection, and difference, assigning values to host-language variables, obtaining each member of a collection, and constants in oql. It also discusses defining types in sql and generator and mutator functions.
Typology: Slides
1 / 18
This page cannot be seen from the preview
Don't miss anything!











SELECT DISTINCT Struct(start1: s1, start2: s2)
FROM Star s1, Star s
WHERE s1.address = s2.address AND s1.name<s2.name
We want the set of pairs of stars living at the same address.
Example: AVG(SELECT m.length FROM Movies m)
We may apply the union, intersection, and difference operators to two objects of set or bag type. These three operators are represented, as in SQL, by the keywords UNION, INTERSECT, and EXCEPT, respectively.
To obtaining each member of a set or bag we need to turn our set or bag into a list. We do so with a select-from-where expressions that uses ORDER BY.
Line 1 sort the movie class. Line 2 computes the number of movies, using the OQL operator COUNT. Line 3 and 4 use for loop inwhich integer variable i ranges over each position of the list. After that the i element of the list assigned to variable movie. Line 5 and 6 are for print.
CREATE TYPE AddressType AS {
street CHAR(50), city CHAR(20)
};
CREATE TYPE StarType AS {
name CHAR (30), address AddressType
};