CBSE Guess > Papers > Important Questions > Class XII > 2012 > Computer Science > Computer Science Vinay Kumar Srivastava
Computer Science- CBSE CLASS XII
c) Consider the table given below, write command in SQL for (1) to (4) and output for (5) to (8).
For - 1 Marks
Table : STUDENT
No |
Name |
Stipend |
Stream |
AvgMark |
Grade |
ClassSec |
1 |
Karan |
800 |
Medical |
67.8 |
C |
11D |
2 |
Vishu |
1500 |
Commerce |
82.6 |
B |
12B |
3 |
Prabhat |
2000 |
Humanities |
85.7 |
B |
12J |
4 |
Selina |
700 |
Medical |
88.9 |
A |
11C |
5 |
Vinod |
900 |
Science |
65.9 |
C |
11D |
6 |
Karan |
1200 |
Medical |
68.6 |
D |
12J |
( 1 ) To display the name and stream of all students who are in class 12.
( 2 ) To display the different Streams available for students.
( 3 ) To display name, avgmarks and grade in ascending order of grade.
( 4 ) To display names of those students whose grade and section are same.
( 5 ) SELECT Stipend+500 FROM Student WHERE stream LIKE ‘%ma%’;
( 6 ) SELECT COUNT(*) FROM Student WHERE grade=’C’ OR stipend =800;
( 7 ) SELECT ClassSec FROM Student WHERE Avgmark>68 && stream=’Medical’;
( 8 ) SELECT AVG(stipend) FROM Student WHERE name=’Karan’;
Ans: (1) SELECT name,stream
FROM student
WHERE classSec LIKE ‘12%’;
Or
SELECT name,stream
FROM student
WHERE LEFT(classSec,2)=‘12’;
(2) SELECT DISTINCT stream
FROM student;
(3) SELECT name, AvgMark, Grade
FROM student
ORDER BY Grade ASC;
(4) SELECT name
FROM student
WHERE RIGHT(classSec,1)=Grade;
(5) 2500
(6) 2
(7) 11C
12J
(8) 1000
Q . 6 Answer the following question. For - 2 Marks
a) Write an SQL query to create the table “Club“ with the following structure-���� For - 2 Marks
Field |
Type |
Constraint |
CoachId |
Integer(6) |
Primary Key |
CoachName |
Varchar(25) |
Not NULL |
Age |
Integer(3) |
Must be more than 35 |
Sports |
Varchar(20) |
|
Pay |
Integer(8) |
|
Sex |
Char(1) |
|
Ans:
CREATE TABLE club (CoachId INT(6) PRIMARY KEY, CoachName Varchar(25) NOT NULL, Age INT(3) CHECK Age>35, Sports Varchar(20), Pay INT(8), Sex Char(1));
b) In a database there are two tables ‘Doctors’ and ‘Patients’ shown below-���� For - 2 Marks
Table: Doctors
DId |
DName |
OPDDays |
Timing |
D521 |
R. K. Sinha |
Monday |
10 am |
D324 |
V. K.Singha |
Wednesday |
9 am |
D945 |
P. Kumar |
Friday |
12 pm |
D457 |
V. Prasad |
Saturday |
10 am |
D125 |
K. Krishna |
Tuesday |
11 am |
D220 |
M. Kumar |
Monday |
12 pm |
��
Table: Patients���
PId |
Name |
Age |
Dept |
DateOfAdm |
Charges |
Gender |
DId |
115 |
Jugal |
36 |
Nephro |
2005-12-15 |
260 |
M |
D324 |
621 |
Smita |
45 |
Cardiology |
2007-07-20 |
450 |
F |
D945 |
451 |
Reena |
14 |
ENT |
Null |
Null |
F |
D457 |
136 |
Kishor |
64 |
Surgery |
2001-08-28 |
850 |
M |
D521 |
����
i) Name the column(s) that can be used to retrieve data from both the tables.
�ii) Identify the Primary key and Foreign Key attributes from both the tables�
Ans : i) DId ( from Doctors and Patients table)
ii) PId – Primary Key ( Patient Table)
iii)DId- Foreign Key (Patient Table)
iv)DId- Primary Key ( Doctors Table)
c) Consider the tables given below-
For - 6 Marks
Table : Staff
StaffId |
Name |
Dept |
Gender |
Experience |
1125 |
Noopur |
Sales |
F |
12 |
1263 |
Kartik |
Finance |
M |
6 |
1452 |
Palak |
Research |
F |
3 |
236 |
Nayan |
Sales |
M |
8 |
366 |
Anvashan |
Finance |
M |
10 |
321 |
Sawan |
Sales |
M |
7 |
Table : Salary
StaffId |
Basic |
Allowance |
CommPer |
1125 |
14000 |
1500 |
9 |
1263 |
25000 |
2800 |
6 |
236 |
13500 |
1400 |
5 |
321 |
12000 |
1500 |
5 |
366 |
26100 |
3100 |
12 |
With reference to above tables, write commands in SQL for (i) and (ii) and output for (iii)-
i)To display name of all the staff that are in Sales having more than 9 years experience and commission percentage is more than 8.
ii)To display average salary of staff working in Finance department. (Salary=Basic+allowance)
iii) SELECT name, Basic from Staff, Salary WHERE Dept=’Sales’ and Staff.StaffId=Salary.StaffId;
Ans: i) SELECT Name
FROM Staff, Salary
WHERE Dept=’Sales’ AND Experience>9 AND CommPer>8 AND
Staff.StaffId=Salary.StaffId;
ii) SELECT AVG(Basic+Allowance) AS “Average Salary”
FROM Staff, Salary
WHERE Staff.StaffId=Salary.StaffId AND Dept=’Finance’;
iii) Noopur 14000
Nayan 13500
Sawan 12000
Q.7 a) What is e-Governance? Name any two major e-Governance projects in India. For - 2 Marks
Ans: E-Governance refers to the application of electronic means in governance with an aim of fulfilling the requirements of a common man at affordable costs and in fastest possible time.
Two projects are- Income Tax Portal, DRDO Project, Indian Courts, Supreme Court of India, RTI Portal etc.
b) What is database connectivity? For - 1 Marks
Ans: Database Connectivity refers to a programming interface through that front end access a database on a backend via same means
c) Mr. Anubhav is working as a programmer in a Hotel. He wants to create the forms to add the details of customers. Choose appropriate controls from Text Field, Label, Radio Button, Check Box, List Box, Combo Box, and Command Button and write in the third column. For - 2 Marks
SNo |
Control Used to |
Control |
1 |
Enter Name of Customer |
|
2 |
Select Room Type |
|
3 |
To display current date |
|
4 |
Selection for extra facilities like Laundry, Food, Gym |
|
Ans:
SNo |
Control Used to |
Control |
1 |
Enter Name of Customer |
Text Field |
2 |
Select Room Type |
Combo/ Radio Button |
3 |
To display current date |
Label |
4 |
Selection for extra facilities like Laundry, Food, Gym |
Check Box/ List Box |
Prepared By: Mr. Pradumna Singh
mail to: [email protected] |