Upload
vinod-vinu
View
8
Download
3
Embed Size (px)
DESCRIPTION
database key
Citation preview
Assignment 1
Assignment 1
Product (maker, model, type)PC (model, speed, ram, hd, rd, price)Laptop (model, speed, ram, hd, screen, price)Printer (model, color, type, price)a. Find the model number, speed, and hard-disk size for all PCs whose price is under $1200.
SELECT model, speed, hdFROM PCWHERE pricem2.length AND m2.title=Gone with the Windd. Which executives are worth more than Merv Griffin?
SELECT e1.name
FROM MovieExec e1, MovieExec e2
WHERE e2.name="Merv Griffin"
AND e1.netWorth > e2.netWorth
Assignment 3
a. Give the manufacturer and speed of laptops with a hard disk of at least thirty megabytes.
SELECT maker, speedFROM Product NATURAL JOIN LaptopWHERE hd>=30b. Find those manufacturers who sell laptops, but not PCs.
SELECT maker
FROM Product
WHERE type="Laptop"
AND maker NOT IN
(SELECT maker from Product
WHERE type="PC")
c. Find those pairs of PC models that have both the same speed and RAM.
SELECT p1.model, p2.model
FROM PC p1, PC p2
WHERE p1.speed=p2.speed AND p1.ram=p2.ram
AND p1.model>p2.modelAssignment 4Use subqueries for each query.
a. Find the makers of PCs with a speed of at least 1200.
SELECT maker FROM productWHERE model IN (SELECT model FROM PC WHERE speed>=1200)b. Find the printers with the highest price.
Select model from Printer where price >= ALL (Select price from printer)
c. Find the laptops whose speed is slower than that of any PC.
Select model from Laptop where speed