Quiz 2 Version 2
Quiz 2 Version 2
A. DROP DATABASE
B. DELETE DATABASE
C. REMOVE DATABASE
D. None of the mentioned
Ans : A
2- Which statement would add a column CGPA to a table Student which is already created 0.5
Ans : C
3- Consider we have 30 employees where 20 of them belong to different departments and
the rest don’t belong to any department. On the other hand, we have 4 departments where
each of them have employees assigned to it. How many record will result by performing left
outer join between Table Employee and Department? (Employee left join Department) 0.5
10
20
30
40
6 - Given SPJ schema, Which of the following queries get the names of suppliers who supply parts for
projects located in London or Paris.
b- select sname
from S,SPJ,J
where S.s#=SPJ.s# and J.j#=SPJ.J#
and J.city = 'London'or J.city = 'Paris'
c- select sname
from S,SPJ,J
where S.s#=SPJ.s# and J.j#=SPJ.J#
and (J.city = 'London'and J.city = 'Paris')
d- select sname
from S,SPJ,J
where S.s#=SPJ.s# and J.j#=SPJ.J#
and (S.city = 'London'or J.city = 'Paris')
e- select sname
from S,SPJ
where S.s#=SPJ.s#
and (S.city = 'London'or S.city = 'Paris')
7-Given SPJ schema, which of these sql statements don’t violate referential integrity constraint and
entity constraint?
9- For each department whose average employee salary is more than $30,000, retrieve the department
name and the number of employees working for that department.
Select dname, avg(salary) as avg_salary, count(ssn)as employeecount
From department, employee
Where dnumber=dno
group by dname
having avg(salary)>30000
incorrect choices:
///////////////////////////////////////////////////
ID Department Name
01 Sales Mark
02 Human Resources John
03 Marketing Suzy
04 Accounting Adam
05 Engineering Peter
NULL NULL NULL
Correct answer:
select distinct CategoryName
from dbo.Products,dbo.Orders,dbo.[Order Details],dbo.Shippers,dbo.Categories
where dbo.Categories.CategoryID=dbo.Products.CategoryID and
dbo.Orders.OrderID=dbo.[Order Details].OrderID and dbo.Products.ProductID=dbo.
[Order Details].ProductID and dbo.Orders.ShipVia= dbo.Shippers.ShipperID
and dbo.Shippers.CompanyName='United Package'
incorrect answers:
13-Given SPJ schema, which of the following SQL DDL query is correct for declaring S table, you must
ensure that the status column can’t be below 10 and can’t be above 40 and all the columns can’t be null.
a- create table S
(
s# varchar(5),
sname varchar(20) not null,
status int not null check (status >= 10 and status <= 40),
city varchar(20) not null,
primary key(s#)
);
b- create table S
(
s# varchar(5),
sname varchar(20) not null,
status int not null check (status >= 10 and status <= 40),
city varchar(20) not null,
);
c-create table S
(
s# varchar(5),
sname varchar(20) not null,
status int not null check (status >= 10 and status <= 40),
city varchar(20) not null,
primary key(s#),
);
d- none of the above
14- which of the following queris Return a list of distinct customers
(CustomerID,CompanyName)who has orders shipped to UK
b- select c.CustomerID,CompanyName
from Customers c
where exists (select * from orders where ShipCountry='UK')