0% found this document useful (0 votes)
178 views58 pages

Cs Practical Manas New

Here are the SQL commands for the given statements: (i) SELECT * FROM EMPLOYEE WHERE Name = 'John'; (ii) SELECT * FROM EMPLOYEE, SALARY WHERE EMPLOYEE.EmpId = SALARY.EmpId AND SALARY BETWEEN 40000 AND 70000; (iii) INSERT INTO SALARY VALUES ('S03', '2400', 45000); (iv) To update the salary of employee having EmpId 'E02' to 55000 UPDATE SALARY SET Amount = 55000 WHERE EmpId = 'E02'; (v) To display the employee name, designation, salary amount from both the tables. SELECT

Uploaded by

swyam sharma
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)
178 views58 pages

Cs Practical Manas New

Here are the SQL commands for the given statements: (i) SELECT * FROM EMPLOYEE WHERE Name = 'John'; (ii) SELECT * FROM EMPLOYEE, SALARY WHERE EMPLOYEE.EmpId = SALARY.EmpId AND SALARY BETWEEN 40000 AND 70000; (iii) INSERT INTO SALARY VALUES ('S03', '2400', 45000); (iv) To update the salary of employee having EmpId 'E02' to 55000 UPDATE SALARY SET Amount = 55000 WHERE EmpId = 'E02'; (v) To display the employee name, designation, salary amount from both the tables. SELECT

Uploaded by

swyam sharma
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/ 58

PRACTICAL FILE OF COMPUTER

SCIENCE

ASSISI CONVENT SCHOOL

Submitted by: Submitted to:


Ekta Sahni
Swyam Sharma

XIITH – E

Roll Number: 41

Swyam Sharma
41
12th E
Q1.

Consider the table STUDENT with the above


data and define the first column SID as primary
key, feed all the records in the table and then
answer the following queries in MySQL: -

a) To count the number of students in each section.


b) To display the names of the student who got
“Excellent” remark in their project.
c) To increase the marks of the student “Raj” in CS by 5.
d) The display the names of the students ending with
“a”.
e) To display the details of the student whose IP marks
are in the range 25 to 35.
f) To display the name of the student who secured
maximum marks in IT>
g) To insert a new row with values
(105,’Shreya’,12,’D’,40,38,’Excellent’)
Swyam Sharma
41
12th E
A1.
a)

b)

c)

d)

Swyam Sharma
41
12th E
e)

f)

g)

Swyam Sharma
41
12th E
Q2.

1. To retrieve all the information about the


teacher with id 104.
2. To find the names of all teachers earning more
than 30000.
3. To display Teacher_id, First name, Last name
and Dept_no of teachers who belong to department 1.
4. To retrieve names of all teachers and the names
and numbers of their respective departments.
5. To display Department numbers corresponding
to department having male teachers.
6. To list all department names with no repetition.
7. To list first name, last name in alphabetical
order.
8. To retrieve name of teachers having at least 6
characters in first name.
Swyam Sharma
41
12th E
A2.
1.

2.

3.

Swyam Sharma
41
12th E
4.

5.

6.

Swyam Sharma
41
12th E
7.

8.

Swyam Sharma
41
12th E
Q3.
Lab exercises:
Consider the following table named "GYM"
with details about Fitness products
being sold in the store.
Table Name: GYM
PrCode stores Codes of Products
PrName stores names of Products
(Unit Price is in Rs.)

Swyam Sharma
41
12th E
Write SQL statements to do the following:

a) Display the names of all the products in the store.


b) Display the names and unit price of all the products
in the store
c) Display the names of all the products with unit price
less than Rs.20000.00
d) Display details of all the products with unit price in
the range 20000 to 30000
e) Display names of all products by the manufacturer
"Fit Express"
f) Display all rows sorted in descending order of unit
price.
g) Add a new row for product with the details: "P106",
"Vibro Exerciser", 23000, manufacturer:
"Avon Fitness".
h) Change the Unit Price data of all the rows by
applying a 10% discount reduction on all the products.
i) Display details of all products with manufacturer
name starting with "A"

Swyam Sharma
41
12th E
A3.

a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

f)

g)

Swyam Sharma
41
12th E
h)

i)

Swyam Sharma
41
12th E
Q4.

