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

US03CBCA04 - Practical

The document outlines a practical assignment for BCA students at Sardar Patel University, focusing on the creation of various database tables including Customer Master, Movies Master, and Invoice Transaction tables, along with their respective data entries. It also includes the creation of tables with constraints such as DEPT, EMP, and others, detailing their structure and sample data. Additionally, it provides instructions for inserting data into tables like client_master, product_master, and sales_order, among others.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

US03CBCA04 - Practical

The document outlines a practical assignment for BCA students at Sardar Patel University, focusing on the creation of various database tables including Customer Master, Movies Master, and Invoice Transaction tables, along with their respective data entries. It also includes the creation of tables with constraints such as DEPT, EMP, and others, detailing their structure and sample data. Additionally, it provides instructions for inserting data into tables like client_master, product_master, and sales_order, among others.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

SARDAR PATEL UNIVERSITY

BCA
Course : US03CBCA04
(Practical)

Assignment 1: (Table Creation)


Table creation without constraints:
a. Customer Master table : cust
Column Name Format
cust_id char(5)
Lname char(15)
Fname char(15)
Area char(2)
phone_no number(8)
b. Movies Master table: movie
Column Name Format
mv_no number(5)
Title char(25)
Type char(10)
star char(25)
Price number(8,2)
c. Invoice transaction table: invoice
Column Name Format
inv_no char(3)
mv_no number(5)
cust_id char(5)
issue_date date
return_date date
Insert the following data into above respective tables :--
a. Data for cust table:

cust_id lname fname area phone_no


a01 Patel Vijay sa 381334
a02 Saitwal Vandana mu 556037
a03 Jaguste Pramada da 372631
a04 Navindgi Basu ba 666612
a05 Sreedhran Ravi va -
a06 - Rukmini ga 512527

Page 1 of 9
b. Data for movie table:
mv_no title type star price
1 Bloody Vengeance action Jackie Chan 180.95
2 The firm thriller Tom Cruise 200.00
3 Pretty woman romantic Richarge Gere 150.00
4 Home alone comedy Macaulay Culkin 150.55
5 The fugitive thriller Harrison Ford 200.00
6 Coma suspence Michael Douglas 100.00
7 Dracula horror Gray Oldman 150.00
8 Quick change comedy Bill Murray 100.00
9 Gone with the wind drama Clarke Gable 200.00
10 Carry on doctor comedy Leslie Phillips 100.00
c . Data for invoice table :

inv_no mv_no cust_id issue_date return_date


i01 4 a01 13-jan-96 25-jan-96
i02 3 a02 12-feb-96 15-feb-96
i03 1 a02 15-feb-96 18-feb-96
i04 6 a03 10-mar-96 13- mar -96
i05 7 a04 05-feb-96 08-feb-96
i06 2 a06 18-mar-96 21-mar-96
i07 9 a05 07-jan-96 10-jan-96
i08 9 a01 11-feb-96 14-feb-96
i09 1 a05 15-feb-96 28-feb-96
Table creation with constraints:

TABLE NAME : DEPT


Name Type Constraints
------------------------------- -------- ----
DEPTNO NUMBER (2) Primary Key
DNAME VARCHAR2 (14)
LOC VARCHAR2 (13)

DEPTNO DNAME LOC


-------- -------------- ------------ -----------------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Table: EMP
Name Type Constraints
------------------------------- -------- ----
EMPNO NUMBER(4) Primary Key
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2) Foreign Key dept(deptno)

Page 2 of 9
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
TABLE NAME: SALGRADE
Name Null? Type
------------------------------- -------- ----
GRADE NOT NULL NUMBER(1)
LOSAL NOT NULL NUMBER(4)
HISAL NOT NULL NUMBER(4)

GRADE LOSAL HISAL


------- --------- --------- --------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
Table Name : Client_master
Name Type Attributes
------------------------------- ------------------- ----------------------
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)

