










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
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
};