Consider the following Employee table:


Table Name: Employee

The primary key of this table is Employee ID and Manager ID is a foreign


key that references Employee ID.

Write SQL commands for the following:

(a) Create the above table.


(b) Insert values as shown above.
(c) Delete the Employee having Employee ID 1217.
(d) Update the salary of "Amyra" to 40000.
(e) Alter the table Employee so that NULL values are not
allowed for Age column.
(f) Write a query to display names and salaries of those
employees whose salary are greater than 20000.
Swyam Sharma
41
12th E
(g) Write a query to display details of employees who are not
getting any bonus.
(h) Write a query to display the names of employees whose
name contains "a" as the last alphabet.
(i) Write a query to display the name and Job title of those
employees whose Manager ID is 1201.
(j) Write a query to display the name and Job title of those
employees whose Manager is "Amyra".
(k) Write a query to display the name and Job title of those
employees aged between 26 years and 30 years (both
inclusive)

Swyam Sharma
41
12th E
A4.
a)

b)

c)

d)

Swyam Sharma
41
12th E
e)

f)

g)

Swyam Sharma
41
12th E
Q5. Study the following tables SENDER and
RECIPIENT. Write SQL commands for the questions (i)
to (v)

(i) To display the details of those senders whose city is


“New Delhi”.
(ii) To update the new name of H Sinha as “Raman
Singh”.
(iii) To display the sender details in ascending order of
SenderName.
(iv) To display the names of the sender starting with “R”,
(v) To display the sender name, sender address from
table sender and recname, recaddress from the table
recipient with their corresponding matching senderid.
(vi) To display the number of sender belonging to each
city.

Swyam Sharma
41
12th E
A5.
a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

Swyam Sharma
41
12th E
Q6.
Consider the following tables CABHUB and
CUSTOMER.

Swyam Sharma
41
12th E
Write SQL commands for the statements (i) to
(v).
(i) To display the names of all the white coloured
vehicles from the cabhub table.

(ii) To display name of vehicle, make and capacity of


vehicles in ascending order of their seating capacity.

(iii) To increase the charges by 5.

(iv) To add a row to the table customer with the values


(5, “Asha”, 102).

(v) To display the vehicle name, cname from the tables


cabhub,
customer.

(vi) Count the number of cars of individual colours.

(vii) Display vcode, vehiclename, make and customer


name from
the table customer and vehicle with their
corresponding matching id of vcode.

Swyam Sharma
41
12th E
A6.
a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

f)

Swyam Sharma
41
12th E
Q7.
Consider the following tables PRODUCT and
CLIENT

Swyam Sharma
41
12th E
Write SQL commands for the statements (i) to
(v).

i. To Display of all those clients from the table


CLIENT whose city is Delhi.
ii. To Display the details of the product whose price
is in the range of 50 to 100.
iii. To Increase the price by Rs. 200 in the table
Product.
iv. To Display the product name in the ascending
order in the table Product.
v. To display product name, manufacturer, city from
the table Product and Client.
vi. To display the number of clients belonging to each
city.
vii. To display the maximum, minimum price from
the table product.

Swyam Sharma
41
12th E
a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

f)

Swyam Sharma
41
12th E
g)

Swyam Sharma
41
12th E
Q8. Consider the following tables EMPLOYEE and SALARY.

Swyam Sharma
41
12th E
Write SQL commands for the statements (i) to (v)

(i) To display the details of those Employees


whose name is “John”

(ii) To display the details of all the employees


whose salary is in the range 40000 to
70000.

(iii) To add a new row with the values “2400,


45000, S03” in the table salary.

(iv) To display employee Name starting with


letter ‘R’ from table Employee.

(v) To increase the price of all the product by


5000

Swyam Sharma
41
12th E
a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

Swyam Sharma
41
12th E
10) Write SQL commands for (a) to (b) on the
basis of relations given below:

a) To show the books of FIRST PUBL. Publishers


written by P. Purohit.
CODE: SELECT FROM books WHERE publishers="FIRST
PUBL' AND author_name='P. Purohit

b) To display cost of all the books published by


FIRST PUBL
CODE: SELECT price FROM books WHERE publishers='FIRST
PUBL.";

Swyam Sharma
41
12th E
10)

