Implement the query find total number of orders submitted

Assignment Help Database Management System
Reference no: EM13886080

Task

Indexing

A user CSCI315 used the following CREATE TABLE statements to create a sample database.

CREATE TABLE ORDERS(
O_ID NUMERIC(10) NOT NULL, /* Unique ID of order */
O_C_ID NUMERIC(10) NOT NULL, /* Customer ID */
O_DATE TIMESTAMP NOT NULL, /* Order date an time */
O_TOTAL NUMERIC(15,2) NOT NULL, /* Total for this order */
CONSTRAINT ORDERS_PKEY PRIMARY KEY (O_ID) );

CREATE TABLE ORDER_LINE(
OL_O_ID NUMERIC(10) NOT NULL, /* Order ID */
OL_ITEM NUMERIC(10) NOT NULL, /* Item name */
OL_QTY NUMERIC(3) NOT NULL, /* Quantity of item */
CONSTRAINT ORDER_LINE_PKEY PRIMARY KEY (OL_O_ID, OL_ITEM),
CONSTRAINT ORDER_LINE_FKEY2 FOREIGN KEY (OL_O_ID)
REFERENCES ORDERS(O_ID) );

(1) Write SELECT statements that implement the following queries.

(i) Find the total number of orders submitted in 2015.

(ii) List all distinct customer IDs (O_C_ID) who submitted the largest number of orders in 2014.

(iii) Find the total number if orders submitted by each customer.

(iv) Find the distinct names of items (OL_ITEM) included in at least one order.

(v) Find the total number of values in a column OL_ITEM.

(vi) Find a name of item ordered with the largest quantity.

(vii) Find the total number of rows in a relational table ORDERS.

(viii) Find the total (O_TOTAL) of all orders in each year.

(2) Write smallest number of CREATE INDEX statement such that each one of the queries listed above is processed through "index-only" computations. It means the indexes must be created in such a way such that there is no need to access the relational tables listed above to find the results of queries and the indexes must be "shared" by the possibly largest number of queries.

Reference no: EM13886080

Questions Cloud

Details of balances or analytical procedures : The following are common tests of details of balances or analytical procedures for the audit of accounts receivable:
Define quality in terms of what it means for a product : Define quality in terms of what it means for a product to have high quality.
Analyze the three internal governance mechanisms : Analyze the three internal governance mechanisms (ownership concentration, boards of directors, and executive compensation) and recommend a possible fourth mechanism that would help align the interests of managerial agents with those of the firm's ow..
Estimate the drag on the tree : A blue spruce pine tree has the shape of a triangle which is 15 cm off the ground. The triangle has a maximum diameter of 6 m and is 10 m tall. Estimate the drag on the tree if it is exposed to a 25 m=s wind. Use CD ¼ 0.4 in your calculations.
Implement the query find total number of orders submitted : Find the total number of orders submitted in 2015. List all distinct customer IDs (O_C_ID) who submitted the largest number of orders in 2014. Find the total number if orders submitted by each customer.
How a company looks at a failed goal is critical as well : Miscommunication between different departments, management and employees can make it difficult to reach. How a company looks at a failed goal is critical as well. So the question is, what happens if the goal is not met
How fast will the rider travel : A bike rider expends a certain amount of energy to travel 12 m=s while in the upright position. How fast will the rider travel with the same amount of energy expenditure if the bent over position is elected? Assume the rider's projected area is re..
How is pluralism different from relativism? : How is Pluralism Different from Relativism?
Tim is currently planning tests of details : 1.Tim Flynn is the engagement manager for the audit of ODonnell Enterprises.

Reviews

Write a Review

Database Management System Questions & Answers

  Knowledge and data warehousing

Design a dimensional model for analysing Purchases for Adventure Works Cycles and implement it as cubes using SQL Server Analysis Services. The AdventureWorks OLTP sample database is the data source for you BI analysis.

  Design a database schema

Design a Database schema

  Entity-relationship diagram

Create an entity-relationship diagram and design accompanying table layout using sound relational modeling practices and concepts.

  Implement a database of courses and students for a school

Implement a database of courses and students for a school.

  Prepare the e-r diagram for the movie database

Energy in the home, personal energy use and home energy efficiency and Efficient use of ‘waste' heat and renewable heat sources

  Design relation schemas for the entire database

Design relation schemas for the entire database.

  Prepare the relational schema for database

Prepare the relational schema for database

  Data modeling and normalization

Data Modeling and Normalization

  Use cases perform a requirements analysis for the case study

Use Cases Perform a requirements analysis for the Case Study

  Knowledge and data warehousing

Knowledge and Data Warehousing

  Stack and queue data structure

Identify and explain the differences between a stack and a queue data structure

  Practice on topic of normalization

Practice on topic of Normalization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd