Вы находитесь на странице: 1из 5

DELHI PUBLIC SCHOOL VADODARA

Academic Session 2016 2017


Practice paper-4

Q1. Answer the following


(a) Which MySQL command helps you to create database if it does not exist? (1)
(b) Write brief notes on any four table Constraints in MySQL? (2)
(c)How can we see the list of existing tables? (1)
(d) Room_No, Cust_Name, Room_Type and Room_Rent of table HOTEL are given below:
Table : HOTEL
Room_No Cust_Name Room_Type Room_Rent
204 Rajesh Single 700
308 Anuja Double AC 1600
105 Vinamra Single NAC 500
202 Soma
Based on this information, find output of the following queries: (2)
(I) SELECT Room_Type, SUM(Room_Rent) FROM hotel GROUP BY Room_Type;
(II) SELECT Room_no FROM hotel WHERE Cust_Name LIKE %n%;
(e) What is a Non-Equi join?give example (2)
(f) Why do we use ROLLBACK statement ? (1)
(g) What is foreign key?How do we define a foreign key in our table ? (2)
(h) Differentiate between CHAR and VARCHAR datatypes? (2)

---------End-------

DELHI PUBLIC SCHOOL VADODARA


Academic Session 2016 2017
Practice paper-4

Q1. Answer the following


(a) Which MySQL command helps you to create database if it does not exist? (1)
(b) Write brief notes on any four table Constraints in MySQL? (2)
(c)How can we see the list of existing tables? (1)
(d) Room_No, Cust_Name, Room_Type and Room_Rent of table HOTEL are given below:
Table : HOTEL
Room_No Cust_Name Room_Type Room_Rent
204 Rajesh Single 700
308 Anuja Double AC 1600
105 Vinamra Single NAC 500
202 Soma
Based on this information, find output of the following queries: (2)
(II) SELECT Room_Type, SUM(Room_Rent) FROM hotel GROUP BY Room_Type;
(II) SELECT Room_no FROM hotel WHERE Cust_Name LIKE %n%;
(e) What is a Non-Equi join?give example (2)
(f) Why do we use ROLLBACK statement ? (1)
(g) What is foreign key?How do we define a foreign key in our table ? (2)
(h) Differentiate between CHAR and VARCHAR datatypes? (2)
---------End-------
DELHI PUBLIC SCHOOL VADODARA
Academic Session 2016 2017
Practice paper-5

Q1. (a) What do you understand by primary key and candidate key. (2)

(b) Write the output of following SQL queries. (2)


i. SELECT ROUND(6.88,2) ;
ii. SELECT MID(Discovery Channel,4,6) ;
iii.SELECT DAYOFMONTH (20110330);
iv. SELECT TRUNCATE (7.727,1);

(c) Consider the table STUDENT given below, write SQL Commands for (i) to (iii) and output for
(iv) to (vi)

RollNo Name Class DOB Sex City Marks


1 Nanda X 6/6/95 M Agra 551
2 Saurabh XII 7/5/93 M Mumbai 462
3 Sanal XI 6/5/94 F Delhi 400
4 Trisla XII 8/8/95 F Mumbai 450
5 Store XII 8/10/95 M Delhi 369
6 Marisla XI 12/12/94 F Dubai 250
7 Neha X 8/12/95 F Moscow 377
8 Nishant X 12/6/95 M Moscow 489

(i) To Display all information about class XII students. (1)


(ii) List names all class of all students in descending order of DOB.
(1)
(iii) To count the number of student in XII Class of Mumbai city. (1)
(iv) SELECT DISTINCT(Sex) FROM Student.
(1)
(v) SELECT AVERAGE(Marks) FROM Student GROUP BY Sex.
(1)
(vi) SELECT COUNT(*)FROM Student where Class = XI
(1)

Q7. (A)Study the following table TEACHER and SALARY and write the SQL commands for the
questions (i) and (ii) and give outputs for SQL queries (iii) and (iv).

Table : TEACHER

SID NAME DEPT SEX EXPERIENCE


