This question uses the following ODL classes:
class Student (extent Students key id) {
attribute string name;
attribute int ID;
relationship Set<Course> enrolledIn
inverse Course::students;
relationship Set<Course> CoursesTAing
inverse Course::TAsOfCourse;
}
class Course (extent Courses key number) {
attribute string number;
relationship Set<Student> students
inverse Student::enrolledIn;
relationship Set<Student> TAsOfCourse
inverse Student::CoursesTAing;
}
The interpretation should be obvious:
students have ID's (key) and names, courses have numbers (key) and
TAs, who are themselves students. Students are enrolled in certain
courses. Write the following queries in OQL:
Bids(auctionID, bidder, price, quantity)
Auctions(auctionID, seller, item, quantity, expires)
Ratings(seller, stars)
Design an equivalent ODL schema. You may assume that in Bids, a bidder may place several bids for one auction, but all bids by one bidder will have different prices. Indicate keys and extents.
create row type AddressType as (street string, city string)Write SQL3 queries for each of the following. You may assume that student and college names are unique, that all students have exactly one address, attend one college, and have one roommate, and that all colleges are located in exactly one city.
create row type StudentType as (name string, address AddressType)
create row type CollegeType as (name string, city string)
create table Student of type StudentType
create table College of type CollegeType
create table Attends(student ref(StudentType), college ref(CollegeType),
tuition integer)
create table Roommates(student1 ref(StudentType), student2 ref(StudentType))
(a) Find the names of all students who live in Santa Cruz.
(b) Find the names of all students who attend Santa Cruz.
(c) Find the names of all students who live in the same city as the college they attend and pay tuition of at least $10,000.
(d) Find the names of all students who live in the same city and on the same street as their roommate. (Let's assume that addresses in the database are home addresses and not college addresses - otherwise this query would return everyone.)