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

BCA Semester II CA 119 - Database Fundamentals Assignment-2: Getting Familiar With Basic SQL Syntax (DDL, DML Statements)

The document outlines the structure and data for several database tables: 1. It defines the structure of tables for clients, products, salespeople and sales orders with various data types and constraints. 2. Sample data is provided to insert into the client, product and salesperson tables. 3. The relationships between the tables are specified through foreign keys.

Uploaded by

harsh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

BCA Semester II CA 119 - Database Fundamentals Assignment-2: Getting Familiar With Basic SQL Syntax (DDL, DML Statements)

The document outlines the structure and data for several database tables: 1. It defines the structure of tables for clients, products, salespeople and sales orders with various data types and constraints. 2. Sample data is provided to insert into the client, product and salesperson tables. 3. The relationships between the tables are specified through foreign keys.

Uploaded by

harsh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

BCA Semester II

CA 119 – Database Fundamentals


Assignment-2

Getting familiar with basic SQL Syntax (DDL, DML Statements)


05/04/2022

1. Create following table which has following structure:

a. TABLE NAME: CLIENT_MASTER

Field Name Data Type Constraint


CLIENT_NO VARCHAR2(6) Primary Key /First letter must Start with ‘C’.
NAME VARCHAR2(20) Not null
ADDRESS1 VARCHAR2(30)
ADDRESS2 VARCHAR2 (30)
CITY VARCHAR2(15)
STATE VARCHAR2 (15)
PINCODE NUMBER(6)
BAL_DUE NUMBER(10,2)

a. TABLE NAME : PRODUCT_MASTER

Field Name Data Type Constraint


PRODUCT_NO varchar2(6) Primary key
Must start with P
DESCRIPTION VARCHAR2(14) NOT NULL
PROFIT_PERCENT NUMBER(4,2) NOT NULL
UNIT_MEASURE VARCHAR2(10) NOT NULL
QTY_ON_HAND NUMBER(8) NOT NULL
REORDER_LVL NUMBER(8) NOT NULL
SELL_PRICE NUMBER(8,2) NOT NULL,
Cannot be 0
COST_PRICE NUMBER(8,2) NOT NULL,
Cannot be 0

b. TABLE NAME : SALESMAN_MASTER

Field Name Data Type Null


SALESMAN_NO VARCHAR2(6) Primary Key / first
letter must start
With ‘S’
SALESMAN_NAME VARCHAR2(20) NOT NULL
ADDRESS1 VARCHAR2(30) NOT NULL
ADDRESS2 VARCHAR2(30)
CITY VARCHAR2(20)
PINCODE VARCHAR2(6)
STATE VARCHAR2(20)
SAL_AMT NUMBER(8,2) Not Null,cannot be
0
TGT_TO_GET NUMBER(6,2) Not Null,cannot be
0
YTD_SALES NUMBER(6,2) NOT NULL
REMARKS VARCHAR2(60)

Table Name :sales_order

Field Name Data Type Null


S_ORDER_NO VARCHAR2(6) Primary Key / first letter
must start
With ‘O’
S_ORDER_DATE DATE
CLIENT_NO VARCHAR2(6) Foreign Key references
client_no Of
client_master table
DELY_ADDR VARCHAR2(25)
SALESMAN_NO VARCHAR2(6) Foreign Key references
salesman_no Of
salesman_master
table.
DELY_TYPE CHAR(1) delivery :
part(P)/full(F),Default
‘F’
BILLED_YN CHAR(1)
DELY_DATE DATE cannot be less than
s_order_date
ORDER_STATUS VARCHAR2(10) values (‘In
Process’,’Fulfilled’,
‘BackOrder’,’Canceled’)

Perform Following Changes on Product_Master table

1) Change Datatype of Product_no field from number(2) to varchar2(6).


2) Assign primary key to product_no field
3) Add Constraint to product_no field (Must start with P)

Table Name : sales_order_details

Field Name Data Type Null