Write SQL statements for the queries (a) to (d)


a) To display the ClientName and City of all Mumbai and Delhi-
based clients in Client table.
CODE: SELECT clientname, city FROM client WHERE
city="Mumbai' OR city="Delhi";

b) Increase the price of all the products in Product table by 10%.


CODE: Update product SET price-1.1"price;

Swyam Sharma
41
12th E
c) To display the Product Name, Manufacturer, Expiry
Date of all the products that expired on or before 2010-
12-31

CODE: SELECT productname, manufacturer, expirydate


FROM product WHERE expirydate=' 2010-12-31";

d) To display C ID, ClientName, City of all the clients


(including the ones that have not purchased a product)
and their corresponding Product Name sold.

CODE: SELECT c_id, clientname, city, productname


FROM client LEFT JOIN product ON
product.p_id=client.p_id;

Swyam Sharma
41
12th E
11) Consider the following tables STORE and
SUPPLIERS.

Write SQL commands for the statements (a) to (c) .


a) To display details of all the items in the Store table in ascending order
of LastBuy.
CODE: SELECT FROM store ORDER BY lastbuy ASC;

b) To display itemno and item name of those items from Store table
whose rate is more than 15 rupees SELECT itemno, item FROM store
WHERE rate>15;
CODE: SELECT itemno, item FROM store WHERE rate>15;

Swyam Sharma
41
12th E
Q 12 Consider a database LOANS with the
following table:

Answer the following questions.


a) Display the sum of all Loan Amounts whose Interest rate is
greater than 10.
CODE: SELECT sum(loan) FROM loans WHERE int_rate>10.00;

b) Display the Maximum Interest from Loans table.


CODE: SELECT max(interest) FROM loans;

c) Display the count of all loan holders whose name ends with
'Sharma'.
CODE: SELECT count(*) FROM loans WHERE cust_name LIKE
'%Sharma';

d) Display the count of all loan holders whose interest is Null.


CODE: SELECT count(*) FROM loans WHERE interest IS NULL;

Swyam Sharma
41
12th E
Swyam Sharma
41
12th E
a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

f)

g)

Swyam Sharma
41
12th E
Swyam Sharma
41
12th E
a)

b)

c)

Swyam Sharma
41
12th E
d)

e)

f)

Swyam Sharma
41
12th E
Q15. Create Database School and table Studinfo
with columns rollnum, name and marks in MySQL
and insert five records of student by using python
and database connectivity coding.

CODE:

Swyam Sharma
41
12th E
OUTPUT:
BEFORE:

AFTER:

Swyam Sharma
41
12th E
Q16. Program to delete the marks of a students
on the basis of rollnum fetched from the user at
run time.

CODE:

Swyam Sharma
41
12th E
OUTPUT:

Swyam Sharma
41
12th E
Q 17 Write Menu Driven program in python to
demonstrate four major operations (add, fetch,
update, delete) in database school.

Swyam Sharma
41
12th E
Swyam Sharma
41
12th E
OUTPUT:

Swyam Sharma
41
12th E
Swyam Sharma
41
12th E
Q 18 ABC infotech Pvt Ltd. needs to store, retrieve and delete the
records of its employees. Develop an interface that provides front-
end interaction through Python, and stores and updates records
using MySQL. The operations on MySQL table "emp" involve reading,
searching, updating and deleting the records of employees.
(Database name company)

Swyam Sharma
41
12th E
(a) Program to read and fetch all the records
from emp table having salary more than
62000
CODE:

OUTPUT:

Swyam Sharma
41
12th E
(b) Program to update the records of employee by
increasing salary by Rs 1000 of all those employees who
are getting less than 80000
CODE:

OUTPUT:
BEFORE: AFTER:

Swyam Sharma
41
12th E
(c) Program to delete the records on the basis of
inputted salary.
CODE:

OUTPUT
BEFORE: AFTER:

Swyam Sharma
41
12th E
Q 19 Write a Menu Driven program in python to
implement all basic operations (PUSH, POP,
DISPLAY) of stack using list.

CODE:

OUTPUT:

Swyam Sharma
41
12th E
Q 20 Program to add, delete and display the
records of an employee using list.
CODE:

OUTPUT:

Swyam Sharma
41
12th E

You might also like