CBSE Guess > Papers > Important Questions > Class XII > 2012 > Computer Science > Computer Science Mr. Pradumna Singh
Computer Science- CBSE CLASS XII
Q. 19. What do you understand by Primary Key and Alternate Key. Explain with example. For - 4 Marks
Ans : PRIMARY KEY : It is a set of one or more attributes that can uniquely identify tuples within the relation.
ALTERNATE KEY : A candidate key that is not the primary key is known as an alternate key.
For ex.
Relation: Data
EmpNo |
Name |
Designation |
MobileNo |
PANCardNo |
Salary |
BankAccountNo |
Here in above table EmpNo, MobileNo, PANCardNo & BankAccountNo are candidate keys. If EmpNo is made the primary key then remaining will automatically become alternate keys.
Q.20. Consider the following table GAMES and PLAYER. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).
Table : GAMES
GCODE |
GAMENAME |
NUMBER |
PRZMONEY |
SCHDATE |
101 |
Chess |
5 |
25000 |
23 Jan 2010 |
102 |
Badminton |
3 |
38000 |
12 Nov 2008 |
103 |
Carrom |
6 |
18000 |
18 Mar 2010 |
105 |
Table Tennis |
3 |
30000 |
09 Jan 2009 |
108 |
Basketball |
5 |
40000 |
29 Apr 2009 |
Table : PLAYER
PCODE |
NAME |
GCODE |
1 |
Rakesh Srivastava |
101 |
2 |
Nilesh Mishra |
102 |
3 |
Vandana |
108 |
4 |
Ravi Jindal |
105 |
- to display the details of those games which are having prize money less than 30000 and organized before 2009. For - 1 Marks
Ans. : SELECT * FROM GAMES WHERE PRZMONEY<30000 AND SCHDATE<’01-JAN-2009’ ;>
- to display the name of PLAYERS in reverse alphabetical order. For - 1 Marks
Ans. : SELECT NAME FROM PLAYERS ORDER BY NAME DESC;
- to increase the prize money by 1000 for those games which name starts with ‘B’. For - 1 Marks
Ans. : UPDATE GAMES SET PRZMONEY=PRZMONEY+1000 WHERE GAMENAME LIKE ‘B%’;
- Insert an additional attribute namely DOB for entering date of birth in table PLAYER. For - 1 Marks
Ans. : ALTER TABLE PLAYER ADD(DOB DATE);
- SELECT GAMENAME,NAME FROM GAMES G,PLAYER P WHERE G.GCODE=P.GCODE; For - 1 / 2 Marks
Ans. :
GAMENAME |
NAME |
Chess |
Rakesh Srivastava |
Badminton |
Niesh Mishra |
Basketball |
Vandana |
Table Tennis |
Ravi Jindal |
- SELECT MIN(SCHDATE), MAX(PRZMONEY) FROM GAMES ; For - 1 / 2 Marks
Ans. : MIN(SCHDATE) MAX(PRZMONEY)
---------------------- ---------------------------
12-Nov-2008 40000
- SELECT AVG(PRZMONEY) FROM GAMES WHERE SCHDATE<’01-JAN-2009’; For - 1 / 2 Marks
Ans. : AVG(PRZMONEY)
--------------------------
38000
- SELECT COUNT(DISTINCT NUMBER) FROM GAMES; For - 1 / 2 Marks
Ans. : COUNT(DISTINCT NUMBER)
-----------------------------------------
3
Prepared By: Mr. Pradumna Singh
mail to: [email protected] |