Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 Create database and DB objects based on the below ER Diagram Create a database called Orders. Create DDL scripts for the database objects

Part 1 Create database and DB objects based on the below ER Diagram
Create a database called Orders. Create DDL scripts for the database objects and enforce referential integrity and PK . Show the CREATE TABLE statements with the modifications including the constraints given in step 2
Add the following constraints:
tblCustomers table: Country default to Canada
tblOrderDetails: Quantity >0
tblShippers: CompanyName must be unique.
tblOrders: ShippedDate must be greater than order date.
3. Run the script provided to populate the data on the table (InsertScript.sql)
Part 2 Create the Following SQL Statements
1. Show a list of customers and the orders they generated during 2014. Display customer ID, order ID, order date and date ordered.
2. Using the ALTER TABLE statement, add a new field (Active) in the tblcustomer. Default it to True.
3. Show all orders purchased before September 1,2012. Display company name, date ordered and total amount of order (include freight).
4. Show all orders that have been shipped via Federal Shipping. Display OrderID, ShipName, ShipAddress and CustomerID.
5. Show all customers who have not made purchases in 2011.
6. Show all products that have never been ordered.
7. Show OrderIDs for customers who reside in London. Use a subquery. Display CustomerID, CustomerName and OrderID.
8. Show products supplied by Supplier A and Supplier B. Display product name and supplier name.
9. Show all products that come in boxes. Display product name and QuantityPerUnit.
Part 3 Insert, Update, Delete, Indexes
1. Create an Employee table. The primary key should be EmployeeID (autonumber). Add the following fields: LastName, FirstName, Address, City, Province, Postalcode, Phone, Salary. Show the CREATE TABLE statement and the INSERT statements for the five employees. Join the employee table to the tblOrders. Show the script for creating the table, setting constraints and adding employees.
2. Add a field to tblOrders called TotalSales. Show DDL ALTER TABLE statement.
Using the UPDATE statement, add the total sale for each order based on the order details table.
9. add additional column in tblCustomer called LatestCustomerOrderQuantity
10. update LatestCustomerOrderQuantity with the quanitity of all the products in lastest customer order
11. add adtional column in TbleCustomer called TotalAmountofOrders
12. update TotalAmountofOrders with the total amount the customer spent on all the orders he/she made ,you may not need to include the shipping cost
13. find the details of the most recent order by the customer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

In what ways can confl ict enrich relationships?

Answered: 1 week ago

Question

How do listening and hearing diff er?

Answered: 1 week ago

Question

How does eff ective listening diff er across listening goals?

Answered: 1 week ago