Documente Academic
Documente Profesional
Documente Cultură
Example 1:
Example 2:
2. List the names of the persons who work for company ’FBC’ along with the cities they live in.
3. Find the persons who work for company ’FBC’ with a salary of more than 10000. List the names of these
persons along with the streets and cities where they live.
4. Find the names of the persons who live and work in the same city.
5.Find the names of the persons who live in the same city and on the same street as their managers.
6.Find the names of the persons who do not work for company ’FBC’.
7. Find the persons whose salaries are more than the salary of everybody who work for company ’SBC’.
8. Find the names of the companies that is located in every city where company ’SBC’ is located in.
Example 3:
Consider the following tables:
Example 4:
Solution: For this query we have to relate subject to itself. To disambiguate the relation,
we will call the subject relation R or S.
(
lecturer R.lecturer = S.lecturer AND R.code <> S.code (R S))
Solution: For this query we have to relate enrolledIn to itself. To disambiguate the relation,
we will call the enrolledIn relation R orS.
name (student ( (R
R.id = S.id AND R.code <> S.code S)))
13. What are the names of students who are taking a subject not taught by Roger?
Solution: (
starName age > 40 AND movieName = Sneakers (star starsIn))
6. What are the names of stars who star in movies produced by studios located inBurbank?
Example 6:
Employee(Fname,Minit,Lname,SSn,Bdate,Adress,Sex,Salary,Super_ssn,Dno)
Department(Dname,Dnumber,Mgr_ssn,Mgr_start_date)
Dept_Locations(Dnumber,Dlocation)
Project(Pname,Pnumber,Plocation,Dnum)
Works_On(Essn,Pno,Hours)
Dependent(Essn,Dependent_name,Sex,Bdate,Relationship)