2.5.1 D) Product(maker, model, type) PC(model, speed, ram, hd, price) Laptop(mod
ID: 3606233 • Letter: 2
Question
2.5.1
D)
Product(maker, model, type)
PC(model, speed, ram, hd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)
1) Show the Tuples that don't satisfy to the following constraint: A manufacturer of a PC must also make a laptop with at least as great a processor speed.
This is how far I got, with this constraint I get only B as answer. But im supposed to get B,C and D.
Select N.Maker
From
((Select PR1.Maker,Min(PC.Speed) as Q1
From Product PR1
Inner Join PC
On PR1.Model=PC.Model
Group by PR1.Maker) as Q3,
(Select PR2.Maker, Max(Laptop.Speed) as Q2
From Product PR2
Inner Join Laptop
On PR2.Model=Laptop.Model
Group by PR2.Maker) as Q4) as N
Where Q3.Maker = Q4.Maker AND Q1 > Q2
I would like the answer in SQL language please.
Explanation / Answer
This query says that those tuples which don't satisfies this contraints,
so one way of doing this is first we select all Makers and then form these makers we subtract all those which satisfies this contraints.
So the query goes like this:
SELECT maker FROM Product MINUS SELECT Maker FROM Product NATURAL JOIN PC NATURAL JOIN LAPTOP where Product.speed = max(Product.speed) and Laptop.speed = max(speed)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.