Question

CUSTTYPE (TID, TypeDesc) CUSTOMER (CID, Lname, Fname, TID, Address, ZIPcode) CUSTORDER (OrderNo, OrderDate, PromiseDate, ShippedDate, ShippingTerm,...

CUSTTYPE (TID, TypeDesc)

CUSTOMER (CID, Lname, Fname, TID, Address, ZIPcode)

CUSTORDER (OrderNo, OrderDate, PromiseDate, ShippedDate, ShippingTerm, SalesID, CID)

SALESREP (SalesID, Name, Phone, Address, ZIPcode, RepType)

ORDERLINE (OrderNo, PID, Qty, Qty_RETD)

FTSALESREP (SalesID, MonthPay, Rank)

PTSALESREP (SalesID, HourlyRate, WeekHours)

ZIP_TABLE (ZIPcode, City, State)

VENDOR (VID, Name, Phone ZIPcode)

PRODUCT (PID, CateID, ProdName, ProdFinish, Price, Qty_on_Hand, Description, VID)

CATEGORY (CateID, CateType)

Local View #1: Use three base tables to develop a SQL statement that will list the following information for a customer, and label this query Customer_Info. CID, Lname, Fname, TypeDesc, Address, City, State, ZIPcode

Local View #2: Use two tables to develop a SQL statement that will list the following information for a SalesRep, and label this query SalesRep_Info. SalesID, Name, RepType, Phone, Address, City, State, ZIPcode B.

Question #1: Use the above two “Access SQL Statements (i.e., Views)” to develop an SQL statement that will list SalesID, Name, and Phone of each sales representative and his/her potential customers’ CID, Fname, Lname, and TypeDesc of those customers who live in the same state. Order your query results in an alphabetical order of the name of sales representative. (Hint: Use Left Join and Order By to complete this inquiry, and save your SQL statement under the name Query 1)

Question #2: Write an SQL to list SalesID, Name, and Phone who have handled at least one Customer Order [Hint: Use EXISTS in a correlated SQL. Save your SQL statement under the name Query 2]

Question #3: Write an SQL to list the PID, ProdName, ProdFinish, and Price for the Product that has the lowest price. [Hint: Use ALL operator in your nested SQL statement. Save your SQL statement under the name Query 3]

Question #4: Write an SQL to list PID, ProdName, and average of Qty sold when each product was ordered, if any, by the customer orders. [Hint: Note you should list all products whether they have been ordered or not. Your intent is to do some sales analysis that will indicate how each product is ordered by customer orders. To show your knowledge in developing SQL statements, for this query you are required to use a Right Join, and you will need a Group By and AVG aggregate function. Save your SQL statement under the name Query 4]

Question #5: Write an SQL to list SalesID, Name, Phone, RepType, the Annual Pay for all sales reps who are either a full time or a part time [Hint: You need to use the UNION operator to retrieve data from SalesRep joining with either FTSalesRep or PTSalesRep. The Annual Pay is calculated by MonthPay*12 for full-time sales rep and HourlyRate * WeekHours*52 for part-time sales rep. Save your SQL statement under the name Query 5]

Question #6: Develop an SQL that will list VID, Name, and State for all Vendors who live in either Wisconsin or Michigan and have not supplied any product at this moment [Hint: You need to use the remote view Vendor_Info to simplify your SQL statement. Also, you may to use IN operator to check against a list of ‘WI’ and ‘MI’ to simplify your query syntax. To prove your knowledge in SQL syntax, you are required to use NOT EXISTS to complete this inquiry. Save your SQL statement under the name Query 6] 9

Bonus Question #7: Develop an SQL that will list PID, ProdName, Price, CateType, and the current balance of inventory quantity for each product in the store. [Hint: You are recommended to use the view Product_Info to join with Orderline to complete this query. Note that the view uses Qty as the value for quantity on hands, and the same term Qty is used in Orderline. You need to use alias as way to calculate the balance (i.e., pr.Qty – SUM(od.Qty), assuming that you use pr as the alias for Product_Info and od for Orderline. In this query, you may find out that some products are in shortage of customer demands. Save your SQL statement under the name Query 7]

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

PLEASE LIKE THE SOLUTION

FEEL FREE TO DISCUSS IN COMMENT SECTION

Add a comment
Know the answer?
Add Answer to:
CUSTTYPE (TID, TypeDesc) CUSTOMER (CID, Lname, Fname, TID, Address, ZIPcode) CUSTORDER (OrderNo, OrderDate, PromiseDate, ShippedDate, ShippingTerm,...
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
  • I need this written in SQL Employee EMP ID EMP FNAME EMP LNAME EMP STREET EMP...

    I need this written in SQL Employee EMP ID EMP FNAME EMP LNAME EMP STREET EMP CITY EMP STATE EMP ZIP EMP START DATE Table TABLE ID AREA IDTABLE SEATS Area AREA ID AREA NAME AREA SUPERVISOR EMPLOYEE ID Customer CUST ID CUST LAST NAME CUST NUMBER OF GUESTS Assignment EMPID TABLE ID Seating CUST IDTABLE ID SEATING COST SEATING DATE SEATING TIP Question 29 (10 points) Write an SQL query to list the employee ID and first and last...

  • For the below `bank' schema: customer(customerid,username,fname,lname,street1,street2,city,state,zip) account(accountid,customerid,description,) transaction(transactionid,trantimestamp,accountid,amount) A customer may have several accounts, and each...

    For the below `bank' schema: customer(customerid,username,fname,lname,street1,street2,city,state,zip) account(accountid,customerid,description,) transaction(transactionid,trantimestamp,accountid,amount) A customer may have several accounts, and each account may participate in many transactions. Each transaction will have at least two records, one deducting amount from an account, and one adding amount to an account (for a single transactionid, the sum of amounts will equal zero). Using SQL, answer these questions (write a SQL query that answers these questions): 8) List the top 1% of customers (ordered by total balance). 9) Using...

  • Employee        (empID, fName, lName, address, DOB, sex, position, deptNo)             Department     (deptNo, deptName, mgrEmpID)   

    Employee        (empID, fName, lName, address, DOB, sex, position, deptNo)             Department     (deptNo, deptName, mgrEmpID)             Project            (projNo, projName, deptNo)             WorksOn         (empID, projNo, hoursWorked)             where Employee        contains employee details and empID is the key.                         Department     contains department details and deptNo is the key. mgrEmpID identifies the employee who is the manager of the department. There is only one manager for each department.                         Project            contains details of the projects in each department and the...

  • Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor...

    Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor (did: integer, lname: string, fname: string, deptid: integer, age: integer, salary: integer) Nurse (nid: integer, lname: string, fname: string, deptid: integer, rank: string, age: integer) Department (deptid: integer, name: string, budget: integer) Menu (menuid: integer, pid: integer, caloriecount: integer, saltlevel: integer, vegetarian: bit, diabetic: bit, nauseaSafe: bit, notes: string) Vaccination (vaccinationid: integer, pid: integer, vaccinationname: string, dategiven: date, dateexpires: date) Prescription (presid: integer, pid:integer,...

  • Create three or more MySQL Data Control language (DCL) Statements using the Youth League Database. 1....

    Create three or more MySQL Data Control language (DCL) Statements using the Youth League Database. 1. A Create new user statement for the database 2. A statement that grants privileges to the new user 3. A statement that revokes privileges 1. A SQL Text File containing the SQL commands to create the database, create the table, and insert the sample test data into the table. 2. A SQL Text File containing the DCL SQL Statements. eted hemas Untitled Limit to...

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

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

  • Q1: The following question are based on these database tables: EMPLOYEE FNAME MIDINT LNAME SSN BDATE ADDRESS SEX SALARY SUPER_SSN Dept_No James A Borg 123123123 Hous...

    Q1: The following question are based on these database tables: EMPLOYEE FNAME MIDINT LNAME SSN BDATE ADDRESS SEX SALARY SUPER_SSN Dept_No James A Borg 123123123 Houston, TX M 55000 Null 1 Franklin S Wong 234234234 Houston, TX M 40000 123123123 5 John Q Smith 345345345 Houston, TX M 30000 234234234 5 Jennifer L Wallace 456456456 Bellaire, TX F 43000 123123123 4 Alicia M Zalaya 567567567 Spring, TX F 25000 456456456 4 Ramesh R Narayan 678678678 Humble, TX M 38000 234234234...

  • CellTell, a cellular phone service provider, offers cell phone service contracts to their customers. They have an information system that stores the details about these contracts, selected plans, phones, and accessories

    ERD and Schema for the model is:CUSTOMER ( ID, Lname, Fname, Street, City, ZipCode, State, Phone, CreditScore, Credit_Org, CS_Date)PLAN ( Plan_ID, Start_Date, End_Date, BasePrice, Plan_Type)VOICE ( vPlan_ID@, NumMin, HasVoiceMail, HasThreeWay, OverageFee)TEXT ( tPlan_ID@, TextLimit, HasMMS, MmsOverage, TextOverage)DATA ( dPlan_ID@, DataLimit, NetworkTechnology, OverageFee)CONTRACT ( Contract_ID, Customer_ID@, vPlan_ID@, tPlan_ID@, dPlan_ID@, Start_Date, End_Date, DiscountPerc)MANUFACTURER ( Manuf_ID, Manuf_Name, Contact_Lname, Contact_Fname, Contact_Phone, Contact_Email)PRODUCT ( Product_ID, Name, Manuf_ID@, CostPaid, BasePrice, Type)CELLPHONE ( Phone_ID@, Model, NetworkTechnology, OS)ACCESSORY ( Access_ID@, Category)PHONE_ACCESS ( Phone_ID@, Access_ID@)CONTRACT_CELLPHONE ( Contract_ID@, Phone_ID@, Seq#, PaidPrice, ESN)1. CellTell would like to add website information about the manufacturers of products they sell. Add a new column named “Website” to the manufacturer table. Then,...

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