0% found this document useful (0 votes)
4 views18 pages

prac file cs

Uploaded by

ashjoddd7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views18 pages

prac file cs

Uploaded by

ashjoddd7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

ASSIGNMENT 5

Q6(I).Create the following tables PRODUCT and CLIENT. Write SQL


commands for the statements (a) to (d) and give outputs for SQL
queries (e) to (h)

Table: PRODUCT
P_ID ProductName Manufacturer Price

TP01 Talcum Powder LAK 40

FW05 Face Wash ABC 45

BS01 Bath Soap ABC 55

SH06 Shampoo XYZ 120

FW12 Face Wash XYZ 95

Table:- CLIENT
C_ID ClientName City P_ID

1 Cosmetic Shop Delhi FW05

6 Total Health Mumbai BS01

12 Live Life Delhi SH06

15 Pretty One Delhi FW12

16 Dreams Bangalore TP01

i. To display the details of those clients whose city is Delhi.


k. To display the ClientName, City from table Client, and ProductName
and Price from
table Product, with their corresponding matching P_ID.

l. To increase the price of all products by 10.


m. SELECT DISTINCT City FROM Client;

n. SELECT Manufacturer , MAX(price) , MIN(Price), COUNT(*)FROM


Product
GROUP BY Manufacturer;

o. SELECT ClientName , Manufacturer FROM Product P, Client C


WHERE C.P_ID = P.P_ID;
p. SELECT ProductName, Price * 4 FROM Product; WHERE P_ID =
‘TP01’ OR P_ID = ‘SH06’;

6. (II) Create the following tables WORKER and PAYLEVEL. Write


SQL commands for the statements (a) to (d) and give outputs for SQL
queries (e) to (h)

Table:- WORKER
ECODE NAME DESIG PLEVE DOJ DOB
L

11 Radhe Shyam Superviso P001 13-Sep-2004 23-Aug-1981


r

12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987

13 Fizza Operator P003 14-Jun-2009 14-Oct-1983

15 Ameen Mechanic P002 21-Aug-2006 13-Mar-1984


Ahmed

18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983

Table: PAYLEVEL
PLEVE PAY ALLOWANCE
L

P001 26000 12000


P002 22000 10000

7P003 12000 6000

a. To display the details of all WORKERS in descending order of DOB.

b. To display NAME and DESIG of those WORKERS, whose PLEVEL is


either P001 or P002.

c. To display the content of all the WORKERs, whose DOB is in


between ’19-JAN-
1984’ and ’18-JAN-1987’.
d. To add a new row with the following:
19, ‘Daya Kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-1984’

e. SELECT COUNT(PLEVEL), PLEVEL FROM WORKER GROUP BY


PLEVEL;

f. SELECT MAX(DOB), MIN(DOJ) FROM WORKER;


g. SELECT Name, Pay FROM WORKER W, PAYLEVEL P

h. SELECT PLEVEL, PAY + ALLOWANCE FROM PAYLEVEL


WHERE PLEVEL = ‘P003’;
ASSIGNMENT 6
(Python-MySQL Connectivity)

Integrate SQL with Python by importing


MySQLdb/mysql.connector

1. Create a table Student in a database ‘project’


as shown below:
RollNo int primary key
Name varchar(20)
Total int
Grade varchar(3)

a. Input Rollno, Name, Total marks and Grade


and insert the record in a table Student.

b. Input Rollno and update the corresponding


record in a table Student with the value
entered by the user.

c. Display all the records from a table Student.


a. Input Rollno, Name, Total marks and Grade and insert the record in
a table Student.

b. Input Rollno and update the corresponding record in a table Student


with the value
entered by the user.
2. Consider the table Product with
following structure.

P_ID | ProductName | Manufacturer | Price


1 | Laptop | Dell | 1000.0
2 | Phone | Apple | 800.0
3 | Tablet | Samsung | 600.0

Write Python code to increase the price of


all products by 50.
Write Python code to increase the price of all products by 50.

3. Create a table Student in a database ‘project’ as shown


below:
RollNo int primary key
Name varchar(20)
Total int
Grade varchar(3)
a. Input Rollno and display the corresponding information from
the table Student.

b. Input Rollno and delete the corresponding record from the


table Student.

c. Display all the records of a grade entered by the user


from the table Student.

d. Display all the records in descending order of total marks


from the table St
A.

B.
C.

D.

You might also like