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

Class 12 LabFile (2)

Uploaded by

radha14622200
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)
23 views

Class 12 LabFile (2)

Uploaded by

radha14622200
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/ 14

Govt.

Co-ed Sarvodaya Vidyalaya, Rohini Sector-


4 ,School ID- 1413336

PRACTICAL FILE
COMPUTER SCIENCE
Code No.- 083

Academic Session (2024-2025)

Submitted to: - Submitted by: -

Ms. Minakshi Student Name-


Lecturer (Computer Science) Student ID-
INDEX
Assignment No Topic Teacher’s Signature
Assignment 1 What is SQL? Features of SQL
Data types in SQL
Basics of SQL Create table student
& DDL Modify the structure of student table
Commands Create table Employee
Modify the structure of Employee table
Assignment 2 Create table customer
Insert 5 rows each using all the three methods
Display the contents
Display CID and Fname
Display Fname,Lname and state
Display all records where state is Delhi
Display fname, lname concatenated with state
Display the records whose pin is not entered
Display the states to which the customer belongs
Select records of Delhi having name Rajiv
Display records delhi or Karnataka
Display details of Customer with CID=98
DML
Display details of Customer except CID=98
Commands Use Alias Name to display CID
Retrieve all rows where CID is between 98 and 100
Display those rows where state name begins with ‘D’
Retrieve all rows where first name contains the word’RAJ’
Retrieve all rows where name field contains the word’RA ESH’
Retrieve all rows where city is Delhi, Karnataka or Bangalore
Rename the table customer to customerdetails
Delete all those rows of customers who stay in Bangalore
Delete those customers who do not have Pin Code
Rename column city to address
Delete the customers who do not belong to Bangalore
Assignment 3 Create table employee
Insert 5 records
List name of all employees who work in Dept No. 5
Find names and salary of all the employees sorted according to salary
List names of employees having salary between 30,000 and 50,000
List name of employees who live in Janakpuri
List name of all female employees
Advanced DML List name of those employees whose bdate is before 2 Nov. 1996
List all employees whose fname is “Ram” and lName is “Kapoor”
Commands
Rename the column address to city
Sort the employees in descending order of city
Update the person named “Ram” to “Vikas”
Update city of empid 101 to Jaipur
Delete record of empid 102
Display those employees whose salary is not equal to 20,000
Assignment 4 Create table employee
Insert 5 records in employee table
Find average and total salaries of all employees
Find average and total salaries of each employee
Find minimum salary of Manager
Find the maximum salary of the Manager
How many employees are Managers
Add 50% salary to salary column and name it HRA
Count the total no. employees
Count the no. of departments available
Count the no. of employees in each department
Aggregate /
Update the commission to 10%of salary for all the employees having
Grouping
salary greater than 50000
Functions Find the name of lowest paid employee for each manager
Update the salaries of all employees in department 10 by hiking it by
15%.
Find the difference between highest and lowest salaries for each dept
List average salary for all the depts which have more than 5 People
List jobs of all the employees where maximum salary is more than
40000
List jobs and no. of employees in each job
List average salary of each job excluding managers
List total, Max, Min, Average salary of employees job wise
Assignment 5 create table course
create table student
Add the following constraints to the above tables
Constraints
Specify the following constraints while creating table
specify the following constraints while alter table
Assignment 6 Create table Department
Create table Employee
Insert 5 records in both tables
Display the details of the employee who draws maximum salary
Display the details of the employee whose Department location is
Noida.
Display the Department Locations to which employees belong.
Increase the Salary of Employees by 1000Rs whose Designation is
Manager
Change the column name Designation to Job
Delete the column Dlocation
Assignment 7 Create the Department table
Joins Create the Employee table
Create the SalGrade
Insert 5 records in all tables
Display Empno, Salary,Deptname of employees
Use table Alias & solve the above query again
Display Empno., ename,Grade and salary that should be greater than
lowsal and less than highsal
Retrieve name of employees where employee is also a manager
Display Empno, Ename, Dname , Dloc of all the employees (outer
join)
Display Empno, Ename, Dname , Dloc of all departments (outer
join)
Retrieve employee no, employee name along with their manager no
and manager name if any
Assignment 8 Create table hotel
Create table room
Create table guest
(Creating tables Create table booking
Find average price of a room
with
List name and address of guest with booking for a hotel in ‘delhi’
constraints,Gro ordered by name.
upingfuctions) Find total income of all rooms of the hotel in Mumbai
List names of guest at hotel TAJ
Increase price of rooms of TAJ to 10%
Count the no of rooms of each type
Assignment 1
Q1. What is SQL? What are the various features of SQL?
Q2. Describe various Data types used in SQL.
Q3. Create table student with fields: Roll No. , Name, Course and Date of Birth
and display its structure.
Q4. Modify the structure of student table as follows(display structure after every
modification):
a. Add two new columns named Section and Contact No.
b. Change the size of course column by 2 points.
c. Remove the column Date of Birth.
Q5. Create table Employee with fields: EmpID, EmpName, Designation and Date
of Joining
Q6. Modify the structure of Employee table as follows(display structure after every
modification):
a. Add a new column Salary.
b. Change the size of Salary by 5 points and Name by 10 Points.
c. Remove the fields Designation and Date of Joining.
Assignment 2
1. Create table customer with fields: CID, Fname, Lname, City, State ,Pin,
2. Insert 5 rows each using all the three methods(All Fields, Selected Fields
and User interactive)
3. Display the contents of Customer Table
4. Display CID and Fname of customers
5. Display Fname, Lname and state of all the Customers
6. Display all records from the customer table where state is Delhi
7. Display fname, lname of customers concatenated with state and name it as
“Customer and their Location”.
8. Display the records of those customers whose pin is not entered.
9. Display the states to which all the customer belongs.
10.Select records of customer from Delhi having name Rajiv.
11.Display records of customer from state delhi or Karnataka
12.Display details of Customer with CID=98
13.Display details of Customer except the customer with CID=98
14.Use Alias Name to display CID as Customer Number
15.Retrieve all rows where CID is between 98 and 100(both numbers included)
16.Display those rows where state name begins with ‘D’
17.Retrieve all rows where first name contains the word’RAJ’
18.Retrieve all rows where name field contains the word’RA ESH’
19.Retrieve all rows where state is Delhi or Karnataka
20.Rename the table customer to customerdetails.
21.Delete all those rows of customers who stay in Bangalore
22.Delete those customers who do not have Pin Code.
23.Rename column city to address
24.Delete the customers who do not belong to Banglore
Assignment 3

