Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

Algebra and SQL examples

Given the following tables

:Employee table
tel addres super Dno Salary lname fanme Number

:Department table
mgrsn locate dname dno

Note: (the true answer is underlined)


1. ( σ * DNO = 4
(EMPLOYEE)
) means:
A. selects all employee names
B. list all information for employees working on department four.
C. selects all information for employees working on department four.
D. select employee names whose working in department number is four

2- (σ * (department)
) means:
a. select only names from the table
b. select names and number
c- a+b
d. not of above

3- (σ * dno.employ=dno.dept ^ addres=”karak” (employee X department) )


A. list all information about employee
b. list all information about employee who work in department 4 and lives karak
c. list all information about department 4 and employee who lives karak
d. not of above

4. (σ * name=ali ^ salary > 500 (employee) ) means:


a. select all inforamtion about whose names ali and salary greater or equal 500
b. select all information about whose names ali and salary lessthan or equal 500
c. select all inforamtion about whose names ali and salary greater 500
d. not of above

5. ( σ * dno,dname (department) ) means:


a. list only dno from department table
b. list only dname from department table
c. a+b
d. not of above
6. π (σ * mgrsn.department=number.employee
(employee X department)
) means:
Fname, dname

a. select fname, dname from employee table and department table


b. list fname, dname from employee table and department table
c. a + b
d. not of above

7. ( π LNAME, FNAME, SALARY


( EMPLOYEE)
); means:
A. list each employee’s first and last name and salary
B. list all employee
C. list all employee last names
D. list all employee names and their salaries.

8. (π fname, tel, dname


(emloyee X department)
); means:
dno.employy=dno.dpartment
^ dno = 4
A. select addrss,telphon,dname for all employee
b. list addrss,telphon,dnumber for all employee.
c. list addrss,telphon,dname for all employee and department name.
d. list fname,tel, dname for employee who works on department number 4

9. (π fname (σ salary >300


(employee )
):
a. list fname whose salary greater than 300
b. list salary, fname whose salary grater than 300
c. a + b
d. not of a bove

10. (π fname, dnum


(emloyee X department)
); means:
dno.employee=dno.dpartment
^ fname.employee = “ali”
a. select fname, dname for employee whose names ali
b. select fname,dnum for employee whose names ali
c. list fname, dname for employee whose names ali
d. not of a bove

11. (π fname (σ employee


X department ) )
salary >300
^ dno=2
a. list salary, dno from employee and department
b. list fname, dno from employee who works on department 2
c. list fname from employee who works on department 2
d. not of above
12. ( fname G max (salary )
employee
) the result is:
a. the max salary from department table
b. the max salary from employee table
c. a + b
d. not of a bove

13. (G max (salary )


employee
) the result is:
a. the max salary from department table
b. the max salary from employee table
c. the salary, fname whose have max salary
d. not of a bove

14. (G count (* )
employee
) the result is:
a. the number of all who’s named ali
b. the number of employee
c. the number of employee who lives amman
d. not of above

15. (G addrss= “amman”


employee
) the result is:
count ( ), sum(salary)

a. number of employee who lives amman


b. the number of employee and sum of employees salary
c. the sum of employees salary
d. not of above

16. ( dno G employee


) the result is:
count(*)

a. number of department
b. dno and number of department
c. dno and number of employee
d. not of above

.
19. (π fname ) ‫ ( ــ‬π
(department)
)fname
(employee)

mgrsnn super
17. ( a. fname who are manager)andthe
dnamelistG employee X department
not aresult is:
supervisor
dno.employee=dno.department
b. list fname who are supervisor and not a manager
c. a + bcount ( *)
d.
a. not
dnameof above
and number of department
b. dnum and employee name works on
c. dname and number of employee works on
20. (πd.
(department)
not of above
fname ) U (π fname
(employee)
)
mgrsnn super

a. list fname for employee who are as suppervisor


18. (G
b. list fname address=”karak”
employee
)
for employee who are not a manager
Avr (salary)
c. list fname for employee who are a manager and supervisor
d. not
a. of
theabove
average of employees salary and employees name
b. the average of employees salary who’s live karak
c. a+b

21. d. fname (department)
not of above )
∩ (π fname
(employee)
)
mgrsnn super

a. list fname for employee who are as suppervisor


b. list fname for employee who are not a manager
c. list fname for employee who are a manager and supervisor
d. b+c

22. (π fname
(employee)
) ‫ ( ــ‬π fname
(employee X department)
)
ssn.employee=number.employee

a. list fname for employee who are a manager


b. list fname for employee who are not a manager
c. list fname for all employee
d. not of above
- read all question and choose the result for each sql statement :
group

23. ( select * from employee )


Where dno=4 ;

A. selects all employee names


