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

Dbms 1

The document describes a database schema for a sales information system with tables for products, clients, salesmen and sales orders. It includes the SQL commands to create the tables, insert sample data, retrieve data and modify the schema. Sample data is inserted into the tables and various queries are written to retrieve and manipulate the data.

Uploaded by

Anushka Singh
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 views13 pages

Dbms 1

The document describes a database schema for a sales information system with tables for products, clients, salesmen and sales orders. It includes the SQL commands to create the tables, insert sample data, retrieve data and modify the schema. Sample data is inserted into the tables and various queries are written to retrieve and manipulate the data.

Uploaded by

Anushka Singh
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/ 13

PRACTICAL -1

Ques -1 ) Design and develop database of sales information system. A product


can be described with a unique product number, product name, selling price,
manufacturer name. The product can sale to a particular client and each client
have it own unique client number, client name, client addresses, city, pin code,
state and total balance to be required to paid. Each client order to buy product
from the salesman. In the order, it has unique sales order number, sales order
date, client number, salesman number(unique), billed whole payment by the
party or not and its delivery date. The salesman has the name, addresses, city,
pin code, state, salary of the sales man, delivery date, total quantity ordered,
product rate.
Solution -1 )
Create DATABASE SALES_INFORMATION_SYSTEM;

USE SALES_INFORMATION_SYSTEM;

(a) Command to Create Tables :-

1. Create table product (product_id varchar(10) primary key, product_name varchar(20),


manufacturer_name char(20),product_rate numeric(9,4), sell_price numeric(9,4),
product_description varchar(25));

2. Create table client (client_id varchar(10) primary key, client_name char(20),address


varchar(15), city char(15),pin numeric(8), state char(15),bal_due numeric(9,4));

3. Create table salesman (salesman_id varchar(10) primary key, salesman_name


char(20),address varchar(15), city char(15),pin numeric(8), state char(15),salary
numeric(9,4));

4. Create Table sales_order_details ( sales_order_no VARCHAR(10) PRIMARY KEY,


sales_order_date DATE, client_id VARCHAR(10) REFERENCES client(client_id),
salesman_id VARCHAR(10) REFERENCES salesman(salesman_id),
bill_payby_party CHAR(5), delivery_date DATE, product_rate
NUMERIC(9,4),tot_quantity_order NUMERIC(8), cancel_date DATE DEFAULT
NULL );

(b) Command to See Tables:-


Desc product
Desc client;

Desc salesman;
Desc sales_order_details;

(c) Command to Insert values in Tables:


1. Product Table
INSERT INTO product VALUES ('p001', 'lux_soap', 'Lux_international', 15.0000, 20.0000, 'soap');

INSERT INTO product VALUES ('p002', 'copy', 'times_copy_org', 14.0000, 16.0000, 'copy');

INSERT INTO product VALUES ('p003', 'marry_biscuit', 'marigold_org', 2218.0000, 2220.0000,


'buiskit');

INSERT INTO product VALUES ('p004', 'mitsubisi_pen', 'pen_international', 2015.0000, 2120.0000,


'pen');

INSERT INTO product VALUES ('p005', 'learn_books', 'book_world', 5104.0000, 5116.0000, 'book');

INSERT INTO product VALUES ('p006', 'tata_steel', 'tata_org', 5118.0000, 5120.0000, 'tata');

INSERT INTO product VALUES ('p007', 'seagate_hdd', 'seaget_world', 5104.0000, 5116.0000,


'HDD1034');

INSERT INTO product VALUES ('p008', 'dvd_writer', 'frontec_org', 5118.0000, 5120.0000,


'DVDRW');
2. Client Table
INSERT INTO client VALUES ('cn01001', 'anushka singh', 'b.d.para', 'dehradun', 248007,
'uttarakhand', 390.9);

INSERT INTO client VALUES ('cn01002', 'sunny mangat', 'kheri gao', 'dehradun', 248008,
'uttarakhand', 2390.9);

INSERT INTO client VALUES ('cn01004', 'ritika tyagi', 'chora para', 'kamalpur', 799301, 'tripura',
1390.9);

INSERT INTO client VALUES ('cn01005', 'mita mia', 'kamal para', 'singur', 799721, 'tripura', 190.9);

INSERT INTO client VALUES ('cn01006', 'pulak roy', 'bircity', 'sonitpur', 799141, 'assam', 110.9);

INSERT INTO client VALUES ('cn01007', 'munni das', 'nappam', 'sonitpur', 799152, 'assam', 190.9);

INSERT INTO client VALUES ('cn01008', 'kusum roy', 'city_dos', 'tezpur', 799141, 'assam', 110.9);

INSERT INTO client VALUES ('cn01009', 'mina das', 'pachmile', 'tezpur', 799152, 'assam', 190.9);

