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

Practical File Term 2 Computer

Here are the SQL queries for the given statements: (i) To display the description and price of all dresses launched after 1st January 2008 SELECT DESCRIPTION, PRICE FROM DRESS WHERE LAUNCHDATE > '01-JAN-08'; (ii) To increase the price of all dresses made of material having code 'M001' by 10% UPDATE DRESS SET PRICE = PRICE * 1.1 WHERE MCODE = 'M001'; (iii) To display the description of dresses having price between Rs. 1000 to Rs. 1500 SELECT DESCRIPTION FROM DRESS WHERE PRICE BETWEEN 1000 AND 1500; (iv) To delete

Uploaded by

Lakshya Sahni
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)
221 views

Practical File Term 2 Computer

Here are the SQL queries for the given statements: (i) To display the description and price of all dresses launched after 1st January 2008 SELECT DESCRIPTION, PRICE FROM DRESS WHERE LAUNCHDATE > '01-JAN-08'; (ii) To increase the price of all dresses made of material having code 'M001' by 10% UPDATE DRESS SET PRICE = PRICE * 1.1 WHERE MCODE = 'M001'; (iii) To display the description of dresses having price between Rs. 1000 to Rs. 1500 SELECT DESCRIPTION FROM DRESS WHERE PRICE BETWEEN 1000 AND 1500; (iv) To delete

Uploaded by

Lakshya Sahni
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/ 31

DATABASE MANAGEMENT

1.CREATE DATABASE :

2.USE DATABASE:

3.CREATE TABLE:

4.INSERT VALUES:

Page 1
5.SELECT :

Page no 2

6.ALTER TABLE(ADD ATTRIBUTES ) :


7.ALTER TABLE(DROP ATTRIBUTE):

Page 3
8.ALTER TABLE(EDIT):

9.UPDATE TABLE :

Page 4
10.ORDER BY

11.DELETING :

12.GROUP BY:

Page 5
13.MAXIMUM

14.AVERAGE

Page 6
PYTHON MY SQL CONNECTIVITY
1. Write a program in python to connect my sql
with python and insert records.
Code :

Output :

Database:

(12)
2. Write a program in python to connect my sql
with python and Search records.
Code :

Output :

(13)
PYTHON PROGRAM FOR DATA
STRUCTURES
1.Python Program to implement Stack Operations.

Page 9
Page 10
Output :

Page 11
Certificate
This is to certify that Lakshya Sahni of class XII-C of Bedi
International school has completed his practical file under my
guidance. He has taken proper care and shown utmost sincerity
in completing this project. I certify that this project is upto my
expectations and as per the guidelines issued by CBSE.

Teacher’s Signature Principal’s Signature


-------------------- --------------------
s.no Particulars Pageno.
1 SQL Queries (Database Management) 1-11

2 Python Mysql Connectivity Programs 12-13


3 Stack Implementation Program 14-18

Index

ACKNOWLEDGEMENT
I would like to express my special thanks of
gratitude to my teacher Dr.Amoli Chakraborty as
well as our principal Mrs.J.K Sawhney who gave me
the golden opportunity to do this Practical File
which also helped me in doing a lot of Research and
i came to know about so many new things I am
really Thankful to them.

Thanks&Regards
Lakshya Sahni
XII-C

SQL Queries and Questions


1.Given following tables for Database Library :
Book_i Book_Nam Author Publishe Pric Type Qt
d e Name rs e y
C0001 Fast Cook Lata EPB 355 Cooke 5
Kapoor ry
F0001 The Tears William First 650 Fiction 20
Hopkins Publ.
T0001 My First C+ Brain&Broo EPB 350 Text 10
+ ke
T0002 C++ A.W TDH 350 Text 10
Brainworks Rossaine
F0002 Thunderbo Anna First 750 Fiction 50
lts Roberts Publ.
Table : BOOKS
Table : ISSUED
Book_id Quantity_Issued
T0001 4
C0001 5
F0001 2

