Question

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 than supplier number 21.

7e) Write a nested SQL query using the keyword IN to retrieve the supplier name of each supplier who supplies more than five products.

7f) Write an SQL query that retrieves all pairs of suppliers who supply the same product, along with their product purchase price if applicable.

7g) Create a view, SUPPLIEROVERVIEW, which retrieves for each supplier the supplier number, the supplier name, and the total quantities ordered. Once created, query this view to retrieve suppliers for which the total ordered quantity exceeds 30.

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

d)

select SUPNR, SUPNAME, SUPSTATUS from SUPPLIER WHERE SUPSTATUS > (SELECT SUPSTATUS FROM SUPPLIER WHERE SUPNR = 21);

e)

SELECT SUPNAME FROM SUPPLIER WHERE SUPNR IN (SELECT SUPNR FROM SUPPLIES GROUP BY SUPNR HAVING COUNT(DISTINCT PRODNR) > 5);

NOTE: As per HOMEWORKLIB POLICY I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
7. Using the provided schema of a Purchase Order Administration database, write the following queries in...
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
  • 7.13. Consider the following View definition and update statement: CREATE VIEW TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY) AS SELECT PRODNR, PRODNAME,...

    7.13. Consider the following View definition and update statement: CREATE VIEW TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY) AS SELECT PRODNR, PRODNAME, AVAILABLE_QUANTITY FROM PRODUCT WHERE AVAILABLE_QUANTITY>100 WITH CHECK OPTION UPDATE TOPPRODUCTS SET QUANTITY=80 WHERE PRODNR=0153 What will be the result of this? a. The update can be successfully made but only the PRODUCT table will be updated. b. The update can be successfully made and both the View and PRODUCT table will be updated. c. The update will be halted because of the WITH CHECK...

  • Problem 3 [40 points, Formal Query Languages]| Consider the following relational schema to represent information about...

    Problem 3 [40 points, Formal Query Languages]| Consider the following relational schema to represent information about suppliers S, parts P, and projects J, S#, P#, and J# are primary keys for S, P, and J respectively. For a tuple of SPJ, a particular supplier supplies a specific part to a specific project in the specified quantity S(S#, SNAME, STATUS, CITY) P(P#, PNAME, COLOR, WEIGHT, CITY) J(J#, JNAME,CITY) SPJ(S# P# J#, QTY) Write queries for the following requests in specified languages....

  • 2) Consider the database schema on the relations (where key attributes have been underlined): PROJECTS(Number, Department,...

    2) Consider the database schema on the relations (where key attributes have been underlined): PROJECTS(Number, Department, ProjectName) EMPLOYEES(Number, Surname, FirstName, Department) ALLOCATIONSEmplovee, Project, Function, Date) NOTE: relation ALLOCATIONS stores the registration number (attribute Employee) of employees that are assigned to a given project (attribute Project is the number of the project, not the name of the project), the function the employee has in that project (i.e., technician, manager, etc.) and the date when the employee has been assigned to that...

  • ***SQL DML*** Write SQL statements to answer the following questions. Note that you do not need...

    ***SQL DML*** Write SQL statements to answer the following questions. Note that you do not need data tuples to answer these questions. Use the following relational schema. Supplier (sid, name, status, city) Part (pid, name, color, weight, city) Job (jid, name, city) Supplies (/sid/, /pid/, /jid/, quantity) Use subquery, what are the id and the name of all suppliers, whose total quantity is larger than the total quantity of all suppliers in city ‘London’?

  • Consider a database schema with three relations: - Parts (pid:integer, pname:string, year:integer, price:integer) -Suppliers (sid:integer, sname:...

    Consider a database schema with three relations: - Parts (pid:integer, pname:string, year:integer, price:integer) -Suppliers (sid:integer, sname: string, state:string, zipcode:string) -Orders (pid:integer, sid:integer, quantity:integer) The description is as follows: a factory keeps a database with parts that it uses, the suppliers of those parts, and purchase orders. Each part is uniquely identified by pid. Each part has a string description pname, year of fabrication and price per unit. Parts are provided by suppliers, and each supplier is uniquely identified by sid....

  • EXERCISE 1 (SQL Queries) Consider the following schema: SUPPLIERS (SID : integer, SNAME : string, CITY...

    EXERCISE 1 (SQL Queries) Consider the following schema: SUPPLIERS (SID : integer, SNAME : string, CITY : string) PARTS (PID : integer, PNAME : string, COLOR : string) CATALOG (SID : integer, PID : integer, COST : real) The key fields are underlined, and the domain of each field is listed after the field name. Thus, SID is the key for SUPPLIERS, PID is the key for PARTS, and SID and PID together form the key for CATALOG. The CATALOG...

  • 10- Specify the following queries in SQL on the database schema of Figure 2. a. Retrieve...

    10- Specify the following queries in SQL on the database schema of Figure 2. a. Retrieve the names of all senior students majoring in ‘CS’ (Computer Science). b. Retrieve the names of all courses taught by Professor King in 2004 and 2005. c. For each section taught by Professor King, retrieve the course number, semester, year, and number of students who took the section. d. Retrieve the name and transcript of each senior student (Class =4) majoring in CS. A...

  • Please HELP, THANK YOU SO MUCH Consider the below schema of the university database (keys are...

    Please HELP, THANK YOU SO MUCH Consider the below schema of the university database (keys are in bold and underline) Part(pid: string, pname: string, description: string, color: string) Department(did: string, dnamestring, address: string) Supplier(sid string,.sname:string, address:string) Order(did:string. sid string pidstring, time:string, quantityreal, pricereal) The key fields are underlined, and the domain of each field is listed after the field name. Thus pid is the key for Part, did is the key for Department, sid is the key for Supplier, and...

  • 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 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...

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