Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

SRIMATHI SUNDARAVALLI MEMORIAL SCHOOL, CHENNAI 600 063

LAB PROGRAMS (16-25)


2023-2024

PGM NO: 16 SQL COMMAND - 1

Consider the following tables FACULTY and COURSES . Write SQL commands for the
statements (i) to (vi) and give outputs for SQL queries (vii) to (x).

TABLE:FACULTY

F lD Enamc Lnamc Hire date Sala ry


102 Amit Mishra 12-1 0-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni I 8-5-200 I 14000
105 Rashmi Malhotra 11 -9-2004 11000
106 Sulekha Srivastava 5-6-2006 IOOOO
TABLE:COURSES

CID F ID Cnamc Fees


C2 1 102 Grid Computin g 40000
C22 106 System Des ign 16000
C23 104 Computer Sccuri tv 8000
C24 106 Human Biolo_gy 15000
C25 102 Comnutcr Network 20000
C26 105 Vi sual Bas ic 6000

GIVE QUERY:

(ii To dis play details of those Faculties whose salary is greater than 12000.
(ii) To display the deta ils of courses whose fees is in the range of 15000 to 50000
(both values included).
(iii) To increase the fees by 500 for "System Design" and "Human Biology" Courses.
(iv) To display d etails of those courses which are taught by 'Sulekha' in descending
order ofcourses name.
(v) To display details of those Faculties whose First name starts with 'R'.
(vi) To display First Name, Last Name, Salary, Course Name and Fees from both the
tables, whose salary is greater than 10000, Hire_date is a bove '0 1-01 -2000' and
their Last name end with 'a'.

Page 1 of 10
GIVE OUTPUT:

lvii) SELECT COUNT(DISTINCT F_ID) FROM COURSES ;


lviii) SELECT MIN(SALARY) FROM FACULTY,COURSES
WHERE COURSES.F_ID =FACULTY.F_ID;
(ix) SELECT COUNT(*), MAX(HIRE_DATE), MIN(FNAME)

FROM FACULTY, COURSES

WHERE SALARY>= 12000 AND FEES< 50000 AND

COURSES.F_ID = FACULTY. F_ID;

(x) SELECT * FROM FACULTY


WHERE HIRE_DATE BETWEEN '2001-01-01' AND '2005-12-3 1';

PGM.NO.: 17 SQL COMMAND - 2

Study the following tables CLIENT and BILL and write SQL commands for the
questions (i) to (vi) and give outputs for SQL queries (vii) to (x) .

TABLE: CLIENT
CUST_NAME ADDRESS PHONE_NO CITY
CUST_ID
Pritam Sharrr.ia 12,M.G Road 71274250 Bangalore
C007
Delhi
coos Sutopa 14/1 PritamPura 41206819

AnuragBasu 15A, Park Road 612819 21 Kolkata


C0lO
Hrithik 7 /2 VasantKunj 26121949 Delhi
C012
25014192 Bangalore
C013 Firoz Shah 2, Servamali road
Mumbai
-
Vinod Nagpal 46-a Navi Mumbai 64104944
C025
41,Dwarka 42101619 Delhi
C027 Sarneer
16/A K.G Marg 27220012 Bangalore
C002 Pasunjit Bose
13/ A Versova 41612181 Mumbai
C035 Aarnina Begum

Pa ge 2 of 10
X ABLE,BILL
ORD_ID CUST_ID ITEM ORD_DATE QTY PRICE
7002 C007 Pizza 2 0-NOV-07 1 249 .50
7003 C013 Garlic Bread 24-OCT-05 3 7 5 .75
7004 C012 Pasta 03-MAR-07 4 173.00
7005 C0lO Ice Cream 0l -JAN-08 30 195.75
7006 C035 Pizza 02-MAR-06 4 249.50
7009 C035 Garlic B read 02-MAR-08 2 75.75
7010 C01 3 Brownie 0 4-MAY-07 4 40.50
7011 C014 Ice Cre am 0 2 -JU N-08 5 195.75
7012 C002 Pizza 01-FEB -08 7 249.50

GIVE QUERY:

(i) To display a report containing cust_id, cust_name, Item, qty, price and bill
amount. Bill amount is calculated as qty*price.
(ii) To display how many customers have ordered Pizza in the month of March.
(iii) To count the number of customer who have ordered item worth more than 1700 .
Total amount = qty* price.
.-----===

(iv) To display the name of customer along with city in alphabetical order of city.
(v) To display the count of each item from BILL table .
(vi) To display the cust_name, address, item, ord_date for those quantities which are
more than 3.