INSERT INTO client VALUES ('cn01003', 'moytree nayak', 'pachmile', 'tezpur', 799152, 'assam',);

INSERT INTO client VALUES ('cn01010', 'pauri mia', 'pachmile', 'tezpur', 799152, 'assam', 2990.9);

INSERT INTO client VALUES ('cn01011', 'manali das', 'satmile', 'tezpur', 799154, 'assam', 3990.9);

3. Salesman Table
INSERT INTO salesman VALUES ('s001', 'Rohan das', 'nappam', 'Tezpur', 79970, 'Assam',
8000.0000);
INSERT INTO salesman VALUES ('s002', 'Rohan das', 'nappam', 'Tezpur', 799170, 'Assam',
8000.0000);

INSERT INTO salesman VALUES ('s003', 'Smita das', 'nirjuli', 'itanagar', 799701, 'Arunachal',
9000.0000);

INSERT INTO salesman VALUES ('s004', 'Kabir bora', 'nappam', 'Tezpur', 799703, 'Assam',
8500.0000);

INSERT INTO salesman VALUES ('s005', 'Neha singh', 'borbota', 'sonitpur', 795970, 'assam',
9600.0000);

INSERT INTO salesman VALUES ('s006', 'Priya agarwal', 'gandhi road', '32 distric', 799750, 'delhi',
9900.0000);

INSERT INTO salesman VALUES ('s007', 'Ashok Paul', 'filmcity', 'munnabari', 799740, 'mumbai',
8900.0000);

4. sales_order_details Table
INSERT INTO sales_order_details VALUES ('on01001', '2024-08-01', 'cn01001', 's001', 'yes', '2024-
08-20', 2220.40, 50, NULL);

INSERT INTO sales_order_details VALUES ('on01002', '2024-08-12', 'cn01004', 's001', 'yes', '2024-
08-23', 2220.40, 15, NULL);

INSERT INTO sales_order_details VALUES ('on01003', '2024-08-12', 'cn01005', 's003', 'yes', '2024-
08-26', 2220.40, 10, NULL);

INSERT INTO sales_order_details VALUES ('on01004', '2024-08-13', 'cn01004', 's001', 'yes', '2024-
08-20', 2220.40, 15, NULL);

INSERT INTO sales_order_details VALUES ('on01005', '2024-08-14', 'cn01002', 's002', 'no', '2024-
08-30', 2220.40, 52, '2024-03-28');

INSERT INTO sales_order_details VALUES ('on01006', '2024-08-15', 'cn01001', 's001', 'yes', '2024-
08-31', 2220.40, 53, NULL);

INSERT INTO sales_order_details VALUES ('on01007', '2024-01-16', 'cn01003', 's004', 'yes', '2024-
08-28', 2220.40, 54, NULL);

INSERT INTO sales_order_details VALUES ('on01008', '2024-02-01', 'cn01004', 's003', 'no', '2024-
08-28', 8220.40, 54, '2024-03-18');
Command to get values from Tables:

1. Select * from client;

2. Select * from product;

3. Select * from salesman;


4. Select * from sales_order_details;
E-R DIAGRAM :-

PRACTICAL -2
Ques ) Develop and execute following queries after creating the above database.
(a) Retrieve the list of names and the cities of all the clients.

(b) List the various products available.

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

(d) List all the clients who are located in Dehradun.

(e) Find the products whose selling price is greater than 2000 and less than or equal
to 4000.
Solution :-

(a) Select client_name, city from client;

(b) Select * from product;

(c) SELECT client_name FROM client WHERE client_name LIKE '_a%';


(d) SELECT * FROM client WHERE city ='dehradun';

(e) SELECT * FROM product WHERE sell_price > 2000 AND (sell_price < 4000 OR
sell_price = 4000);

PRACTICAL - 3
Ques - 3) Develop and execute following queries after creating the above
database.
(a) Add a new column NEW_PRICE into the product_master table.
(b) Rename the column product_rate of Sales_Order_Details to new_product_rate.
(c) List the products in sorted order of their description.
(d) Display the order number and date on which the clients placed their order.
(e) List the names, city and state of the clients not in the state of ‘UTTARAKHAND’.

Sol - 3)
(a) ALTER TABLE product ADD (new_price numeric(9,4));
Desc product;

(b) ALTER table Sales_Order_Details RENAME column product_rate to new_product_rate;


Desc Sales_Order_Details;
(c) SELECT * FROM product ORDER BY PRODUCT_DESCRIPTION ASC;

(d) SELECT sales_order_no, sales_order_date FROM Sales_Order_Details;


(e) SELECT client_name, city, state FROM client WHERE state <> 'UTTARAKHAND';

You might also like