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

DBE Lab Experiment 5: Name: Implement Queries On Constraints

This document describes a lab experiment involving creating database tables with constraints and inserting sample data. It provides the structure and sample data for tables related to a sales database, including sales_master, sales_order, sales_order_details, challan_header, and challan_details. It also lists several questions involving adding, modifying, and querying the data in these tables.

Uploaded by

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

DBE Lab Experiment 5: Name: Implement Queries On Constraints

This document describes a lab experiment involving creating database tables with constraints and inserting sample data. It provides the structure and sample data for tables related to a sales database, including sales_master, sales_order, sales_order_details, challan_header, and challan_details. It also lists several questions involving adding, modifying, and querying the data in these tables.

Uploaded by

Sumit Patil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

DBE

Lab Experiment 5

Name: Implement queries on Constraints.

Question 1. Create the following tables:


i. Sales_master
Columnname Datatype Size Attributes
Salesman_no varchar2 6 Primary key/first letter
must start with ‘s’
Sal_name varchar2 20 Not null
Address varchar2 Not null
City varchar2 20
State varchar2 20
Pincode Number 6
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, cannot be 0
Remarks Varchar2 30

ii. Sales_order

Columnname Datatype Size Attributes


S_order_no varchar2 6 Primary/first letter must be 0
S_order_date Date 6 Primary key reference clientno
of client_master table
Client_no Varchar2 25
Dely_add Varchar2 6
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 Can not be lessthan
s_order_date
Order_status Varchar2 10 Values (‘in
process’;’fulfilled’;back
order’;’canceled

. Sales_order_details
Column Datatype Size Attributes

S_order_no Varchar2 6 Primary key/foreign


key references
s_order_no of
sales_order
Product_no Varchar2 6 Primary key/foreign
key references
product_no of
product_master
Qty_order Number 8
Qty_disp Number 8
Product_rate Number 10,2
Data for sales_man master table

Tgt_to_
Salesman_ Salesman Address City Pin State Salamt get Ytd Rem
no name code Sales
500001 Kiran A/14 Bom 400002 Mah 3000 100 50 Good
worli bay
500002 Manish 65,narim Bom 400001 Mah 3000 200 100 Good
an bay
500003 Ravi P-7 Bom 400032 Mah 3000 200 100 Good
Bandra bay
500004 Ashish A/5 Bom 400044 Mah 3500 200 150 Good
Juhu bay
(ii)
Data for salesorder table:

S_orderno S_orderdate Client no Dely Bill Salesman no Delay Orderstatus


type yn date
019001 12-jan-96 0001 F N 50001 20-jan- Ip
96
019002 25-jan-96 0002 P N 50002 27-jan- C
96
016865 18-feb-96 0003 F Y 500003 20-feb- F
96
019003 03-apr-96 0001 F Y 500001 07-apr- F
96
046866 20-may-96 0004 P N 500002 22- C
may-96
010008 24-may-96 0005 F N 500004 26- Ip
may-96
(iii)
Data for sales_order_details table:

S_order no Product no Qty ordered Qty disp Product_rate


019001 P00001 4 4 525
019001 P07965 2 1 8400
019001 P07885 2 1 5250
019002 P00001 10 0 525
046865 P07868 3 3 3150
046865 P07885 10 10 5250
019003 P00001 4 4 1050
019003 P03453 2 2 1050
046866 P06734 1 1 12000
046866 P07965 1 0 8400
010008 P07975 1 0 1050
010008 P00001 10 5 525
Challan_Header

Column name data type size Attributes


Challan_no varchar2 6 Primary key
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

Column name data type size Attributes


Challan_no varchar2 6 Primary key/Foreign key
references Product_no
of product_master
Qty_disp number 4,2 not null

Q2. Insert the following values into the challan header and challan_details tables:
Challan No S_order No Challan Date Billed
CH9001 019001 12-DEC-95 Y
CH865 046865 12-NOV-95 Y
CH3965 010008 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

Answer the following Questionries


Q1. Make the primary key to client_no in client_master.

Q2. Add a new column phone_no in the client_master table.

Q3. Add the not null constraint in the product_master table with the columns description, profit percent
, sell price and cost price.

Q4. Change the size of client_no field in the client_master table.

Q5. Select product_no, description where profit percent is between 20 and 30 both inclusive.

You might also like