Table Name : Product_Master


Name Type Attributes
--------------- ------ ------------------
PRODUCT_NO VARCHAR2(6) Primary Key /first letter must start with ‘P’.
DESCRIPTION VARCHAR2(15) 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.

Page 3 of 9
Table Name : Salesman_master
Name Type Attributes
-------------------------- -------------
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


Name Type Attributes
------------------------------- -------------
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’)

Table Name :sales_order_details


Name Type Attributes
------------------ ------ -----------
S_ORDER_NO VARCHAR2(6) Primary Key /Foreign Key references
S_order_no of sales_order table.
PRODUCT_NO VARCHAR2(6) Primary Key / 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


Name Type Attributes
------------------ --------- -------------
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’.

Page 4 of 9
Table Name :Challan_Details
Name Type Attributes
------------- ------- ------------
CHALLAN_NO VARCHAR2(6) Primary Key/Foreign Key references
Challan_no of challan_header table.
PRODUCT_NO VARCHAR2(6) Primary Key / Foreign Key references
Product_no of product_master table
QTY_DISP NUMBER(4,2) Not Null

Insert the following data into their respective tables using the SQL insert statement :
Data for client_master table

CLIENT CLIENT NAME CITY PINCODE STATE BAL_DUE


NO.
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

Data for product_master table

PRODUCT DESCRIPTION PROFIT_PE UNIT_ME QTY_ON REORDER SELL_P COST_P


NO RCENT ASU _HAND _LVL RICE RICE
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

Data for sales_master table

Sales Salesman Address1 Address2 City Pincode State Salea Tgt_To_ Ytd Remarks
man_No _Name mt Get sales
S00001 Kiran A/14 Worli Bombay 400002 MAH 3000 100 50 Good
S00002 Manish 65 Nariman Bombay 400001 MAH 3000 200 100 Good
S00003 Ravi P-7 Bandra Bombay 400032 MAH 3000 200 100 Good
S00004 Ashish A/5 Juhu Bombay 400044 MAH 3500 200 150 Good

Data for sales_order table

S_ORDER S_ORDER_ CLIENT DELY_ BILLED SALESMAN DELY_ ORDER_STATUS


NO DATE NO TYPE YN NO DATE
------ --------- ------ --------------- - - --------- --------------------------------------------------------------------------------
O19001 12-JAN-96 C00001 F N S00001 20-JAN-96 In Process
O19002 25-JAN-96 C00002 P N S00002 27-JAN-96 Canceled
O46865 18-FEB-96 C00003 F Y S00003 20-FEB-96 Fulfilled
O19003 03-APR-96 C00001 F Y S00001 07-APR-96 Fulfilled
O46866 20-MAY-96 C00004 P N S00002 22-MAY-96 Canceled
O10008 24-MAY-96 C00005 F N S00004 26-MAY-96 In Process

Page 5 of 9
Data for sales_order_details table

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

Data for challan_header table

CHALLAN_NO S_ORDER_NO CHALLAN_DATE BILLED


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

Data for challan_details table

CHALLAN_NO PRODUCT_NO QTY_DISP


---------- ------ --------- ---------- ---------- ------------ ---------- ------
CH9001 P00001 4
CH9001 P07965 1
CH9001 P07885 1
CH6865 P07868 3
CH6865 P03453 4
CH6865 P00001 10
CH3965 P00001 5
CH3965 P07975 2

Assignment 2: (Single Table Retrieval)

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 a original selling price*15.
15. Rename the new column in the above query as new_price.

Page 6 of 9
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 begiin with
letter ‘M’.
22. List all the orders that were canceled in the month of March.
Assignment 3 (Set Functions and Concatenation)

23. Count the total number of orders.


24. Calculate the average price of all the products.
25. Calculate the minimum price of products.
26. Determine the maximum and minimum product prices. Rename the title as max_price
and min_price respectively.
27. Count the number of products having price greater than or equal to 1500.
28. Find all the products whose qty_on_hand is less than reorder level.
29. 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}