S_ORDER_NO VARCHAR2(6) Foreign Key references
S_order_no of sales_order table.
PRODUCT_NO VARCHAR2(6) Foreign Key references Product_no
of product_master table.

QTY_ORDERED NUMBER(8)
QTY_DISP NUMBER(8)
PRODUCT_RATE NUMBER(10,2)

Table Name :challan_header

Field Name Data Type Null


CHALLAN_NO VARCHAR2(6) Primary Key / first two
letters must Start with
‘CH’.
S_ORDER_NO VARCHAR2(6) Foreign Key
references s_order_no
of Sales_order table.
CHALLAN_DATE DATE NOT NULL
BILLED_YN CHAR(1) values(‘Y’,’N’),Default
‘N’.
Table Name :Challan_Details

Field Name Data Type Null


CHALLAN_NO VARCHAR2(6) Foreign Key references
Challan_no of
challan_header table.
PRODUCT_NO VARCHAR2(6) Foreign Key
references Product_no
of product_master
table.
QTY_DISP NUMBER(4,2) NOT NULL

2. . Insert following records in respective tables.

Table Name: CLIENT_MASTER

CLIENT NO. CLIENT NAME CITY PINCODE STATE BAL_DUE


C00001 Ivan Bayross Bombay 400054 Maharashtra 15000
C00002 Vandana Saitwal Madras 780001 Tamil Nadu 0

C00003 Pramada Jaguste Bombay 400057 Maharashtra 5000


C00004 Basu Navindgi Bombay 400056 Maharashtra 0
C00005 Ravi Shreedharan Delhi 100001 2000
C00006 Rukmini Bombay 400050 Maharashtra 0

Table Name: PRODUCT_MASTER

PRODUC DESCRIPTION PROFIT_ UNIT_MEA QTY_O REOR SELL_P COST_P


T no PERCEN SU N_HAN DER_L RICE RICE
T D VL
P00001 1.44 Floppies 5 Piece 100 20 525 500
P03453 Monitors 6 Piece 10 3 12000 11280
P06734 Mouse 5 Piece 20 5 1050 1000
P07865 1.22 Floppies 5 Piece 100 20 525 500

P07868 Keyboards 2 Piece 10 3 3150 3050


P07885 CD Drive 2.5 Piece 10 3 5250 5100
P07965 540 HDD 4 Piece 10 3 8400 8000
P07975 1.44 Drive 5 Piece 10 3 1050 1000
P08865 1.22 Drive 5 Piece 2 3 1050 1000

Table Name: SALES_MASTER

Sales Salesman Addr Addre City Pincode Stat Salea Tgt_T Ytd Rem
man_N _Name ess1 ss2 e mt o_Get sale arks
o s
S00001 Kiran A/14 Worli Bombay 400002 MA 3000 100 50 Good
H
S00002 Manish 65 Narim Bombay 400001 MA 3000 200 100 Good
an H
S00003 Ravi P-7 Bandr Bombay 400032 MA 3000 200 100 Good
a H
S00004 Ashish A/5 Juhu Bombay 400044 MA 3500 200 150 Good
H
Table Name: SALES_ORDER

S_ORDE S_ORDER CLIENT DELY_T BILL SALESM DELY_D ORDER_S


R_NO _DATE _NO YPE ED ANNO ATE TATUS
O19001 12-JAN-96 C00001 F N S00001 20-JAN- In Process
96
O19002 25-JAN-96 C00002 P N S00002 27-JAN- Canceled
96
O46865 18-FEB-96 C00003 F Y S00003 20-FEB- Fulfilled
96
O19003 03-APR-96 C00001 F Y S00001 07-APR- Fulfilled
96
O46866 20-MAY-96 C00004 P N S00002 22-MAY- Canceled
96
O10008 24-MAY-96 C00005 F N S00004 26-MAY- In Process
96

Table Name: SALES_ORDER_DETAIL

S_ORDER_NO PRODUCT_NO QTY_ORDERED QTY_DISP PRODUCT_RATE


