0% found this document useful (0 votes)
75 views5 pages

DBMS (Practical) BETN1CS18084

The document describes an internal viva activity for a student involving an order processing database application. It includes: 1) Relations for the database schema including customer, orders, order items, items, shipments, and warehouses tables with attributes and primary/foreign keys specified. 2) A question asking to create the tables which the student answers by writing the proper SQL commands. 3) A question asking to insert sample data into the relations, which the student provides SQL insert statements as an answer. 4) A question asking to list customer name, number of orders, and average order amount for each customer, which the student answers with the correct SQL join and aggregate functions.
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)
75 views5 pages

DBMS (Practical) BETN1CS18084

The document describes an internal viva activity for a student involving an order processing database application. It includes: 1) Relations for the database schema including customer, orders, order items, items, shipments, and warehouses tables with attributes and primary/foreign keys specified. 2) A question asking to create the tables which the student answers by writing the proper SQL commands. 3) A question asking to insert sample data into the relations, which the student provides SQL insert statements as an answer. 4) A question asking to list customer name, number of orders, and average order amount for each customer, which the student answers with the correct SQL join and aggregate functions.
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/ 5

ITM UNIVERSITY GWALIOR, (M.

P)

INTERNAL VIVA ACTIVITY

NAME – S.M. Nahinul Hossain


ROLL NO. – BETN1CS18084
Set : F
SUBMITTED TO – Dr. Deepak Motwani
DATE : 24.04.2020
PRACTICAL :

consider the following relations for an order processing


database application in a company.
CUSTOMER (Cust #: int, Cname: string, City: string)
ORDER (Order #: int, Odate: date, Cust #: int, Ord-Amt: int)
ORDER-ITEM (Order #: int, Item #: int, qty: int)
ITEM (Item #: int, Unit Price: int)
SHIPMENT (Order #: int, Ware
house #: int, Ship-Date: date)
WAREHOUSE (Warehouse #: int, City: string)
Q1. Create the above tables by properly specifying the primary
keys and the foreign keys.
Ans.
1 SQL> create table customer(Cust# number(10) primary key,
Cname varchar2(10), City
varchar2(10));
2 SQL> create table Orders(Order# number(10) primary key,
Odate Date, Cust#
number(10), Order_Amt number(10));
3 SQL> Alter table orders add constraint fk_cust foreign
key(Cust#) references
customer(Cust#);
4 SQL> create table Order_item(Order# number(10), Item#
number(10) primary key, qty
number(10));
5 SQL> Alter table Order_item Add Constraint fk_order foreign
key(Order#) references
Orders(Order#);
6 SQL> Create table Item(Item# number(10), Unit_price
number(10));
7 SQL> Alter Table Item Add Constraint fk_Item foreign
key(Item#) references
Order_item(Item#);
8 SQL> Create Table Shipment(Order# number(10),
Warehouse# number(10) Primary
Key, Ship_date Date);
9 SQL> Alter table Shipment Add constraint fk_odr Foreign
key(Order#) references
orders(Order#);
10 SQL> Create Table Warehouse(Warehouse# number(10),
city varchar2(10));
SQL> Alter table Warehouse add constraint fk_wrhs foreign
key(Warehouse#) references
Shipment(Warehouse#);

Q2. Enter at least five tuples for each relation.


Ans.
1 SQL> Insert into Customer values('&Cust', '&Cname', '&City');
2 SQL> Insert into Orders values(&Order,Date '&Odate', &Cust,
&Ord_amt);
3 SQL> Insert into Order_item values(&Order, &Item, &qty);
4 SQL> Insert into Item values(&Item, &Unit);
5 SQL> Insert into Shipment values(&Order, &Warehouse,
Date '&Ship_date');
6 SQL> Insert into Warehouse values(&Warehouse, '&City');

SHIPMENT

ORDER# WAREHOUSE# SHIPDATE


1 1 30-APR-06
2 2 29-APR-06
3 2 24-APR-06
4 5 30-APR-06
5 3 01-JUN-06
6 1 01-JUN-06

Q3. Produce a listing: CUSTNAME, NO_OF_ORDERS,


AVG_ORDER_AMT, where the middle column is the
total number of orders by the customer and the last column is
the average order amount for that customer.
CNAME COUNT(*) AVG
GHI 2 1750
MNO 1 10000
ABC 1 5000
DEF 1 5000.5
Ans.
1. select C.Cname, count(*) as NO_OF_ORDERS,
avg(O.Order_Amt) as
AVG_ORDER_AMT
2. from customer C, orders O
3. where (C.Cust# = O.Cust#) group by Cname;

You might also like