0% found this document useful (0 votes)
26 views

Ics321 HW2

Uploaded by

Mahdi Abbadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Ics321 HW2

Uploaded by

Mahdi Abbadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Mahdi Al-Abbadi 201839000

ICS321 – Homework 2

1. [10 points] Consider the following relations and write the appropriate SQL statements to answer the queries
given below.
SELECT FNAME,LNAME,SSN
FROM EMPLOYEE,WORKS_ON
WHERE EMPLOYEE.SSN = WORKS_ON.ESSN AND
WORKS_ON.PNO IN (2,3)
SELECT DISTINCT p.PNAME
FROM PROJECT p, WORKS_ON w, EMPLOYEE e, DEPENDENT d
WHERE
e.SSN NOT IN (SELECT d.ESSN FROM DEPENDENT d) AND
p.PNUMBER IN
(SELECT w.PNO FROM WORKS_ON W
GROUP BY w.PNO
HAVING COUNT(w.ESSN) = 3)
DEGGRE = 6, CARDINALITY = 96
SELECT FNAME, LNAME
FROM EMPLOYEE e,WORKS_ON w, PROJECT p
WHERE
w.HOURS < 5 and w.ESSN = e.SSN and p.pname = 'Computerization'
SELECT DISTINCT FNAME, LNAME
FROM EMPLOYEE e INNER JOIN WORKS_ON w on e.SSN = w.ESSN
WHERE e.SSN IN (SELECT ESSN FROM WORKS_ON GROUP BY ESSN HAVING COUNT(PNO) > 2)

2. [8 points] Given the following schema:

Manufacturer {ID,Name, Street, City, State, Zip, Phone}


Product {PID, Name, Buying_Price, Selling_Price, Size, Manufacturer_Name} Foreign Key {Manufacturer_Name}
references Manufacturer,
Warehouse {ID,Name, Location, City, State, Zip, Space}
Stores {Warehouse_Name, PID, Qty} Foreign Key {Warehouse_Name} references Warehouse, Foreign Key {PID}
references Product;

Write SQL Queries for the following:


(I ADDED ID FOR BOTH MANUFACTURER AND WAREHOUSE)
i. SELECT NAME, PHONE FROM Manufacturer WHERE CITY = “DAMMAM”
ii. SELSECT PID, NAME FROM Product p, Manufacturer AS m WHERE p.PID= m.ID AND m.CITY =
“DAMMAM”
iii. SELSECT p.PID, p.NAME FROM Product p, STORES s WHERE s.PID = p.PID AND s.Warehouse_Name =
“JEDDAH”
iv. SELECT w.NAME,m.NAME FROM WAREHOUSE FULL OUTER JOIN MANUFACTURER ON m.ID = w.ID
WHERE m.CITY = w.CITY

3. [22 points] A system is to be created to manage the calendar of campus events.

You might also like