O19001 P00001 4 4 525
O19001 P07965 2 1 8400
O19001 P07885 2 1 5250
O19002 P00001 10 0 525
O46865 P07868 3 3 3150
O46865 P07885 3 1 5250
O46865 P00001 10 10 525
O46865 P03453 4 4 1050
O19003 P03453 2 2 1050
O19003 P06734 1 1 12000
O46866 P07965 1 0 8400
O46866 P07975 1 0 1050
O10008 P00001 10 5 525
O10008 P07975 5 3 1050

Table Name: challan_header

CHALLAN S_ORDER_NO CHALLAN_DATE BILLED


_NO
CH9001 O19001 12-DEC-95 Y
CH6865 O46865 12-NOV-95 Y
CH3965 O10008 12-OCT-95 Y

Table Name: challan_details


CHALLAN PRODUCT QTY_DISP
_NO _NO
CH9001 P00001 4
CH9001 P07965 1
CH9001 P07885 1
CH6865 P07868 3
CH6865 P03453 4
CH6865 P00001 10
CH3965 P00001 5
CH3965 P07975 2

QUERIES

Single Table Retrival :


1. Find out the names of all the clients.

2. Print the entire client_master table.

3. Retrieve the list of names and the cities of all the clients.

4. List the various products available from the product_master table.

5. Find the names of all clients having ‘a’ as the second letter in their names.

6. Find out the clients who stay in a city whose second letter is ‘a’.

7. Find the list of all clients who stay in city ‘Bombay’ or city ‘Delhi’ or city ‘Madras’.

8. List all the clients who are located in Bombay.

9. Print the list of clients whose bal_due are greater than value 10000.

10. Print the information from sales_order table of orders placed in the month of
January

11. Display the order information for client_no ‘C00001’ and ‘C00002’.

12. Find the products with description as ‘1.44 Drive and ‘1.22 Drive.’

13. Find the products whose selling price is greater than 2000 and less than or equal to
5000.

14. Find the products whose selling price is more than 1500 and also find the new
selling price as original selling price*15.

15. Rename the new column in the above query as new_price.

16. Find the products whose cost_price is less than 1500.

17. List the products in sorted order of their description.

18. Calculate the square root of the price of each product.


19. Divide the cost of product ‘540 HDD’ by difference between its price and 100.

20. List the names, city and state of clients not in the state of ‘Maharashtra’.

21. List the product_no, description, sell_price of products whose description begin
with letter ‘M’.

22. List all the orders that were cancelled in the month of March.

23. Display all the Client names in Capitals and State in Lowercase.

24. Price must be displayed in 8,2 format. Put '*' before the amount. e.g. ***23.90.

25. Display Description and Qty_on_hand for each product.

26. Display sales transactions (qty_ordered and qty_disp) from Sales_order_details.

Set Functions and Concatenation:

27. Count the total number of orders.

28. Calculate the average price of all the products.

29. Calculate the minimum price of products.

30. Determine the maximum and minimum product prices. Rename the title as
max_price and min_price respectively.

31. Count the number of products having price greater than or equal to 1500.

32. Find all the products whose qty_on_hand is less than reorder level.

33. Print the information of client_master,product_master,sales_order table in the


following format for all the records :-

{cust_name} has placed order {order_no} on {s_order_date}

Having and Group By:

34. Print the description and total qty sold for each product.

35. Find the value of each product sold.

36. Calculate the average qty sold for each client that has a maximum order value
of 15000.00
37. Find out the total sales amount receivable for the month of jan.It will be the
sum total of all the billed orders for the month.

38. Print the information of product_master,order_detail table in the following


format for all the records :- {description} worth Rs. {total sales for the product}
was sold.

39. Print the information of product_master,order_detail table in the following


format for all the records :-

{description} worth Rs. {total sales for the product} was ordered in the month
of {s_order_date in month format}

40. Find out the total Qty_Disp and Qty_ordered of each item from
Sales_order_Details.

41. Find out the no. of sales transactions of each day from Sales_order_details.

42. Compute average, minimum and maximum Qty_ordered for each product.

You might also like