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

SQL Lab Tables (1)

The document outlines the creation of several database tables including Client_master, Product_master, Salesman_master, Sales_order, Sales_order_details, Challan_Header, and Challan_Details, detailing their structure, data types, sizes, and attributes. It also provides specific SQL insert statements to populate these tables with sample data for clients, products, salesmen, orders, and challans. Additionally, it mentions performing queries based on the created tables.

Uploaded by

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

SQL Lab Tables (1)

The document outlines the creation of several database tables including Client_master, Product_master, Salesman_master, Sales_order, Sales_order_details, Challan_Header, and Challan_Details, detailing their structure, data types, sizes, and attributes. It also provides specific SQL insert statements to populate these tables with sample data for clients, products, salesmen, orders, and challans. Additionally, it mentions performing queries based on the created tables.

Uploaded by

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

Tables for Exercise

Que : 1 Create the following tables:

Table Name : Client_master


Description : Use to store information about clients.

Column Name Data Type Size Attributes


Client_no Varchar 6 Primary Key / First letter must start with ‘C'.
Name Varchar 20 Not Null
City Varchar 15
State Varchar 15
Pincode Decimal 6
Bal_due Decimal 10,2

Table Name : product_master


Description : Use to store information about products.

Column Name Data Type Size Attributes


Product_no Varchar 6 Primary Key / first letter must start with ‘P'
Description Varchar 15 Not Null
Profit_percent Decimal 2,2 Not Null
Unit_measure Varchar 10 Not Null
Qty_on_hand Decimal 8 Not Null
Reorder_lvl Decimal 8 Not Null
Sell_price Decimal 8,2 Not Null, Cannot be 0.
Cost_price Decimal 8,2 Not Null, Cannot be 0.

Table Name : salesman_master


Description : Use to store information about salesman working in the company

Column Name Data Type Size Attributes


Salesman_no Varchar 6 Primary Key / First letter must start with ‘S'
Salesman_name Varchar 20 Not Null
Address1 Varchar 30 Not Null
Address2 Varchar 30
City Varchar 20
Pincode Varchar 6
State Varchar 20
Sal_amt Decimal 8,2 Not Null, cannot be 0
Tgt_to_get Decimal 6,2 Not Null, cannot be 0
Ytd_sales Decimal 6,2 Not Null
Remarks Varchar 60

Table Name : sales_order


Description : Use to store information about order

Column Name Data Type Size Attributes


S_order_no Varchar 6 Primary Key / First letter must start with ‘O'
S_order_date Date
Client_no Varchar 6 Foreign Key references client_no of client_master table
Dely_addr Varchar 25
Salesman_no Varchar 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 Varchar 10 Values(‘ln Process', ‘Fulfilled', ‘BackOrder','Canceled')
Table Name : sales_order_details
Description : Use to store information about products ordered.

Column Name Data Type Size Attributes


S_order_no Varchar 6 Primary Key / Foreign Key references s_order_no of
sales_order table.
Product_no Varchar 6 Primary Key / Foreign Key references product_no of
product_master table.
Qty_ordered Decimal 8
Qty_disp Decimal 8
Product_rate Decimal 10,2

Table Name : Challan_Header


Description : Use to store information about challans made for the order.

Column Name Data Type Size Attributes


Challan_no Varchar 6 Primary Key / first two letters must start with ‘CH'.
S_order_no Varchar 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


Description : Use to store information about challans made for the order.

Column Name Data Type Size Attributes


Challan_no Varchar 6 Primary key/ Foreign key references challan_no of
challan_header table.
Product_no Varchar 6 Primary key/ Foreign key references product_no of
product_master table.
Qty_disp Decimal 4,2 Not Null
Que : 2 lnsert the following data into their respective tables using the SQL insert statement :

1. Data for client_mastr table :

Client_no Name City Pincode State Bal_due


C00001 lvan 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 Sreedharan Delhi 100001 2000
C00006 Rukmini Bombay 400050 Maharashtra 0

2. Data for Product_master table :

Profit
Product_no Description UOM Qty_on_hand Reorder_lvl Sell_price Cost_price
Percent
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

3. Data for Salesman_master table :

Salesman Salesman Sal Tgt_to Ytd


Add1 Add2 City Pincode State Remarks
No Name Amt 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 3000 200 150 Good
4. Data for sales_order table :

Dely Bill Salesman Order


S_order_no S_order_date Client_no Dely_date
Type YN No Status
O19001 12-jan-96 C00001 F N S00001 20-jan-96 lP
O19002 25-jan-96 C00002 P N S00002 27-jan-96 C
O46865 18-feb-96 C00003 F Y S00003 20-feb-96 F
O19003 03-apr-96 C00001 F Y S00001 07-apr-96 F
O46866 20-may-96 C00004 P N S00002 22-may-96 C
O10008 24-may-96 C00005 F N S00004 26-may-96 lP

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

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

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

Perform the following queries on the basis of these tables.

You might also like