0% found this document useful (0 votes)
138 views

Company Database - Questions - Updated

The document provides the schema and data for a furniture company database including tables for customers, orders, order lines, products, and suppliers. It also includes exercises to: 1) Create the tables and add constraints 2) Perform basic queries using aggregation, grouping, and joins 3) Develop an application to manage orders and supplies using JDBC 4) Design an entity relationship diagram and create the database 5) Write PL/SQL programs using triggers and cursors

Uploaded by

mathu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views

Company Database - Questions - Updated

The document provides the schema and data for a furniture company database including tables for customers, orders, order lines, products, and suppliers. It also includes exercises to: 1) Create the tables and add constraints 2) Perform basic queries using aggregation, grouping, and joins 3) Develop an application to manage orders and supplies using JDBC 4) Design an entity relationship diagram and create the database 5) Write PL/SQL programs using triggers and cursors

Uploaded by

mathu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FURNITURE COMPANY DATABASE

SCHEMA

Customer(customer_id,customer_name,customer_address,city,state,pstal_code);

Order(order_id,order_date,customer_id);

Orderline(order_id,product_id, ordered_quantity); (Price – will be added later)

Product (product_id,product_description, product_finish, product_line_id);

Supplier(s_id, s_name, gender, s_date, p_id, quantity, rating)

(Primary key attributes are underlined)

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

S1,’aaa’,’M’ '11-NOV-14' 1000, 5, 1;


S2, ‘bbb; ‘F’,'01-NOV-14', 2000, 7, 2;
S2, ‘bbb; ‘F’,'01-NOV-14', 2001, 10, 2;
S3, ‘ccc’ ‘M’'20-OCT-14', 9999, 10, 3;
S4, 'ddd’, ‘F’‘05-NOV-14', 4001, 5, 4;
S4, 'ddd’, ‘F’‘05-NOV-14', 4000, 3, 4;
S5, ‘eee’,’M’, '13-NOV-14', 1001, 10, 5;

1. FUNDAMENTAL QUERY LANGUAGE


 Create the table using DDL
 Maning the table using DML
 Authorization using DCL
 Transaction Control using TCL
Lab Exercises
1. Create the above tables, with primary key constraints
2. Add foreign key reference to the customer_id attribute.
Ans: alter table orders add foreign key(customer_id) references customer(customer_id);
3. Modify the attribute product_finish in the product table to product_material
Ans: alter table product rename column prod_finish to prod_material;
4. Add an attribute called price in the Orderline table
Ans: alter table orderline add price number(8,2);
5. Add a check constraint to ordered_quantity column and check that quantity is above 5
Ans: alter table orderline add constraint qtychk check(order_quantity>3);
6. Rename orderline to orderquantity
Ans: alter table orderline rename to orderquantity;
7. Insert the above values in to the corresponding table.
8. Update the pstal_code of 'Mary Smith', to ‘10032'
Ans: update customer set postal_code='10032' where cust_name='Mary Smith';

9. Store the data permanently in stable storage


2
10. Insert the record (108, '10-NOV-14', 1) into Order table
Ans: Insert into orders values(‘108’,’10-Nov-2014’,’1’);
11. Delete the record from Order where order_id =’104’
Ans: delete from orders where order_id=’104’;
12. Undo the delete operation
Ans: rollback;
13. Display the details of Product whose price is >100.
Ans: select product.prod_id, product.prod_desc, product.prod_material,
product.prod_line_id from product, orderquantity where
product.prod_id=orderquantity.prod_id
and orderquantity.price>100;
14. Grant select privilege to user1 on Order table
Ans: grant select on orders to user1;
15. Try to insert values into Order table from user1 and state what happens

2. BASIC SQL

 Aggregate functions
 Group by and order by clause
 Built in functions

Lab Exercises

1. How many orders are placed by John Doe?


Ans: select count(order_id) from orders where customer_id=(select customer_id from
customer where cust_name='John Doe');
2. What is the maximum quantity that has been ordered?
Ans: select max(order_quantity) from orderquantity;
3. Display the details of the customer who ordered the product whose price is the minimum
among all the products.
Ans: SQL> select * from customer where customer_id=(select customer_id from orders
where order_id=( select order_id from orderquantity where price=(select min(price)
from orderquantity)));
4. Display the average price of each product.
Ans: select avg(price) from orderquantity;
5. Find the total quantity ordered for each product.
Ans: select prod_id,sum(order_quantity) as total_orders from orderquantity group
by prod_id;
6. Find out the no. of orders placed on each date.
7. Find out how many products are ordered in each order.
Ans: select order_id,count(prod_id) from orderquantity group by order_id order b
y order_id;

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. Display the product that was ordered and delivered (Union)


2. Display the details of the product that are yet to be delivered. (Minus)
3. List the name of the customers who has placed an order after 10th OCT 2014.
4. Display the details of the product that are delivered within 10 days.
5. Display details of the customer who has received their ordered product.
6. Display the details of the product whose quantity is greater than 10
7. Display the details of order_id with Order_date and customer_name. (inner join)
8. Display the details of all the products that have been ordered and also the details of
delivered product. (use left outer join)
9. Display the details of all customers as well as the order details. (full outer join)
10. Display the details of the supplier who has supplied ‘Office Desk’

4. DATABASE DESIGN AND CREATION


 ER Diagram
 Database Creation

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

2. Create a company database for the above Schema

5. APPLICATION DEVELOPMENT USING JDBC CONNECTIVITY

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

6.SUBQUERY AND CORELATED SUBQUERY

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.

9. CREATION OF OTHER DATABASE OBJECTS


 Views
 Index
 Sequence

Lab Exercises

1. Create a view(V1) to display the customer name, order id and quantity.


2. Create a view(V2) to display the order-id, order-date and the date of delivery.
3. Create a view (V3) with customer name, order id and order date from V1 and V2.

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

10. ORACLE FORMS AND REPORT GENERATION

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

11. WEB APPLICATION DEVELOPMENT USING PHP AND MYSQL

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

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