1. Create table employee with following attributes:


empid, fname, lname, bdate, address, gender, salary,dept_no.
2. Insert 5 records in employee table.
3. List name of all employees who work in Dept No. 5.
4. Find names and salary of all the employees sorted according to their salary
(ascending as well as descending).
5. List names of employees having salary between 30,000 and 50,000 using
logical operators
6. List name of employees who live in Janakpuri.
7. List name of all female employees.
8. List name of those employees whose bdate is before 2 Nov. 1996.
9. List all those employees whose first name is “Ram” and last Name is
“Kapoor”.
10.Rename the column address to city.
11.Sort the employees in descending order of city.
12.Update the person named “Ram” to “Vikas”.
13.Update city of empid 101 to Jaipur.
14.Delete record of empid 102.
15.Display those employees whose salary is not equal to 20,000
Assignment 4
1. Create table employee with following attributes:
Eno, Ename (Not Null), Salary(Not Null), Commission, Job, Deptno.
2. Insert 6 records in employee table.
3. Find average and total salaries of all employees.
4. Find minimum salary of Manager.
5. Find the maximum salary of the Manager.
6. How many employees are Managers.
7. Add 50% salary to salary column and name it HRA.
8. Count the total no. employees.
9. Count the no. of departments available.
10.Count the no. of employees in each department.
11.Update the commission to 10%of salary for all the employees having salary
greater than 50000.
12.Find the salary of lowest paid employee for each department.
13.Update the salaries of all employees in department no 2 by hiking it by 15%.
14.Find out the difference between highest and lowest salaries for each
department.
15.List average salary of each job excluding manager
Assignment 5
Q1.
a) Create table course with fields: Coursecode(primary key), Coursename(not
null),Section

b) Create table student with following attributes Rollno, First name, Lname
name, Address(unique), Coursecode(foreign key)

Add the following constraints to the above tables:


1. Roll no. should be primary key using alter statement

