Company Database - Questions - Updated
Company Database - Questions - Updated
SCHEMA
Customer(customer_id,customer_name,customer_address,city,state,pstal_code);
Order(order_id,order_date,customer_id);
DATA SET
Customer
1, 'John Doe', '392 Sunset Blvd.', 'New York', 'NT','10059'
2, 'Mary Smith', '6900 Main St.', 'San Francisco', 'CA','94032'
3, 'Richard Newman', '2040 Riverside Rd.', 'San Diego', 'CA','92010'
4, 'Cathy Cook', '4010 Speedway', 'Tucson', 'AZ','85719'
Order
100, '01-OCT-14', 1
101, '01-OCT-14', 2
102, '02-OCT-14', 3
103, '03-OCT-14', 2
104, '10-OCT-14', 1;
105, '10-OCT-14', 4;
106, '10-OCT-14', 2;
107, '10-OCT-14', 1
Orderline
100, 4000, 10, 10000;
101, 1000, 20, 15000;
101, 2000, 20, 20000;
102, 3000, 15, 23500;
102, 2000, 12, 34560;
103, 4001, 14, 1000;
104, 2000, 10, 2000;
105, 3001, 20, 30005;
106, 3000, 12, 20500;
106, 4000, 11, 30000;
107, 4001, 5, 40100;
1
Product
1000, 'Office Desk', 'Cherry', 95.0, 10;
1001, 'Manager''s Desk', 'Red Oak', 199.0, 10;
2000, 'Office Chair', 'Cherry', 75.0, 20;
2001, 'Manager''s Desk', 'Natural Oak', 129.0, 20;
3000, 'Book Shelf', 'Natural Ash', 35.0, 30;
3001, 'Duplex Book Shelf', 'White Ash', 80.0, 30;
4000, 'Table Lamp', 'Natural Ash', 15.0, 40;
4001, 'Duplex Table Lamp', 'White Ash', 40.0, 40;
1000, 'Keyboard', 'Plastic', 20.0, 50;
Supplier
2. BASIC SQL
Aggregate functions
Group by and order by clause
Built in functions
Lab Exercises
3
8. Sort the order table based on the order date.
select * from orders order by order_date;
9. Display the products for which more than 3 quantity are orders and sort the result on the
sum of quantity ordered.
10. Display the order_id in descending order of the ordered quantity.
Ans: select order_id from orderquantity order by order_id desc;
11. Display the names of all customers in uppercase.
Ans: select upper(cust_name) from customer;
12. Find the number of months between ordered date of order_id=103 and current date
13. Prefix the postal code with two zeroes
14. Display the substring “Newman” from “Richard Newman”.
15. Display the name of the customer ends with ‘e’
3. ADVANCED SQL
Set Operations
Joins
Lab Exercises
1. Do the database design for the “Furniture Company” using ER model to hold information
relating to Customers Ordering Products. The draft facts have been defined as follows:
The Entities required should include:
Customers
Orders
OrderLines
Products
4
Suppliers
The Entities are related as follows:
An Customer can have One or Many Orders
An Order can contain One or Many Products (OrderLines)
A Product can be associated with One or Many Orders
A Supplier can supply One or Many Products
Develop an application for a company to manage its order and supply details using JDBC
connectivity and do the following:
Have a menu with the following option and perform the following operations.
Insert new order
Modify the order details
Delete a record from order table
Search the supply details based on product id
Lab Exercises
1. Find the names of customers who have ordered for a ‘cherry’ or ‘ red oak’ finish.
2. Find the names of customers who have ordered for the product “Table Lamp”. (use IN)
3. Find the details of customers who have ordered for product id 1000. (use EXISTS)
4. Find suppliers whose total supply quantity is greater than some supplier called S3. (use
ANY)
5. Find the supplier with the highest rating using ALL.
6. Display the products that are same as the product ordered by “Cathy Cook”
7. Display the supplier details whose supplied quantity is greater than the quantity of order
id – 103
8. Display the ordered quantity of the order whose ordered date is greater than the ordered
date of the order id 106
7. PL/SQL PROGRAMMING - I
Triggers
Cursors
Lab Exercises
5
1. Create a Simple Trigger that does not allow Insert, Update and Delete Operations on the
Supplier Table
2. Create a Trigger that raises an User Defined Error Message and does not allow updating
the order table.
3. Write a PL/SQL script to display the supplier details whose has rating greater than 3 (use
Cursors)
4. Write a PL/SQL script to display the product names whose ordered quantity is >10 using
Cursors.
5. Create a trigger to warn when the supplied quantity is greater than ordered quantity.
6. Write a trigger to update the order table whenever the customer id is updated in the
customer table.
8 PL/SQL PROGRAMMING - II
Functions
Procedures
Lab Exercises
1. Write a PL/SQL procedure that will accept the product id from the user, check if the
product is supplied by the supplier and display the status.
2. Write a procedure to calculate total price for the product that has been supplied and
Pass the supplier id as the argument.
3. Write a procedure raise_quantity which increases the quantity of the ordered product.
It accepts an order id and quantity to be increased. It uses the order id to find the
current quantity from the ORDER table and update the quantity.
4. Write a PL/SQL function STATUS to return value SUPPLIED if the product number
passed to it is available in the Supplier table else will return NOT SUPPLIED
5. Write a PL/SQL function to return the product name when the product id is passed as
an argument.
6. Write a PL/SQL function to return the maximum quantity ordered by the customers.
Lab Exercises
6
4. Insert a row into the above view. Is the view updatable? If yes, is the updation
reflected in the base table.
5. Delete a row from the above view and state what happens to the other views from
which it was created.
6. Create a bit map index on the gender field of the supplier table.
7. Create a B tree index on the quantity attribute of the Orderline table and evaluate the
performance
8. Create a sequence in the order-id of the order table
Create the following reports for furniture compary with Oracle SQL * plus
Report on customer details
Daily report on order details
Weekly report on order details
Monthly report on order details
Report on supplier details
Develop an creative and innovative mini project on the following web-based application
using PHP and MySQL
Hotel Room Booking
Car Booking System
Inventory Control for Furniture Company
Airline Information System
Library Management
Taining Institute Course Management