Professional Documents
Culture Documents
Experiment 14
Open Ended Lab
CLO1 EXECUTE the Database Server using MS SQL Server 2017 by using Structure Query Language, students
will be able to apply DML and DDL commands in database management. Programming and debugging,
using different views, functions, procedures and forms in MS SQL Server can program and debug the
queries. [ P4, PLO - 5 ]
CLO2. Adopt the laboratory rules and safety procedures; perform the lab experiments and solve
problems on cohort Levels through effective communication [A3, PLO-8]
Lab Objective:
Purpose of this open ended lab is to develop an analytical, logical and thinking ability of a
student to solve any Database Management System related problems.
An Organization has a database which maintains the records for the customer which places the
order(s) through the salesmen. There can be more than on customer who places the order(s)
through a single salesman or there can be single customer which places the order(s) through
multiple salesmen.
The tables and details that you will have to enter in the database are:
Table 1 SALESMEN
SID SNAME CITY SALARY PRODUCT COMM
S101 Ajay Patel Ahmedabad 3000 books 1200
Table 2 à CUSTOMERS
CID CNAME CITY STATE PINCODE PRODUCT CLASS
C301 Nirav Patel Nadiad Pakistan 001 books B
C302 Kiran Dave Delhi India 002 pencils A
C303 Sapan Shah Bangalore America 003 skirts B
C304 Saurabh Mehta Baroda India 004 Apple C
Table 3 à ORDERS
OID CID SID PRODUCT QUANTITY ODATE O_AMT
O501 C302 S102 books 2 02-JAN-09 700000
O502 C301 S105 pencils 12 21-JAN-09 10000
O503 C308 S103 skirts 1 10-FEB-09 250000
O504 C306 S104 apple 7 14-FEB-09 400000
O505 C306 S102 orange 10 29-MAR-09 100000
O506 C303 S101 pens 5 15-APR-09 90000.50
O507 C304 S105 mangoes 3 24-JUN-09 7500.75
O508 C306 S101 cellphone 1 27-SEP-09 900000
O509 C302 S102 car 1 21-DEC-09 205000
O510 C307 S102 ball 6 30-DEC-09 27800
O511 C303 S104 computer 2 31-DEC-09 15000
Solution:
1. Create the database for this problem Statement.
Query:
CREATE DATABASE ORGANIZATION;
b. List the name of all the salesmen whose salary is greater than 2000.
Query:
SELECT SNAME FROM SALESMEN WHERE SALARY > 2000;
c. Display order id and order date from orders table whose sales id is S102.
Query:
SELECT OID, ODATE FROM ORDERS WHERE SALES ID=”S102”;
d. List all the information of customers in descending order according to their name.
Query:
SELECT* FROM CUSTOMER WHERE ORDER BY NAME DESC;