GIVE OUTPUT:

(vii) SELECT CUST_NAME, CITY, ORD_DATE FROM CLIENT A, BILL B


WHERE A.CUST_ID = B.CUST_ID;
(viii) SELECT CUST_NAME FROM CLIENT
WHERE CUST_ID IN( SELECT CUST_ID FROM BILL
WHERE (YEAR(ORD_DATE) ='2008')) ;
(ix) SELECT CITY ,COUNT(*) FROM CLIENT
GROUP BY CITY;
(x) SELECT DISTINCT (ITEM) FROM BILL;
Page 3 of 10
PGM.NO.: 18 SQL COMMAND - 3
Study the following tables ITEM and CUSTOMERand write SQL commands for the
questions (i) to (vi) and give outputs forSQL queries (vii) to(x) .

TABLE: ITEM

~ IITEMNAME [[MANUFACTURER IIPRICE


I
E J[Laptop
Personal Computer
IABC

IIABC
IE J
E]
1155000
I
E]
Personal Computer

Personal Computer
IXYZ
1 I 32000

!COMP l1 37000 I
~ [Laptop I PQR 1157000
I

TABLE: CUSTOMER

,C_ID IICUSTOMERNAME I CITY I~


E J[tt.Singh 11Mumbai J~
C IR.Pandey [ Delhi [~

L Jjc.Sharma I Delhi J~
L J[K.Agarwalh [jBangalore [~

GIVE QUERY:

(i) To display the details of those Customers whose city is Delhi.


(ii) To display the details of Item whose Price is in the range of 35000 to 55000
(Both values included) .
(iii) To display the CustomerName, City from table Customer, and ItemName and
Price from table Item, with their corresponding matching I_ID.

Page 4 of 10
(iv) To increase the Price of all Items by 1000 in the table Item.
(v) To display the customer name and manufacturer of the highest priced item.

(vi) To display the number of customers from each city.

GIVE OUTPUT:
(vii) SELECT DISTINCT CITY FROM CUSTOMER;
(viii) SELECT ITEMNAME, MAX(PRICE), COUNT(*) FROM ITEM
GROUP BY ITEMNAME;
(ix) SELECT CUSTOMERNAME, MANUFACTURER FROM ITEM, CUSTOMER
WHERE ITEM .P_ID=CUSTOMER.P_ID
(x) SELECT ITEMNAME, PRICE * 100 FROM ITEM
WHERE MANUFACTURER = 'ABC ';

PGM.NO.: 19 SQL COMMAND - 4

Consider the following tables TEACHER and SALARY. Write SQL commands fo r the
statements (i) to (vii) and give outputs for SQL queries (viii) to (xii) .

TABLE: TEACHER

SID TNAME DEPT GENDER DOB EXPERIENCE

ACCOUNTS M 1975-12-25 12
101 SIDDHARTH

PHYSICS M 1993-01-1 3
104 JOHN 5

NAMAN CHEMISTRY M 1994-08-12 4


107

114 NUPUR ENGLISH F 1978-07-09 15 ,

109 JANVI PHYSICS F 1975-05-01 13

105 SELVA ACCOUNTS M 1964-06-21 24


117 JANAK.I COMPUTER F 1967-03-17 18
111 BINOY ACCOUNTS F 1987-09-15 8
130 AMRESH COMPUTER M 1983- 10-05 12

Page 5 of 10
TABLE: SALARY

SID BASIC ALLOWANCE DA


101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 1000
109 42000 1700 200
105 18900 1690 300
130 21700 2600 300

GIVE QUERY:

(i) To display the names and gender of all the staff who are in Accounts department

and having more than 8 years of experience.


(ii) To display the no of teachers, maximum and minimum BASIC in SALARY.

(iii) To display the names and dept of all staff who doesn't have 'a' in their name.

(iv) To display the SID and Department of the teachers in the descending order
of their Experience.
(v) To display the report containing SID, teacher's name, department, gender, Gross
Salary (BASIC+ ALLOWANCE+ DA) and PF (BASIC*0.12).

(vi) To display the details of the teachers who have their DOB in 1975 and Experience
inore than 12.

GIVE OUTPUT:

(vii) SELECT TNAME, DEPT


FROM TEACHER T, SALARY S
WHERE T.SID=S.SID AND 5*DA>ALLOWANCE;

(viii) SELECT * FROM TEACHER

WHERE DEPT IN ('English', 'Physics ', Accounts') AND


DOB BETWEEN '1965-01-01' AND '1975- 12-31';

Page 6 of 10
(ix) SELECT SUM (BASIC+ALLOWANCE+DA) AS "TOTAL EXPENDITURE",

AVG (BASIC+ALLOWANCE+DA) AS "AVERAGE SALARY"


FROM SALARY;

(x) SELECT DISTINCT (DEPT) FROM TEACHER;

(xi) SELECT TNAME 'MOST EXPERIENCED TEACHER'

FROM TEACHER
WHERE EXPERIENCE = (SELECT MAX (EXPERIENCE) FROM TEACHER);

PGM.NO.: 20 SQL COMMAND - 5

Study the following tables COMPANY and CUSTOMERand write SQL commands for
the questions (i) to (vi) and give outputs forSQL queries (vii) to(x).

TABLE: COMPANY

-
CID NAME CITY PRO DUCTNAME

111 SONY DELHI TV


222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY MADRAS MOBILE
666 DELL DELHI LAPTOP

TABLE: CUSTOMER

CUSTID NAME PRICE QTY CID


101 ROHAN SHARMA 70000 20 222
102 DEEPAK KUMAR 50000 10 666
103 MOHAN KUMAR 30000 5 111
104 SAHIL BANSAL 35000 3 333
105 NEHA SONI 25000 7 444
106 SONAL AGGARWAL 20000 5 333
107 ARUN SINGH 50000 15 666

GIVE QUERY:

(i) To display those company name which are having price less than 30000.
Page 7 of 10
(ii) T0 ct·isp1ay the name of the companies in reverse alphabetical order.

(iii) To increase the price by 1000 for those customer whose name starts with 'S'.

(iv) To add one more column totalprice with decimal value to the table customer.

(v) To display the details of company where productname as mobile.

(vi) To display all the details from company and customer using natural join whose

price value is above 40000.

GIVE OUTPUT:

(vii) SELECT S.CID, A.NAME, (PRICE*QTY)-(PRICE*0.02) AS GROSS


FROM COMPANY S, CUSTOMER A
WHERE S.CID = A.CID AND QTY > 5;
(viii) SELECT * FROM CUSTOMER
WHERE (NAME LIKE '%A' OR NAME LIKE 'S%') AND PRICE <75000 ;
(ix) UPDATE CUSTOMER
SET QTY= QTY+ 1
WHERE CID IN(lll,444,555,333)
(x) SELECT CID, NAME, CITY
FROM COMPANY
WHERE PRODUCTNAME = 'MOBILE';

PGM.NO.: 21 PYTHON SQL CONNECTMTY - 1


r
1) Write a program in python to create a table stationary with 5 records . Retrieve and
display all the records whose price is below 10.

TABLE:STATIONARY

S ID StationaryName Company Price

DPOI Dot Pen ABC 10


PL02 Pencil XYZ 6
EROS Eraser XYZ 7
PLOI Pencil CAM 5
GP02 Gel Pen ABC 15

Page 8 of 10
PGM.NO.: 22 PYTHON SQL CONNECTMTY - 2
Write a menu driven Python program to implement the following operations on a

database using user defined functions.


• Create Database - STUDENT
• Create Tables
o STUDENT DETAILS - ID, NAME, AGE, CLASS, SECTION
o MARKS DETAILS - ID, EXAMNAME, SUBl, SUB2, SUB3, SUB4,

SUB5,TOTAL,AVERAGE,GRADE
• Insert Data- MINIMUM 5 RECORDS PER TABLE
• Update Data - CHANGE MARKS BASED ON ID
• Display Data - Display the details of both the tables.

PGM.NO.: 23 PYTHON SQL CONNECTMTY - 3


Write a menu driven Python program to implement the following operations on a

database using user defined functions.


• Create Database - CUSTOMER
• Create Tables
o CUSTOMER DETAILS - CID, CNAME, ADDRESS , PHONENO
o PURCHASE DETAILS - PID, PURCHASE DATE, NO.ITEMS,
TOTALAMOUNT, CID
• Insert Data - MINIMUM 5 RECORDS PER TABLE
• Search Data - Search data based on CID and PURCHASE DATE.
• Display Data - Display the details of both the tables.

PGM.NO.: 24 PYTHON SQL CONNECTMTY - 4


Write a menu driven Python program to implement the following operations on a
database using user defined functions.
• Create Database - BOOKSTORE
• Create Tables
o BOOK DETAILS - ISBN, BOOKNAME, AUTHOR, PUBLISHER,
YEAR, PRICE, QTY
o CUSTOMER DETAILS CID, CNAME, PHNO, ISBN,
PURCHASEDATE, PURCHASEQTY

Page 9 of 10
• Insert Data - MINIMUM 5 RECORDS PER TABLE

• SCALAR QUERY - CALCULATE THE TOTAL AMOUNT FOR EACH


CUSTOMER BASED ON ISBN, PURCHASEQTY AND PRICE.
• Display Data -Display the details of both the tables.

PGM.NO.: 25
PYTHON SQL CONNECTMTY - 5
Write a menu driven Python program to implement the following operations on a
database using user defined functions .
• Create Database - FLIGHT RESERVATION
• Create Tables
o FLIGHT DETAILS FL_NO, AIRLINENAME, SOURCE,
DESTINATION, NO_FLIGHTS, NO_STOPS
o PASSENGER DETAILS - PID, PASSENGER NAME, FL_NO,
JOURNEY DATE, TICKET PRICE, TRAVEL CLASS
• Insert Data - MINIMUM 5 RECORDS PER TABLE
• Delete Data - Delete Flight & Passenger details based on FL_NO.
• Delete both tables permanently.

****************

Page 10 of 10
OUTLINE FOR PROJECT WRITE UP

1.COVERPAGE (according to the sample provided).


2.BONAFIDE CERTIFICATE(to be issued by the School)

3.ACKNOWLEDGEMENT

(School Management, Principal,Teacher(s), Resource Person(s)


and others who have contributed/rendered guidance for the
completion of the project)
4.TABLE OF CONTENTS(must be in the following format)

S.No. CONTENT PAGENO.


1
1. OVERVIEW OF PYTHON & MySQL

5.0VERVIEW OF PYTHON & MySQL (must not exceed two pages).


6.ABSTRACT (must not exceed one page).
(Synopsis of the project; must include the reason(s) for choosing
this project)

?.REQUIREMENTS (Hardware & Software) along with instructions


Regarding how to install the project and use it, are to begiven. It
should be a sort of USERMANUAL.
a.MODULES (Modules used in the project and their purpose).
9.DATA STRUCTURES (used with explanation.(lf any))
10.BUILT-IN FUNCTIONS (used in the project and their need for usage.)
11 .SOURCE CODE (Listing of all the programs prepared as part of the
project.)
12.0UTPUT (Dumps of all the outputscreens; each page can have
two output screenshots; maximum 5 sheets enough).

13.CONCLUSION (Must not exceed one page; specify the problems


faced in your project).
14.FUTURE OUTLOOK (List out the possible updations in your app.)
15.REFERENCES (Books & Web links)
Books: Title of the book, Author, Edition, Publisher(Year of Edition)
Weblinks: Link to be copied from the Address Bar (retrieved
dd/mm/yyyy)

PS: Please note that a White chart paper must be included after the
'" Cover Page and after the References in the Final copy.
SPECIFICATIONS

1.FONTSTYLE:
D Headings:'BookW\aV\. Old Sty(e'and in Bold.
D Body of the Report:'Book'11aV\. Old Style'
2.FONT SIZE:

Main Heading: 16

Side Heading:14 (Double Underlined)

Body:12

3.LINESPACING:1 ;5

4.ALIGNMENT: Justify (Except Source Code)

5.PAGE BORDER: Simple style

6.PAGE NUMBER:' X of Y'format (Ex.: 1 of 170)

7.HEADER/FOOTER: Not to be inserted

a.Running project Source Code to be submitted in a PenDrive


along with relevant information.

9.PRINT OUT: [FINAL COPY]


.Black & White, A4Sheet, only one side (left side blank) .
.'Co(our priV1.t out'-as per requirement (studeV\.t5 option) .
.Each topic in the ''TableofContents" should begin in a
Fresh page .
.The final copy should be spiral bind with a white
Transparent sheet at the front and back of the document.
SAMPLE COVER PAGE

TITLE OF THE PROJECT


<Bookman Old Style - Size 20-Bold- Caps-1.5 line spacing>

Picture related to the topic

(In Colour)

A COMPUTER SCIENCE PROJECT REPORT


<Bookman Old Style (Bold) - Size 18 - Caps-1.5 line spacing>

Submltted By
<Style - Bookman Old Style(bold) Size-14 linespacing-1.5 line>
NAME OF THE STUDENT, CLASS XII
<BookmanOldStyle(Bold) 18-Caps-Bold-1.5Iinespacing> ·

SRIMATHI SUNDARAVALLI MEMORIAL SCHOOL


CHENNAI
<Bookman Old Style (Bold)- Size 14- Caps- Single Line spacing>

You might also like