Assignment 4: (Having and Group By)

30. Print the description and total qty sold for each product.
31. Find the value of each product sold.
32. Calculate the average qty sold for each client that has a maximum order value of
15000.00
33. 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.
34. 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.
35. 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}

Assignment 5 (Joins and Correlations)

36. Find out the products which has been sold to ‘Ivan Bayross’.
37. Find out the products and their quantities that will have to delivered in the current
month.
38. Find the product_no and description of moving products.
39. Find the names of clients who have purchased ‘CD Drive’.
40. List the product_no and s_order_no of customers having qty_ordered less than 5
from the order_details Table for the product ‘1.44 Floppies’.
41. Find the products and their quantities for the orders placed by ‘Vandana Saitwal’ and
‘Ivan Bayross’.
42. Find the products and their quantities for the orders placed by client_no ‘C00001’ and
‘C00002’.

Page 7 of 9
Assignment 6 (Nested Queries)

43. Find the product_no and description of non-moving products.


44. Find the customer name,address1,address2,city and pincode for the client who has
placed order no “O19001’.
45. Find the client names who have placed orders before the month of May,96.
46. Find out if product ‘1.44 Drive’ is ordered by any client and print the client_nmo,name
to whom it was sold.
47. Find the names of clients who have placed orders worth Rs. 10000 or more.

Assignment 7 (Queries using Date)

48. Display the order number and day on which clients placed their order.
49. Display the month (in alphabets) and date when the order must be delivered.
50. Display the s_order_date in the format ‘dd-month-yy’ e.g. 12-February-98.
51. Find the date,15 days after today’s date.
52. Find the number of days elapsed between today’s date and the delivery date of the
orders placed by the clients.

Assignment 8 (Table Update)

53. Change the s_order_date of client_no ‘C00001’ to 24/07/96.


54. Change the selling price of ‘1.44 Floppy Drive’ to Rs. 1150.00.
55. Delete the record with order number ‘O19001’ from the order table.
56. Delete all the records having delivery date before 10 th July ’96.
57. Change the city of client_no ‘C00005’ to ‘Bombay’.
58. Change the delivery date of order number ‘O10008’ to 16-08-96.
59. Change the bal_due of client_no ‘C00001’ to 1000.
60. Change the cost price of ‘1.22 Floppy Drive’ to Rs. 950.00.
Assignment 9 (View)

Table structure:
dept (dept_id number(5) primary key, emp(emp_id number(3) primary key,
dept_name varchar2(20) not null) emp_name varchar2(20) not null,
emp_sal number(8,2),
dept_id number(5) references dept)

1 WAQ to create a view having name “emp_vw” which contains emp_id, emp_name and salary
from emp table.
2 WAQ to add new records in “emp” table using “emp_vw” view.
3 WAQ to update salary of JOHN from 2000 to 5000.
4 WAQ to create a read only view having name “emp_ro_vw” which contains emp_id,
emp_name and salary.
5 WAQ to view having name which contains emp_name, emp_sal and dept_name from dept
and emp table.

Page 8 of 9
Assignment 10 (sequence)

1 Create sequence “seq1to10” which is start with 1 and ends with 10.
2 Create sequence “seq_even” which is generates with even numbers between
100 and 500.
3 Create sequence “seq_rev” in a way that produce Z-A repetitive.
4 Create sequence “seq_div3”, it generates the number which is divisible by 3 and
numbers are between 3 and 23.
5 Create sequence “seq_5” which is generates the numbers between 5 and 250, it
start with 5 increment by 5, end with 250, cache value 5 and also the numbers are
in order.

Assignment 11 (synonym)

1 Create a synonym having name “emp_syn” for emp table.


2 Create a public synonym having name “dept_syn” for dept table.
3 Display data of emp table using synonym “emp_syn”.

Page 9 of 9

You might also like