Question

Hw problems help thanks The following questions are based on the tables Product (maker, model, type)...

Hw problems help thanks

The following questions are based on the tables

Product (maker, model, type)

PC(model, speed, ram, hd, price)

Laptop(model, speed, ram, hd, screen, price)

Printer(model, color, type, price)

14. Find those manufacturers that sell laptops but not pc’s.

15. Find those hard-drive sizes that occur in two or more PC’s. [hint; use group and having]

16. Find those pairs of PC models that have both the same speed and RAM. A pair should be listed only once: e.g. list (f, g) but not (g,f)

17. Find the maker of the color printer with the lowest price.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION 14:

select maker from Product p,Laptop L
where p.model==L.model and maker not in (select maker from Product p1,PC where p1.model==PC.model )

EXPLANATION:

STEP 1: We need to find the laptop makers first

STEP 2: We need to eliminate the makers of PC from it

STEP 3: Project those makers

SOLUTION 15:

SELECT hd FROM PC
GROUP BY hd
HAVING count(hd)>=2

EXPLANATION:

STEP 1: Group the hard disks which have the same size by using group by

STEP 2: Check their Count by using having clause and project them

SOLUTION 16:

SELECT p1.model AS MODEL1, p2.model MODEL2
FROM PC p1 JOIN PC p2 ON p1.model!=p2.model AND p1.speed==p2.speed AND p1.ram==p2.ram
WHERE p1.model>p2.model

EXPLANATION:

STEP 1: We need to do a self join based on the condition of the equal speed and ram

STEP 2: We need to eliminate matching of same rows in both tables by matching with the model (p1.model!=p2.model)

STEP 3: To eliminate the duplicate rows of matching(i,j) and (j,i) we do it by (p1.model>p2.model )

STEP 4: Project the fields

SOLUTION 17:

SELECT DISTINCT maker
FROM Product p, Printer pr
WHERE color=="Y" AND price==(SELECT MIN(price) FROM Printer) AND p.model=pr.model

EXPLANATION :

STEP 1: We need to find the color printer by checking the color attribute whether it is Y or N

STEP 2: Select the min Price of the Printer

STEP 3: Map That with the products model

STEP 4: We need to find the distinct of those Makers to eliminate duplicate makers

Add a comment
Know the answer?
Add Answer to:
Hw problems help thanks The following questions are based on the tables Product (maker, model, type)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question from book - Database systems the complete book (second edition) by hector Garcia-molina Jeffery D....

    Question from book - Database systems the complete book (second edition) by hector Garcia-molina Jeffery D. Ullman Jennifer Widom Exercise 7.5.2: Write the following as triggers. In each case, disallow or undo the modification if it does not satisfy the stated constraint. The database scheme is from the "PC" example of Exercise 2.4.1: Product(maker, model, type) PC(model, speed, ram, hd, price) Laptop(model, speed, ram, hd, screen, price) Printer(model, color, type, price) A) When updating the price of a PC, check...

  • SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and...

    SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and insert all the data. Show the SQL statements to create each table and show a representative SQL insert statement for the data in each table (i.e. you do not need to show insert statements for all the data). – For the remaining questions, assume that your SQL is part of a program function and the function provides the input needed for your SQL query....

  • Find the manufacturer(s) of the computer (PC or laptop) with the highest available speed. Write in...

    Find the manufacturer(s) of the computer (PC or laptop) with the highest available speed. Write in Relational Algebra. Pc 1002 pc pc Product model maker type 1001 pc 1003 pc 2004 laptop 2005 laptop 2006 laptop 1004 pc 1005 pc 1006 2007 laptop 1007 1008 pc 1009 pc 1010 pc 3004 printer 3005 printer 1011 pc 1012 1013 pc 2001 laptop 2002 laptop 2003 laptop 3001 printer 3002 printer 3003 printer 2008 laptop 2009 laptop 2010 laptop 3006 printer 3007...

  • Please help we are suppose to explain what the C code does. This is the electronics database (6 pts) This problem is...

    Please help we are suppose to explain what the C code does. This is the electronics database (6 pts) This problem is based on Electronics database. Add some annotations to the following table to explain what the C program is doing in detail. Note that "void" is how C declares a function that does not return anything. You are expected to generalize or research svntaxes not mentioned in the lecture C Program Annotation void newPCproduct EXEC SQL BEGIN DECLARE SECTION;...

  • Please use own words. Thank you. CASE QUESTIONS AND DISCUSSION > Analyze and discuss the questions...

    Please use own words. Thank you. CASE QUESTIONS AND DISCUSSION > Analyze and discuss the questions listed below in specific detail. A minimum of 4 pages is required; ensure that you answer all questions completely Case Questions Who are the main players (name and position)? What business (es) and industry or industries is the company in? What are the issues and problems facing the company? (Sort them by importance and urgency.) What are the characteristics of the environment in which...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT