Saved Bookmarks
| 1. |
Consider the following tables GAMES and PLAYER and answer (b) and (c) parts of this question :(a)What do you understand by primary key and candidate keys?(b)Write SQL commands for the following statements:1. To display the name of all GAMES with their GCodes.2. To display details of those GAMES which are having Prizemoney more than 7000.3. To display the content of the GAMES table in ascending order of Schedule Date.4. To display the sum of Prizemoney for each type of GAMES.(c) Give the output of the following SQL queries:1. SELECT COUNT(DISTINCT Number) FROM GAMES;2. SELECT MAX(ScheduleDate), MIN(Sche- duleDate) FROM GAMES3. SELECT Name, GameName FROM GAMES G, PLAYER PWHERE (G.Gcode=PGcode AND G.Pri- zeMoney>10000);4. SELECT DISTINCT Geode FROM PLAYER; |
|
Answer» (a) An attribute or set of attributes which are used to identify a tuple uniquely is known as a primary key. If a table has more than one such attributes which identify a tuple uniquely than all such attributes are known as candidate keys. (b) 1. SELECT GameName, GCode FROM GAMES; 2. SELECT * FROM Games WHERE PrizeMoney >7000; 3. SELECT * FROM Games ORDER BY ScheduleDate; 4. SELECT SUM(Pnzemoney) FROM Games GROUPBY Type; (c) 1. 2 2. 19-Mar-2004 12-Dec-2003 3. Ravi Sahai Lawn Tennis 4. 101 108 103 |
|