B. selects all DNO.
C. selects all information for employees whose working on department four.
D. select employee names whose working in department number is four

24- . ( select * from employee


)
means:
a. select only names from the table
b. select names and number
c- a+b
d. not of above

25- ( select * from employee,department )


where dno.employee=dno.depart ^ addres=”karak

A. list all information about employee


b. list all information about employee who work in department 4 and lives karak
c. list all information about department 4 and employee who lives karak
d. not of above

26. ( select * from employee )


where name=ali ^ salary > 500

a. select all inforamtion about whose names ali and salary greater or equal 500
b. select all information about whose names ali and salary lessthan or equal 500
c. select all inforamtion about whose names ali and salary greater 500
d. not of above

group

27. ( select dno,dname )


From department

a. list only dno from department table


b. list only dname from department table
c. a+b
d. not of above

28. ( select fname, dname from employee, department )


where mgrsn.department=number.employee

a. select fname, dname from employee table and department table


b. list fname, dname from employee table and department table
c. a + b
d. not of above

29. ( select Lname, Fname, salary from employee )


A. list each employee’s first and last name and salary
B. list all employee
C. list all employee last names
D. list all employee names and their salaries.

group
30. ( select fname, tel, dname from employee, department ) ; means:
where dno.employee=dno.dpartment
^ dno = 4
A. select addrss,telphon,dname for all employee
b. list addrss,telphon,dnumber for all employee.
c. list addrss,telphon,dname for all employee and department name.
d. list fname,tel, dname for employee who works on department number 4

31. ( select fname from employee ) :


Where salary >300

a. list fname whose salary greater than 300


b. list salary, fname whose salary grater than 300
c. a + b
d. not of a bove

32. ( select fname, dnum from emloyee , department ) ; means:


where dno.employy=dno.dpartment
^ fname.employee = “ali”
a. select fname, dname for employee whose names ali
b. select fname,dnum for employee whose names ali
c. list fname, dname for employee whose names ali
d. not of a bove

33. ( select fname from employee , department )


where salary >300
^ dno=2
a. list salary, dno from employee and department
b. list fname, dno from employee who works on department 2
c. list fname from employee who works on department 2
d. not of above

group
34. ( select fname from employee )
Group by max (salary)
the result is:
a. the max salary from department table
b. the max salary from employee table
c. a + b
d. not of a bove

35. ( select fname from employee )


Group by min (salary)
the result is:
a. the max salary from department table
b. the max salary from employee table
c. the salary, fname whose have max salary
d. not of a bove

36. ( select fname from employee )


where addrss= “amman” group by count ( ), sum(salary)
the result is:
a. number of employee who lives amman
b. the number of employee and sum of employees salary
c. the sum of employees salary
d. not of above

37. ( select dno,count from employee )


Group by count(*) the result is:
a. number of department
b. dno and number of department
c. dno and number of employee
d. not of above

38. ( select dname from employee , department ) the result is:


where dno.employee=dno.department
group by count ( *)

a. dname and number of department


b. dnum and employee name works on
c. dname and number of employee works on
d. not of above

39 .( select fname from employee )


where address=”karak” group by Avr (salary)

a. the average of employees salary and employees name


b. the average of employees salary who’s live karak
c. a+b
d. not of above

group
40. ( select fname from employee ) ‫ ( ــ‬select fname from employee)
where mgrsnn=number where superssn=number

a. list fname who are manager and not a supervisor


b. list fname who are supervisor and not a manager
c. a+b
d. not of above

41 select fname from employee ) U ( select fname from employee)


where mgrsnn=number where superssn=number

a. list fname for employee who are as suppervisor


b. list fname for employee who are not a manager
c. list fname for employee who are a manager or supervisor
d. b+c

42.( select fname from employee ) ∩ ( select fname from employee)


where mgrsnn=number where superssn=number

a. list fname for employee who are as suppervisor


b. list fname for employee who are not a manager
c. list fname for employee who are a manager or supervisor
d. not of above

43. ( select fname from employee ) -


(select fname from employee, department)
ssn.employee=number.employee

a. list fname for employee who are a manager


b. list fname for employee who are not a manager
c. list fname for all employee
d. not of above

group
44. ( select * from employee )
Where fname=”%a%”
a. list all information for employee who his name start by a character
b. list all information for employee who his name end by a character
c. list all information for employee who his name having a character
d. not of above

45. ( select * from employee )


Where fname=”_a%”
a. list all information for employee who his name start by a character
b. list all information for employee who his name end by a character
c. list all information for employee who his name having a character
d. not of above

46. ( select * from employee )


Where fname=”%a_”
a. list all information for employee who his name start by a character
b. list all information for employee who his name end by a character
c. list all information for employee who his name having a character
d. not of above

You might also like