LAB ASSIGNMENT RECORD
On
(BCAMJ23416)
Database Management System Lab
COLLEGE OF COMPUTING SCIENCES AND INFORMATION
TECHNOLOGY
TMU, MORADABAD
Session 2024-2025
Submitted To: Submitted By:
Mr. Anuj Kumar Raghav Student Name :
Asst. Professor, CCSIT Enrollment No.:
LAB ASSIGMENT NAME –Basic SQL Queries
LAB ASSIGMENT NO. –1
Assignment 1 is based on the following Table:
FIRST LAST ID AGE CITY STATE
John Jones 99980 45 Payson Arizona
Mary Jones 99982 25 Payson Arizona
Eric Edwards 88232 32 San Diego California
Mary Ann Edwards 88233 32 Phonix Arizona
Ginger Howell 98002 42 Cottonwood Arizona
Sebastian Smith 92001 23 Gila Bend Arizona
Gus Gray 22322 35 Bagdad Arizona
Mary Ann May 32326 52 Tucson Arizona
Erica William 32327 60 Show Low Arizona
Leoroy Brown 32380 22 Pinetop Arizona
Elroy Cleaver 32382 22 Globe Arizona
S.NO PROGRAM NAME PAGE NO DATE SIGN REMARK
1 Create the table EMPINFO with ID as a Primary
key constraint.
2 Insert all the above mentioned values in table.
3 Select all the first name ,last name & city from
the table whose names starts with 'Er'
4 Select first name & last name from the table
whose last names ends with 's'
5 Select all the details from the table whose first
name equals 'Eric' exactly
6 Select all the details of the table EMPINFO.
7 Display the first name & age for everyone that
is in the table
8 Display the first name, last name & city for
everyone that is not from 'Payson'
9 Display all columns for everyone that is over
40 years old
10 Display the first & last names for everyone
whose last name ends in an 'ay'
11 Display all columns for everyone whose first
name equals 'Mary'
12 Display all the columns for everyone whose first
name contains 'Mar'
13 Select first name , last name & age from the
table where last name contains 'illia'
14 Select the first name , last name , city & state
whose first name starts with 'J'
15 Display the last name and city of employees who
belongs to Arizona and whose age is greater than
25
16 Display the details of employees with id 32382,
32326 and 99980.
17 Count the number of employees who work in
Tucson and Payson
18 Display the first name and last name in a single
column
19 Display the record like : “Hello John welcome to
Payson City” where name and city has to be fetch
from table for all the employees
20 Display the details of employees whose first name
and last name starts with the same character
Customer Table
Cus_I Cus_Name Ref_I Prod_ID Date_of_Purchas Price Discoun
D D e t
1359 Elina Taylor 1608 20 05-Oct-2006 1000
1573 Mark Lyon 1175 40 07-Sep-2008 1550 110
1932 Stuart Twain 1608 60 23-Aug-2009 3000 230
1000
1875 Allan Samuels 1610 80 15-Nov-2011 0 970
1723 Peter Russel 40 17-July-2010 4000 250
1973 Andre Finch 1932 60 12-Mar-2014 6000 530
1205 Steffi Nicolus 1175 20 07-Feb-2012 1500
Adams
1608 Franklin 80 05-Jan-2010 8000 509
1175 Luke Martin 1932 60 14-Dec-2007 3500 300
1097 Joseph Milne 1610 40 07-Apr-2007 1200 80
1850 Mary Roberts 1875 20 12-Sep-2008 1170
1105
1610 Sheldon Moris 1175 80 08-May-2009 0 915
Product Table
Prod_ID Prod_Category
20 Cosmetics
40 Daily Needs
60 Garments
80 Equipment
LAB ASSIGMENT NAME – SQL Queries with Aggregate Functions and Clauses
LAB ASSIGMENT NO. –2
S.NO PROGRAM NAME PAGE NO DATE SIGN REMARK
.
1 Create the Table Customer Cus_ID as
Primary key
2 Insert the given records into the table
3 Select top 3 Customer ID from the sorted
table
4 Change Customer name into uppercase.
5 List customer name who purchases the
product ID 80.
6 Alter Customer table to set the default
value of customer name as ABC
7 List First Customer ID whose price is less
than 2000
8 List the Customers belonging to the Product
ID 20.
9 List the ID and name of the customers
whose Product Price is more than 4000
10 List the Customer ID & ID of Reference
Person.
11 List the records in the Ascending Order of
Customer Name
12 List the Name of the Customers who purchase
their products before 5-Jul-2009
13 List the name of Customers who does not refer
any person.
14 List the different Products ID available in
the Customer table.
15 List the customer names who are not
eligible for discount.
16 List the ID of the Customers having "a" as
second character of their name
17 List the Customer name, Product Price &
Product ID in ascending order of Product
ID & then on descending order of Price
18 Count the no. of different Products
available in the Customer table
19 List the total Price paid by the Customers
20 List the maximum Price of products
categorize as Equipment
21 List the minimum price of products in
Customer table
22 List the average price and the no. of customers
purchasing product having ID as 60
23 List the average price from each job
excluding Cosmetics
24 List total price, maximum & minimum
price and the average price for product Id
20 and 80.
25 List the average price for each product
within each product category.
26 Update the discount of Mark Lyon from
110 to 100
27 Delete the record of Luke Martin.
28 Change the data type size of cus_name
29 Create a copy of Customer Table as
NewCustomer
30 Remove the NewCustomer Table while
maintaining its structure
31 Remove the NewCustomer table
completely from the disk.
LAB Assignment Name-SQL Queries with Join Operations
LAB Assignment No.-3
S.NO. PROGRAM NAME PAGE DATE SIGN REMARK
NO.
1 Display product ID and no. of customers
for each Product ID
2 Display Customer ID, Customer Name and
their respective Product Category
3 Display Customer name, Product Category,
Price and Discount for those whose Price
lie in between 5000 and 10000
4 Display the id and name of all those
customers who give the reference of at least
one Customer.
5 List the Customer Name and their
respective reference name.
6 Display Customer Name and Product
Category even if customers don’t purchase
a particular product category.
7 List all customers who purchase their
product before their reference person.
8 List all customers who purchase their
product after their reference person.
9 List the Customer Names whose Price is
greater than the lowest price of Product ID
60.
10 Display Customer Name and their product
price whose Product Price is greater than
highest average of Product Category.
11 List all those Customers whose product
price is greater than the Product Price of
their Reference Person.
12 Display the Product Category along with
total discount given for each category.
13 Display those customers whose product
price is less than the average of minimum
and maximum price out of all categories.
14 Display 3 least product prices and their ID.
15 Count total reference persons who give
their reference to customers.
Lab Assignment-Table with Constraints
Lab Assignment No-4
The assignment is based in context to the relations given below. Create the following table
as per given constraints.
1. Table:- CLIENT_MASTER
Column Name Data type Size Attribute Constraints
CLIENTNO VARCHAR2 6 Primary Key/ First Latter must start with ‘C’
NAME VARCHAR2 20 NOTNULL
ADDRESS1 VARCHAR2 30
ADDRESS2 VARCHAR2 30
CITY VARCHAR2 15
PINCODE NUMBER 8
STATE VARCHAR2 15
2. Table: - PRODUCT_MASTER
Column Name Data type Size Attribute Constraints
PRODUCTNO VARCHAR2 6 Primary Key/ First Latter must start with
‘P’
DESCRIPTION VARCHAR2 15 NOTNULL
PROFITPERCENT NUMBER 4,2 NOTNULL
UNITMEASURE VARCHAR2 10 NOTNULL
QTYONHAND NUMBER 8 NOTNULL
REORDERLVL NUMBER 8 NOTNULL
SELLPRICE NUMBER 8,2 NOTNULL, Cannot be 0
COSTPRICE NUMBER 8,2 NOTNULL, Cannot be 0
3. Table: - SALESMAN_MASTER
Column Name Data type Size Attribute Constraints
SALESMANNO VARCHAR2 6 Primary Key/ First Latter must start with
‘S’
SALESMANNAME VARCHAR2 20 NOTNULL
ADDRESS1 VARCHAR2 30 NOTNULL
ADDRESS2 VARCHAR2 30
CITY VARCHAR2 20
PINCODE NUMBER 8
STATE VARCHAR2 8,2
SALAMT NUMBER 8,2 NOTNULL, Cannot be 0
TGTTOGET NUMBER 6,2 NOTNULL, Cannot be 0
YTDSALES NUMBER 6,2 NOTNULL
REMARKS VARCHAR2 60
4. Table: - SALES_ORDER
Column Name Data type Size Attribute Constraints
ORDERNO VARCHAR2 6 Primary Key/ First Latter must start with ‘O’
CLIENTNO VARCHAR2 6 Foreign key references ClientNo of
Client_Master table
ORDERDATE DATE NOTNULL
DELYADDRESS VARCHAR2 25
SALESMANNO VARCHAR2 6 Foreign key references SalesmanNo of
Salesman_Master table
DELTYPE CHAR 1 Delivery:- Part(P)/ Full(F)
BILLYN CHAR 1
DELYDATE DATE
ORDERSTATUS VARCHAR2 10 Values(‘In Process’, ’Fulfilled’,
’BackOrder’, ’Cancelled’)