Question

consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and...

consider the following schema:

Product(pid, name, type, manufacturer, price)

key: pid

Buys(cid, pid)

key: cid and pid together

Customer(cid, cname, age, gender)

key: cid

1) write the following query in relational algebra; find the names of all customers who have purchased all products manufactured by sears.

2)write the following in sql: find the names of all the customers who have not purchased the most expensive product.

3)write the following query in sql: find the best selling products (in terms of the total sales price) per gender.

4) write the following query in sql: find the type of products with the highest difference in the total sales between males and females customers.

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

1.

SELECT c.cname from customer c, product p, buys b where p.pid = b.pid AND p.cid = c.cid AND p.manufacturer = "Sears";

2.

SELECT c.cname from customer c, product p, buys b where p.pid = b.pid AND p.cid = c.cid AND p.price NOT IN (select MAX(Price) from product);

3.

SELECT p.name from

(SELECT p.name, SUM(p.price) as Price FROM customer c, product p, buys b where p.pid = b.pid AND p.cid = c.cid GROUP BY c.gender Order BY SUM(p.price) desc) where Price IN

(SELECT MAX(p.price) from

(SELECT p.name, SUM(p.price) as Price FROM customer c, product p, buys b where p.pid = b.pid AND p.cid = c.cid GROUP BY c.gender Order BY SUM(p.price) desc));

Add a comment
Know the answer?
Add Answer to:
consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and...
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
  • consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and...

    consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and pid together Customer(cid, cname, age, gender) key: cid 1) write the following query in relational algebra; find the names of all customers who have purchased all products manufactured by sears. 2)write the following in sql: find the names of all the customers who have not purchased the most expensive product. 3)write the following query in sql: find the best selling products (in terms of...

  • Given the following relational schema, write queries in SQL to answer the English questions. There is...

    Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...

  • Consider the following relational schema of the company’s database. Use Tuple Relational Calculus (TRC) & Domain...

    Consider the following relational schema of the company’s database. Use Tuple Relational Calculus (TRC) & Domain Relational Calculus (DRC) expression to answer each of the following three questions (Step by step brief description is appreciated if possible) PRODUCT (pid, stock, supplier) CLIENT (cid, name, address, city) ORDER (orderno, date, quantity, pid, cid) Question 1: Find the number of orders for products that are being ordered in quantities smaller than 100 items by customers living in Madrid. Provide solutions expressed both...

  • Given the following relational schema, write queries in SQL to answer the English questions. There is...

    Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...

  • Given the following relational schema, write queries in SQL to answer the English questions. The Access...

    Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...

  • Consider a database schema consisting of two tables, Employee (ID, Name, Address), Project(PID, Name, Deadline), Assign...

    Consider a database schema consisting of two tables, Employee (ID, Name, Address), Project(PID, Name, Deadline), Assign (EID, PID, Date). Assign.EID is a foreign key referencing employee's ID and Assign.PID is a foreign key reference the project. Write the SQL query for 1. Find Projects that are not assigned to any employees(PID and Name of the project).

  • Given the following relational database schema (primary keys are bold and underlined). Answer questions 2.1 to 2.4 Orde...

    Given the following relational database schema (primary keys are bold and underlined). Answer questions 2.1 to 2.4 Orders(orderld, customerld, dateOrdered, dateRequired, status) Customer(customerld, customerLastName, customerStreet, customerCity, customerState, customer Lip OrderDetails(orderld.productld, quantity, lineNumber, amount) Products(productld, name, description, quantity, unitPrice) Account(accountNumber, customerld, dateOpened, creditCard, mailingStreet, mailingCity, mailingState, mailingZip) 2.1 (2 Points) List all possible foreign keys. For each foreign key list both the referencing and referenced relations. 2.2 (2 Points) Devise a reasonable database instance by filling the tables with data of...

  • Please, No handwriting COURSE; introduction to database thank you for your efforts and time The f...

    Please, No handwriting COURSE; introduction to database thank you for your efforts and time The following set of schemas is given: Customer (name, age, gender) Visit (name, store) Receipt (name, product) Offer (store, product, price) Write the following queries in relational algebra, using the above schema: 1. Find all stores visited by at least one customer under the age of 18. 2. Find the names of all females who bought either product # 1 or product #2. 3. Find all...

  • Consider the following schema: SUPPLIERS (SID: integer, SNAME: string, STREET: string, CITY: string, ZIP: string) PARTS...

    Consider the following schema: SUPPLIERS (SID: integer, SNAME: string, STREET: string, CITY: string, ZIP: string) PARTS (PID: integer, PNAME: string, COLOR: string) CATALOG (SID: integer, PID: integer, COST: real) The primary key attributes are underlined, and the domain of each attribute is listed after the attribute name. Thus, SID is the primary key for SUPPLIERS, PID is the primary key for PARTS, and SID and PID together form the primary key for CATALOG. Attribute SID in CATALOG is a foreign...

  • Answer the following five (5) questions, based on the schema provided.

    C. Answer the following five (5) questions, based on the schema provided.Consider the following schema:Supplier (sid: integer, sname: string, address: string)Part(pid: integer, pname: string, , color: string)Catalog(sid: integer, pid: integer, cost: real)The relation Supplier stores suppliers and the primary key of that relation is sid. The relation Part stores parts, and pid is the primary key of that relation. Finally, Catalog stores which supplier supplies which part and at which cost (price). The primary key is the combination of the...

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