2. Add constraint on firstname to not allow blank entries

3. Add a check constraint on section i.e. it should be ‘m’ or ‘e’

4. Drop constraint primary key of student table using alter command.

Q2.
Person table
P_id Firstname Lastname Address city
1 Hari Om Tilaknagar 10 Delhi
2 Shyam Tomar Base 23 Bangalore
3 Petter Joseph Staff 20 Chandigarh

Orders table:
o_id orderno p_id
1 77895 3
2 44678 3
3 22456 2
4 24562 1
Specify the following constraints while creating table:-
1)p_id (person table)-primary key
2)first name-not null constraint
3)order no –unique constraint,not null
4)p_id(order table)-foreign key
5)o_id-primary key

specify the following constraints while alter table:-


1)add a default constraint on city as delhi

2)add check constraint on p_id>0

3)drop unique constraint order no from order table

4)try to delete a record from person table and find out the result

5)try to delete a record from order table and find out the result.

6)note down your observation from these two queries.


Assignment-6
Q1. Create table Department with fields:
Dno(Primary Key), Dname(Unique) , Dlocation

Q2. Create table Employee with fields:


Eno(Primary Key), Ename(Not Null), Salary, Designation, Dno(Foreign Key)

Q3. Insert 5 records in both tables


Department
Dno Dname Dlocation
10 Sales Noida
20 Finance Gurgaon
30 HR Delhi
40 Marketing Delhi
50 IT Gurgaon
Employee
Eno Ename Salary Designation
Dno
101 Akash 40000 Manager 30
102 Neha 30000 Executive 50
103 Kunal 25000 Executive 10
104 Saksham 60000 Manager 50
105 Dheeraj 50000 Team Leader 20

Q4. Display the details of the employee who draws maximum salary.

Q5. Display the details of those employees whose salary is greater than the average
salary in the organization.

Q6. Display the details of the employee whose Department location is Noida.

Q7. Display the Department Locations to which employees belong.

Q8. Increase the Salary of Employees by 1000Rs whose Designation is Manager.

Q9. Change the column name Designation to Job.

Q10. Delete the column Dlocation.


Assignment 7

1.Create the Department table with fields: Dno(Primary Key), Dname, Dloc
Insert the following values
Dno Dname Dloc
10 Accounts New York
20 Research Dallas
30 Sales Chicago
40 Operation Boston
50 Payroll Dallas
2. Create the Employee table with fields: Empno(Primary Key), Ename, Salary,
Commission, Deptno(Foreign Key),Mgrid
Insert the following values
Empno Ename Salary Commissio Deptno Mgrid
n
75 Jones 20000 20
76 Martin 30000 30 75
77 Blake 40000 1400 30 75
78 Ford 10000 20
79 Tummes 20000 5000 10 78
3. Create the SalGrade table with fields: Grade, Lowsal, Highsal
Insert the following values
Grade Lowsal Highsal
A 10000 19000
B 20000 29000
C 30000 50000
4. Display Empno, Salary,Deptname of employees
5. Use table Alias & solve the above query again
6. Display Empno., ename,Grade and salary that should be greater than lowsal
and less than highsal
7. Retrieve name of employees where employee is also a manager.
8. Display Empno, Ename, Dname ,Dloc of all the employees using outer join
9. Display Empno, Ename, Dname ,Dloc of all the departments using outer
join
10.Retrieve employee no, employee name of all the employees along with their
manager no and manager name if any
Assignment 8
(Creating tables with constraints,Groupingfuctions)
1. Create table hotel and insert 3 records for the following attributes:-Hotelno
(primary key), Hotelname, city

2. Create table Room and insert 3 records for the following fields:- Room
no(primary key), hotelno(foreign key), type of room, price

3. Create table guest and insert 3 records into table:- Guest no(primary key),
gname, gaddress

4. Create table booking and insert 3 records for the following fields- Hotelno -
foreign key),guestno(foreign key),datefrom,dateto,roomno

5. Find average price of a room

6. List name and address of guest with booking for a hotel in ‘delhi’ ordered by
name

7. Find total income of all rooms of the hotel in Mumbai

8. List names of guest at hotel TAJ

9. Increase price of rooms of TAJ to 10%

10. Count the no of rooms of each type

You might also like