Friday 29th March 2024
REGISTRATION
Online Fashion Store

CBSE Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2012 > Computer Science > Computer Science Mr. Pradumna Singh

Computer Science- CBSE CLASS XII

PreviousIndex Next

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

  1. to display the details of those games which are having prize money less than 30000 and organized before 2009.                             For - 1 Marks
  2. Ans. : SELECT * FROM GAMES WHERE PRZMONEY<30000 AND SCHDATE<’01-JAN-2009’ ;>

  3. to display the name of PLAYERS in reverse alphabetical order.                             For - 1 Marks
  4. Ans. : SELECT NAME FROM PLAYERS ORDER BY NAME DESC;

  5. to increase the prize money by 1000 for those games which name starts with ‘B’.                             For - 1 Marks
  6. Ans. : UPDATE GAMES SET PRZMONEY=PRZMONEY+1000 WHERE GAMENAME LIKE ‘B%’;

  7. Insert an additional attribute namely DOB for entering date of birth in table PLAYER.                             For - 1 Marks
  8. Ans. : ALTER TABLE PLAYER ADD(DOB DATE);

  9. SELECT GAMENAME,NAME FROM GAMES G,PLAYER P WHERE G.GCODE=P.GCODE;                             For - 1 / 2 Marks
  10. Ans. :    

    GAMENAME NAME
    Chess Rakesh Srivastava
    Badminton Niesh Mishra
    Basketball Vandana
    Table Tennis  Ravi Jindal
  11. SELECT MIN(SCHDATE), MAX(PRZMONEY) FROM GAMES ;                             For - 1 / 2 Marks
  12. Ans. : MIN(SCHDATE)       MAX(PRZMONEY)
               ----------------------      ---------------------------

               12-Nov-2008         40000

  13. SELECT AVG(PRZMONEY) FROM GAMES WHERE SCHDATE<’01-JAN-2009’;                             For - 1 / 2 Marks
  14. Ans. :             AVG(PRZMONEY)
                           --------------------------

                               38000
  15. SELECT COUNT(DISTINCT NUMBER) FROM GAMES;                             For - 1 / 2 Marks
  16. Ans. :  COUNT(DISTINCT NUMBER)
               -----------------------------------------

                  3

PreviousIndex Next

Prepared By: Mr. Pradumna Singh
mail to: [email protected]