(1)
Write SQL Queries for
(a) To Show Book Name,Author Name and Price of books
of First Publ. Publishers.
(b) To Display the names from books of Text type.
(c) To Display the names and price from Books in
ascending Order of Their Price.
(d) To increase the price of all books of EPB Publishers by
50.
(e) To Display Book_Id,Book_Name and Quantity_Issued
for all books which have been issued.
(f) To insert a new row in the table Issued having the
Following data : “F0003”,1
Queries :
(a) SELECT Book_Name,Author_Name,Price
FROM Books
WHERE Publishers =”First Publ.”;
(b) SELECT Book_Name
FROM Books
WHERE Type=”Text”;
(c) SELECT Book_Name, Price
FROM Books
ORDER BY Price ;
(d) UPDATE Books
SET Price=Price+50
WHERE Publishers =”EPB”;
(e) SELECT Books.Book_Id,Book_Name,Quantity_Issued
FROM Books,Issued
WHERE Books.Book_Id = Issued.Book_Id;
(2)
(f) INSERT INTO Issued
VALUES(“F0003”,1);

(3)
2.Consider the following DEPT and WORKER tables.Write SQL
Queries for the Following.
Table : DEPT
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table : WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013- 1991-09- MALE D01
09-02 01
1002 Ryma Sen 2012- 1990-12- FEMALE D03
12-15 15
1003 Mohitesh 2013- 1987-09- MALE D05
02-03 04
1007 Anil Jha 2014- 1984-10- MALE D04
01-17 19
1004 Manila 2012- 1986-11- FEMALE D01
Sahai 12-09 14
1005 R SAHAY 2013- 1987-03- MALE D02
11-18 31
1006 Jaya Priya 2014- 1985-06- FEMALE D05
06-09 23

(4)
(i) To display Wno, Name, Gender from the table WORKER in
descending order of Wno.
(ii) To display the Name of all the FEMALE workers from the
table WORKER.
(iii) To display the Wno and Name of those workers from the
table WORKER who are born between ‘1987-01-01’ and
‘1991-12-01’.
(iv) To count and display MALE workers who have joined after
‘1986-01-01’.
QUERIES :
(i) SELECT Wno,Name,Gender FROM Worker
    ORDER BY Wno DESC;
(ii) SELECT Name FROM Worker
     WHERE Gender=’FEMALE;
(iii) SELECT Wno, Name FROM Worker
     WHERE DOB BETWEEN ‘19870101’ AND ‘19911201;
(iv) SELECT COUNT(*) FROM Worker
      WHERE GENDER=’MALE’ AND DOJ > ‘19860101;

(5)
3. Consider the following table Employee and salary.Write Sql
Commands .
TABLE : Employee
Eid Name Depid Qualification Sex
1 Deepali Gupta 101 MCA F
2 Rajat Tyagi 101 BCA M
3 Hari Mohan 102 B.A M
4 Harry 102 M.A M
5 Sumit Mittal 103 B.Tech M
6 Jyoti 101 M.tech F
TABLE: Salary
Eid Basic D.A HRA Bonus
1 6000 2000 2300 200
2 2000 300 300 30
3 1000 300 300 40
4 1500 390 490 30
5 8000 900 900 80
6 10000 300 490 89
(i) To Display Frequency of Employees department
Wise .
(ii) To list the names of those employees only whose
name starts with ‘H’.
(iii) To add a new column in salary table.The Column
name is Total_Sal.
(iv) To Store the corresponding values in the Total_sal
column
Queries
(i) Select Depid , count( Eid ) from Employee group by
Depid ;
(6)
(ii) Select Name from Employee where Name like “H%”;
(iii) Alter table Employee add column Total_Sal integer;
(iv) Update Employee
Set Total_sal = Basic + D.A. + HRA + Bonus;

