Assignment 4 - SQL

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment 4

Database Schema:
Products Table: product_id (Primary Key), product_name, weight, category.

Vendors Table: vendor_id (Primary Key), vendor_name, contact_person, contact_number.

Warehouses Table: warehouse_id (Primary Key), location, capacity.

Shipments Table: shipment_id (Primary Key), product_id (Foreign Key to Products Table), vendor_id (Foreign
Key to Vendors Table), warehouse_id (Foreign Key to Warehouses Table), quantity, shipment_date.

Initial Setup:
Create a database named "LogisticsDB." Implement the above tables with appropriate data types and
relationships. Insert some sample data into each table.

Query 1: Products in Stock:


List all products along with their quantities currently in stock.
Query 2: Warehouse Capacity:
Find the warehouse with the maximum available capacity.
Query 3: Vendors and Products:
Retrieve a list of vendors and the products they supply.
Query 4: Shipment History:
Display the shipment history, including shipment_id, product_name, vendor_name, quantity,
and shipment_date.
Query 5: Low Stock Alert:
Identify products with a stock quantity below a specified threshold (e.g., 10) and need to be
restocked.
Query 6: Products by Category:
List products along with their categories, ordered by category.
Query 7: Warehouse Usage:
Calculate the percentage of warehouse capacity used by each warehouse.
Query 8: Vendor Contact Information:
Display the contact information for vendors, including vendor_name, contact_person, and
contact_number.
Query 9: Monthly Shipment Statistics:
Calculate and display the total quantity of products shipped each month for the last six
months.

You might also like