Only need parts b,d, and e for Exercise 6.5.1 Exercise 6.5.1: Write the followin
ID: 3699582 • Letter: O
Question
Only need parts b,d, and e for Exercise 6.5.1
Exercise 6.5.1: Write the following database modifications, based on the database schema Product (maker, model, type) PC (model, speed, ram, hd, price) Laptop (model, speed, ram, hd, screen, price) Printer (model, color, type, price) of Exercise 2.4.1. Describe the effect of the modifications on the data of that exercise. a) Using two INSERT statements, store in the database the fact that PC model 1100 is made by manufacturer C, has speed 3.2, RAM 1024, hard disk 180, and sells for S2499. ! b) Insert the facts that for every PC there is a laptop with the same man facturer, speed, RAM, and hard disk, a 17-inch screen, a model number 1100 greater, and a price $500 more. c) Delete all PC's with less than 100 gigabytes of hard disk d) Delete all laptops made by a manufacturer that doesn't make printers e) Manufacturer A buys manufacturer B. Change all products made by B so they are now made by A f) For each PC, double the amount of RAM and add 60 gigabytes to the amount of hard disk. (Remember that several attributes can be changed by one UPDATE statement.) ! g) For each laptop made by manufacturer B, add one inch to the screen size and subtract $100 from the price.Explanation / Answer
Answers.)
A)
INSERT INTO PC (MODEL,SPEED,RAM,HD,PRICE)
VALUES (1100,3.2,1024,180,2499);
INSERT INTO PRODUCT (MAKER,MODEL,TYPE)
VALUES ('C',1100,'PC');
B)
INSERT INTO LAPTOP
SELECT MODEL+1000,SPEED,RAM,HD,17,PRICE+500
FROM PC WHERE MODEL IN (SELECT DISTINCT MODEL FROM PRODUCT WHERE TYPE='PC');
INSERT INTO PRODUCT
SELECT MAKER,MODEL+1100'LAPTOP' WHERE MAKER='PC';
C)
DELETE FROM PRODUCT
WHERE MODEL IN(SELECT MODEL FROM PC WHERE HD<100);
DELETE FROM PC WHERE HD<100;
D)
DELETE FROM PRODUCT WHERE MAKER IN(SELECT MAKER FROM PRODUCT WHERE TYPE NOT IN ('PRINTER')) AND TYPE = 'LAPTOP';
DELETE FROM LAPTOP
WHERE MODEL NOT IN (SELECT DISTINCT MODELS FROM PRODUCT WHERE TYPE='LAPTOP');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.