Documente Academic
Documente Profesional
Documente Cultură
Example 2:
Consider the relation schemas as follows.
works(person name, company name, salary); lives(person name, street, city); located in(company name, city); managers(person name, manager name); where manager name refers to person name.
1. Find the names of the persons who work for company FBC (company name FBC).
!. "ist the names of the persons who work for company FBC along with the cities they live in.
#. Find the persons who work for company FBC with a salary of more than 1$$$$. "ist the names of these persons along with the streets and cities where they live.
%. Find the names of the persons who live and work in the same city.
&.Find the names of the persons who live in the same city and on the same street as their managers.
'.Find the names of the persons who do not work for company FBC.
(. Find the persons whose salaries are more than the salary of every)ody who work for company *BC.
+. Find the names of the companies that is located in every city where company *BC is located in.
Example 3:
Consider the following tables:
Example 4:
Consider the following tables:
student(id, name) enrolledIn(id, code) subject(code, lecturer) 1. What are the names of students enrolled in cp3020? Solution.
name
cp#$!$ code
(st-dent
enrolled/n))
name 0ector
(st-dent
enrolled/n))
code cp1&$$
(s-)3ect))
(s-)3ect))
R.lect-rer
(R
S))
code cp1&$$
(st-dent
enrolled/n))
name
code cp#$1$
(st-dent
enrolled/n))
code cp1&$$
(st-dent
enrolled/n))
name
code cp#$1$
(st-dent
enrolled/n))
(st-dent
R.id
(R
S)))
(s-)3ect)
(st-dent)
code cp1&$$
(st-dent enrolled/n))
lect-rer ,oger
(st-dent
enrolled/n
s-)3ect))
1#. 1hat are the names of st-dents who are taking a s-)3ect not ta-ght )y ,oger2 Solution.
name
lect-rer :; ,oger
(st-dent
enrolled/n
s-)3ect))
Example 5:
movieName = Sneakers
(movie))
movieName = Sneakers
(starsIn))
age >
(star
starsIn))
(star) "
starName
movieName = Sneakers
(starsIn)))
movieName = Sneakers
(produces))
'. 1hat are the names of stars who star in movies prod-ced )y st-dios located inBurbank2 Solution.
starName
where = #urbank
(studio
produces
starsIn))
Example 6:
Consider the following tables:
$mplo%ee(&name,Minit,'name,SSn,#date,(dress,Se),Salar%,Super*ssn,+no) +epartment(+name,+number,Mgr*ssn,Mgr*start*date) +ept*'ocations(+number,+location) ,roject(,name,,number,,location,+num) -orks*.n($ssn,,no,/ours) +ependent($ssn,+ependent*name,Se),#date,0elationship)