101 Siddharth Computer M 12
104 Raghav Physics M 5
107 Naman Chemistry M 10
114 Nupur Computer F 3
109 Janvi Physics F 9
105 Rama Accounts M 10
117 James Computer F 3
111 Binoy Accounts F 12
130 Samuel Computer M 15

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

i. Display NAME and DA of all staff who are in Accounts department and having more than 10 years of
experience and DA is more than 300. (2)
ii. Display the NAME and salary of all staff working in physics department and salary more than average
salary. (SALARY=BASIC +ALLOWANCE+ DA) (2)
iii. Select NAME, DA, BASIC from TEACHER, SALARY
Where BASIC>20000 and TEACHER.SID=SALARY.SID; (1)
iv. Select NAME, DEPT, SEX, BASIC, DA from TEACHER, SALARY
Where DEPT LIKE %o% and DA >=500 and TEACHER.SID=SALARY.SID; (1)

----------End-------

DELHI PUBLIC SCHOOL VADODARA


Academic Session 2016 2017
Practice paper-6

Subject : Informatics Practices. Class :


XII

Q1. Write the commands in mysql based on empl and dept table.
a) Display details like deptno, dname, emplno, ename, job and salary. And order the rows by employee
number with department number.
b) Display the difference of higest and lowest salary of each department having maximum salary >
4000.
c) Display detail like deptno, dname,empno, ename,job and salary. And order the rows by employee
number with department number . these details should be only for employees earnin atleast Rs. 1500
and of SALES department.
d) Select * from empl e Join dept d on ( e.deptno= d.deptno). Write this query and see the output.
e) Select * from empl Natural Join dept. Write this query and display the output .

Q2 a) Table Employee has 4 records and table Dept has 3 records in it. Mr jain wants to display all the
information stored in both of these related tables. 1
SELECT * FROM EMPLOYEE ,DEPT ;
He forgot to specify equijoin. How many rows will get displayed on execution of this query?

b) There is a column c1 in table t1 . The following two statements are giving different outputs. What may
be the possible reason ? 1
SELECT COUNT(*)FROM T1;
SELECT COUNT(C1) FROM T1;
c) What are constraints ?Are they useful or not. Justify your answer. 2
d) Name two statements that can be used to end a transaction. 2

e) Write SQL statements for the queries (i) ,(ii) and output for (iii) and (iv): 4
Table: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener Classic 23 60 8 2009-06-31
2003 Ball Pen 0.25 22 50 25 2010-02-01
2002 Gel Pen Premium 21 150 12 2010-02-24
2006 Gel Pen Classic 21 250 20 2011-03-09
2001 Eraser Small 22 220 6 2009-01-19
2004 Eraser Big 22 110 8 2009-12-02
2009 Ball Pen 0.5 21 180 18 2009-11-03
Note: ItemNo is the Primary Key.

i Delete those records whose last buy is before 2003


ii Add another column Category of type character in the table
iii Select round ( qty*110/100, 1)from store where rate>10;
iv Select MID(informatics,3,4), substr(practices,3);

Q3 a)Identify Primary Key, Alternate Key, Candidate Keys in each table & Foreign Key from the following
two tables:

Table: Employee Table: Department


Eno Name Designation Salary Deptno
45 Ramanuj Singh Director 90000 10 Deptno Dname City
32 Gareema Seth Manager 78000 20 10 Research Delhi
12 John Brooke Accountant 25000 20 20 HRD Delhi
9 Ahmed Abdul Manager 78000 30 20 HRD Kolkata

b) Display employee name and department number who reside in DELHI. 2

c) Display the sum of salary for each department with minimum salary as 20000 2

Q4. Select max(sal)- min(sal) difference from empl group by deptno having max(sal)>4000;
a). Select e.deptno, dname, emplno, ename, job and sal from empl e , dept d where e.deptno=d.deptno order
by e.deptno,empno;
b)Select e.deptno, dname, emplno, ename, job and sal from empl e , dept d where e.deptno=d.deptno and
dname=sales and sal>=1500 order by e.deptno,empno;

----------End-------

Вам также может понравиться