Question

In: Computer Science

Consider the following database schema:                Product(maker, model, type)                PC(model, speed

Consider the following database schema:

               Product(maker, model, type)

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

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

               Printer(model, color, type, price)

Give SQL statement for each of the following:

  1. (Subqueries, Join operations) Write the following queries in SQL:
  1. Find the makers of PC’s with a speed of at least 1200.
  2. Find the printers with the highest price.
  3. Find the laptops whose speed is lower than that of any PC.
  4. Find the model number of the item (PC, laptop, or printer) with the highest price.
  5. Find the maker of the color printer with the lowest price.
  6. Find the maker(s) of the PC(s) with the fastest processor among all those PC’s that have the smallest amount of RAM.

Solutions

Expert Solution

Consider the following database schema:

Product(maker, model, type)

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

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

Printer(model, color, type, price)

1. Find the makers of PC’s with a speed of at least 1200.

=> Select maker from Product

NATURAL JOIN PC

Where PC.speed >= 1200 And Count (distinct model)>=2

2.Find the printers with the highest price.

=> Select model from Printer

Where Price >= ALL (Select price from Printer)

3.Find the laptops whose speed is lower than that of any PC.

=> Select model from Laptop

Where speed <= ALL (Select speed from PC)

4.Find the model number of the item (PC, laptop, or printer) with the highest price.

=> Select model from

(Select model, price from PC)

UNION

(Select model, price from Laptop)

UNION

(Select model, price from Printer) model_price

Where price >= ALL (Select price from model_price)

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

=> Select distinct maker from Product, Printer

Where color ='true' And Printer.model = Product.model

And price <= ALL (Select price from Printer

Where color ='true')

6.Find the maker(s) of the PC(s) with the fastest processor among all those PC’s that have the smallest amount of RAM.

=> Select distinct maker from Product, PC

Where Product.model = PC.model

And RAM <= ALL( Select ram from PC)

And Speed >= ALL( Select speed from PC

Where ram = ( select min (ram) from PC))


Related Solutions

Consider the following database schema:                Product(maker, model, type)                PC(model, speed
Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Give SQL statement for each of the following: (Grouping and Aggregation) Write the following queries in SQL: Find the average speed of laptops costing over $2000. Find the average price of PC’s and laptops made by manufacturer “D”. Find, for each manufacturer, the average screen size of its laptops. Find the manufacturers...
SQL query exercises: Consider the following database schema:                Product(maker, model, type)              &
SQL query exercises: Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Consider the Drivers-Cars-Reserves DB for a small rental car company:                Drivers(id, name, rating, age)                Cars(vin, maker, model, year, color)                Reserves(did, vin, date) Give SQL statement each of the following operations: Find the colors of cars reserved by Smith. Find all id’s of drivers who have a...
For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name,...
For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name, price, quantity) transaction(trans_id, cust_id, time_date) product_trans(product_id, trans_id) Identify the primary keys and foreign keys for the relations and specify at least two different types of integrity constraints that would be applicable for different relations given.
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes Express the following queries in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that a person likes Express the following queries...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes. Express the following queries in...
7. Using the provided schema of a Purchase Order Administration database, write the following queries in...
7. Using the provided schema of a Purchase Order Administration database, write the following queries in SQL. (In the schema, bold attributes are primary keys and italicized attributes are foreign keys.) SUPPLIER (SUPNR, SUPNAME, SUPADDRESS, SUPCITY, SUPSTATUS) SUPPLIES (SUPNR, PRODNR, PURCHASE_PRICE, DELIV_PERIOD) PRODUCT (PRODNR, PRODNAME, PRODTYPE, AVAILABLE_QUANTITY) PO_LINE (PONR, PRODNR, QUANTITY) PURCHASE_ORDER (PONR, PODATE, SUPNR) 7d) Write a nested SQL query to retrieve the supplier number, supplier name, and supplier status of each supplier who has a higher supplier status...
Consider the STAR schema with dimensions Customer, Product, and Time. The fact table has a measure...
Consider the STAR schema with dimensions Customer, Product, and Time. The fact table has a measure called Purchase_Price. This measure is: - additive -non-additive -semi-additive
Consider an economy described by the IS-LM-PC model, and suppose that agents in it have unanchored...
Consider an economy described by the IS-LM-PC model, and suppose that agents in it have unanchored inflation expectations. Finally, assume that the economy begins at the medium run equilibrium with a positive medium run rate of inflation. Invariably, a drop in consumer confidence in this economy will produce the following immediate outcome. Select one: a. Inflation acceleration; b. A decrease in potential output; c. Deflation; d. Disinflation;
Green Angel Inc. is an auto part maker and produces a particular product: Type X605. The...
Green Angel Inc. is an auto part maker and produces a particular product: Type X605. The standard costs and actual production results are listed as follows: Cost standards for one unit of product Type X605: Direct material 3 pounds at $2.5 per pound $7.5 Direct labor 5 hours at $8 per hour $40 Variable overhead 2.5 hours at $12 per hour $30 Actual production results: Units produced 8,000 units direct material purchased 23,500 pounds at $2.70 per pound direct material...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT