Page 290 - PYTHON-12
P. 290
Ans. (i) Name
Motherboard
Hard Disk
LCD
(ii) AREA COUNT
CP 2
GK II 1
Nehru Place 2
(iii) COUNT 3
17. (a) Define a candidate key with example and write SQL queries for (b) to (f) and write the output for the
SQL queries mentioned in parts (g1) to (g3) on the basis of tables PRODUCTS and SUPPLIERS.
Table: PRODUCTS
PID PName QTY Price COMPANY SUPCODE
101 DIGITAL CAMERA 14X 120 12000 RENIX S01
102 DIGITAL PAD 11i 100 22000 DIGI POP S02
104 PEN DRIVE 16 GB 500 1100 STOREKING S01
106 LED SCREEN 32 70 28000 DISPEXPERTS S02
105 CAR GPS SYSTEM 60 12000 MOVEON S03
Table: SUPPLIERS
SUPCODE SNAME CITY
S01 GET ALL INC KOLKATA
S03 EASY MARKET CORP DELHI
S02 DIGI BUSY GROUP CHENNAI
Ans. (a) A table may have more than one such attribute/group of attributes that identifies a tuple uniquely; all
such attribute(s) are known as Candidate Keys.
Table: Item
Ino Item QTY
101 Pen 560
102 Pencil 780
104 CD 450
109 Floppy 700
105 Eraser 300
103 Duster 200 Candidate Keys
Computer Science with Python–XII 12.60 Ans. SELECT * FROM PRODUCTS ORDER BY PNAME;
(b) To arrange and display all the records of table Products on the basis of product name in the ascending
order.
(c) To display product name and price of all those products whose price is in the range of 10000 and 15000
(both values inclusive).
Ans. Select PNAME, PRICE FROM PRODUCTS WHERE PRICE>=10000 and PRICE<=15000;