0% found this document useful (0 votes)
558 views1 page

Lab 5

The document provides the SQL commands to create a database with 5 tables (CUSTOMER, SHIPMENT, TRUCK, CITY, POPULATION) including primary and foreign keys and constraints. It then lists 11 queries to perform on the populated database including finding city names and populations for shipments over 100 pounds, drivers for high revenue customers to large cities, and using views to filter customers by revenue for additional queries.

Uploaded by

Richa Joshi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
558 views1 page

Lab 5

The document provides the SQL commands to create a database with 5 tables (CUSTOMER, SHIPMENT, TRUCK, CITY, POPULATION) including primary and foreign keys and constraints. It then lists 11 queries to perform on the populated database including finding city names and populations for shipments over 100 pounds, drivers for high revenue customers to large cities, and using views to filter customers by revenue for additional queries.

Uploaded by

Richa Joshi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Write the SQL commands to create a database for the following relational schema with given

constraints:

CUSTOMER (CUST_ID, CUST_NAME, ANNUAL_REVENUE, CUST_TYPE)


CUST_ID must be between 100 and 10,000
ANNUAL_REVENUE defaults to $20,000
CUST_TYPE must be manufacturer, wholesaler, or retailer

SHIPMENT (SHIPMENT_#, CUST_ID, WEIGHT, TRUCK_#, DESTINATION,


SHIP_DATE)
Foreign Key: CUST_ID REFERENCES CUSTOMER
Foreign Key: TRUCK_# REFERENCES TRUCK, on deletion set to null
Foreign Key: DESTINATION REFERENCES CITY, on deletion set to null
WEIGHT must be under 1000 and defaults to 10

TRUCK (TRUCK_#, DRIVER_NAME)

CITY (CITY_NAME, POPULATION)

Populate it with some data and perform the following queries:

1. What are the names and populations of cities that have received shipments weighing over 100
pounds?
2. Who are the drivers who have delivered shipments for customers with annual revenue over
$20 million to cities with populations over 1 million?
3. List the cities that have received shipments from customers having over $15 million in annual
revenue.
4. List the names of drivers who have delivered shipments weighing over 100 pounds.
5. List the name and annual revenue of customers who have sent shipments weighing over 100
pounds.
6. List customers who had shipments delivered by every truck.
7. List cities that have received shipments from every customer.
8. List drivers who have delivered shipments to every city.
9. Customers with annual revenue over $10 million which have sent packages under 1 pound to
cities with population less than 10,000.
10. Create views for each of the following:
a. Customers with annual revenue under $1 million.
b. Customers with annual revenue between $1 million and $5 million.
c. Customers with annual revenue over $5 million.
11. Use these views to answer the following queries:
a. Which drivers have taken shipments to Delhi for customers with revenue over $5 million?
b. What are the populations of cities which have received shipments from customers with
revenue between $1 million and $5 million?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy