Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 4 Answer (a), (b) and (c) Consider the following relational schema for a company: CUSTOMER (CustomerID, CustomerName, CustomerAddress, CustomerCity, CustomerState, CustomerPostalCode) ORDER (OrderID, OrderDate,

QUESTION 4 Answer (a), (b) and (c) Consider the following relational schema for a company: CUSTOMER (CustomerID, CustomerName, CustomerAddress, CustomerCity, CustomerState, CustomerPostalCode) ORDER (OrderID, OrderDate, CustomerID) ORDER-LINE (OrderID, ProductID, OrderedQuantity) PRODUCT (ProductID, ProductDescription, ProductFinish, ProductStandardPrice) The key attributes for the relations shown above are underlined, and other important attributes are included in each relation. The primary key for ORDER-LINE is a composite key consisting of the attributes OrderID and ProductID. Also, CustomerID is a foreign key in the ORDER relation. ORDER-LINE has two foreign keys: OrderID and ProductID. Write SQL queries to answer the following: (a) Write statements to create all the tables from relational schema described above. Select appropriate data types for each attribute. Remember to set the primary and foreign keys. (16 marks) (b) Write a query to list all orders (order id and its date) submitted by a customer with id cus0019 since 1st of December 2016. (4 marks) (c) List the total ordered quantity of all orders by each customer while considering only the customers who ordered more than 65.

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions