create row type AddressType as (street string, city string)Write SQL 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 Palo Alto.
(b) Find the names of all students who attend Stanford.
(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.)
We do not know in what order these three transactions execute.
| stmt | user | operation |
|---|---|---|
| 1 | U | grant select on R to V,W with grant option |
| 2 | V | grant select on R to W |
| 3 | W | grant select on R to X,Y |
| 4 | U | grant select on R to Y |
| 5 | U | revoke select on R from V restrict |
| 6 | U | revoke select on R from W cascade |
Show the grant diagram after steps 4, 5, and 6. Since all of the nodes in the diagrams will be for privilege "select on R," you may omit writing it in each node.