(7)
4.In a Database There are two tables given below :
TABLE : EMPLOYEE
EMPLOYEEID NAME SALES JOBID
E1 SUMIT SINHA 1100000 102
E2 VIJAY SINGH TOMAR 1300000 101
E3 AJAY RAJPAL 1400000 103
E4 MOHIT RAMNANI 1250000 102
E5 SHAILJA SINGH 1450000 103
TABLE : JOB
JOBID JOBTITLE SALARY
101 President 200000
102 Vice President 125000
103 Administration Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
106 Sales Manager 80000
Write SQL Queries for the following :
(i) To display employee ids,names of employees,job ids
with corresponding job titles.
(ii) To display names of employees,sales and
corresponding job titles who have achieved sales
more than 1300000.
(iii) To display names and corresponding job titles of
those employees who have’SINGH’ in their Names .
(iv) Identify Foreign Key in Table EMPLOYEE.

(8)
Queries :
(i) SELECT EMPLOYEEID , NAME , EMPLOYEE.JOBID ,
JOBTITLE FROM EMPLOYEE  NATURAL  JOIN ON JOB ;
(ii) SELECT NAME , SALES , JOBTITLE  FROM EMPLOYEE ,
JOB WHERE EMPLOYEE.JOBID = JOB.JOBID AND SALES
> 1300000 ;
(iii) SELECT NAME , JOBTITLE FROM EMPLOYEE , JOB
WHERE EMPLOYEE.JOBID = JOB.JOBID AND NAME
LIKE “%SINGH%” ;
(iv) JOBID

(9)
5.Consider the Following Tables DRESS and MATERIAL.write
SQL Commands for the statements i to iv .
DCODE DESCRIPTION PRICE MCODE LAUNCHDATE
10001 FORMAL SHIRT 1250 M001 12-JAN-08
10020 FROCK 750 M004 09-SEP-07
10012 ONFORMAL 1450 M002 06-JUN-08
SHIRT
10019 EVENING GOWN 850 M003 06-JUN-08
10090 TULIP SKIRT 850 M002 31-MAR-07
10023 PENCIL SKIRT 1250 M003 19-DEC-08
10089 SLACKS 850 M003 20-OCT-08
10007 FORMAL PANT 1450 M001 09-MAR-08
10009 INFORMAL PANT 1400 M002 20-OCT-08
10024 BABY TOP 650 M003 07-APR-07
TABLE : MATERIAL
MCODE TYPE
M001 TERELENE
M002 COTTON
M004 POLYSTER
M003 SILK

(i)To Display DCODE and DISCRIPTION of each dress in


ascending order of DCODE.
(ii) To Display the details of all the dresses which have
LAUNCHDATE in between 05-DEC-07 AND 20-JUN-08
(iii) To display the average PRICE of all the dresses which are
made with the material with MCODE as M003.
(10)
(iv)To Display materialwise highest and lowest price of dresses
from dress Table.
Queries :
(i) SELECT DCODE,DESCRIPTION FROM DRESS ORDER BY
DCODE ;
(ii) SELECT *FROM DRESS WHERE LAUNCHDATE
BETWEEN ’05-DEC-07’AND’20-JUN-08’;
(iii) SELECT AVG(PRICE) FROM DRESS WHERE
MCODE=’M003’;
(iv) SELECT B.MCODE ,TYPE,MAX(PRICE)AS
“HIGHEST”,MIN(PRICE) AS “LOWEST” FROM DRESS
A,MATERIAL B WHERE A.MCODE=B GROUP BY TYPE;

. (11)
PYTHON PROGRAM FOR DATA
STRUCTURES
1.Write a Program that depending upon the users Choice
either pushes or pops an Element.
Program :

(14)
Output:

(15)
2.  Write a program that depending upon user's choice,
either pushes or pops an element in a stack the elements are
shifted towards right so that top always remains at 0th (zero)
index.
Program:

(16)
Output:
(17)
3.A line of text is read from the input terminal into a
stack .write an algorithm to output the string in reverse
order ,each character appearing twice(e.g.,the string a b c d e
should be changed to ee dd cc bb aa).
Program:

Output :

. (18)

You might also like