Ques Bank - Database and SQL (Sec-14 Indira Nagar)
Ques Bank - Database and SQL (Sec-14 Indira Nagar)
1. DISTINGUISH BETWEEN ALTER TABLE AND UPDATE COMMANDS IN SQL WITH EXAMPLE. [2]
2. DIFFERENTIATE BETWEEN DROP TABLE AND DELETE COMMANDS OF SQL WITH EXAMPLE. [2]
4. IS NULL VALUE EQUIVALENT TO 0? WHAT DO YOU MEAN BY NULL VALUE IN SQL? [2]
6. DEFINE CANDIDATE KEY AND PRIMARY KEY WITH SUITABLE EXAMPLE IN A TABLE. [2]
12. TAKING A TABLE AS EXAMPLE, EXPLAIN PRIMARY KEY, CANDIDATE AND ALTERNATE KEYS. [2]
14. A TABLE SHOP HAS CARDINALITY 3 AND DEGREE 5. TELL THE NUMBER OF ROWS AND NUMBER OF COLUMNS OF
THE TABLE. [2]
15. Departmental Store ‘MY STORE’ IS CONSIDERING TO MAINTAIN THEIR INVENTORY USING SQL to store the data.
AS A DATABASE ADMINISTRATOR, BIPIN HAS decided that: [3]
16. WHICH COMMAND WILL BE USED TO REMOVE A COLUMN “EMPNO” FROM A TABLE “EMP”? WRITE THE
COMPLETE COMMAND. [2]
17. WHAT IS ‘NAME’ AND ‘STU’ IN THE FOLLOWING SQL STATEMENT: [2]
SELECT CITY, AGE, ADDRESS FROM EMP, STU WHERE NAME=’AMAN’ AND EMP.NO = STU.NO;
19. DIFFERENTIATE BETWEEEN CHAR AND VARCHAR DATA TYPES IN SQL. [2]
21. DIFFERENTIATE BETWEEN WHERE AND HAVING CLAUSES OF SELECT WITH EXAMPLE. [2]
25. [2]
26. [3]
27. Write SQL commands for i to iv : [4]
TABLE: FABRIC TABLE : GARMENT
GCODE DESCRIPTION PRICE FCODE READYDATE CODE TYPE
10023 PULLOVER 1150 F03 19-DEC-08 F04 POLYSTER
10001 FORMAL SHIRT 1250 F01 12-JAN-08
F02 COTTON
10012 T-SHIRT 1550 F02 06-JAN-08
F03 SILK
10024 JACKET 750 F03 07-APR-07
F01 TERELENE
10090 TIE 850 F02 31-MAR-07
10019 TROUSER 1500 F01 06-JAN-08
28. WRITE outputs of i to iv based on tables GARMENT & FABRIC given above: [2]
i) SELECT SUM(PRICE) FROM GARMENT WHERE FCODE=’F01’;
ii) SELECT DESCRIPTION,TYPE FROM GARMENT,FABRIC WHERE GARMENT.FCODE=FABIRC.CODE AND
GARMENT.PRICE=1250;
iii) SELECT MAX(FCODE) FROM FABRIC;
iv) SELECT COUNT(DISTINCT PRICE) FROM GARMENT;
29. Write the SQL queries for statements (i) to (iv) : [4]
SENDER RECEPIENT
senderid sendername Senderadd sendercity recid senid recname recadd Reccity
ND01 R Jain 2/abc apppts New Delhi KO05 NDO1 H.Rai 5 ingr Kolkata
MU02 H Sinha 12, newtown Mumbai ND08 MU02 A.singh 6 vngr Mumbai
MU15 S Jha 27/a park st. Mumbai MU19 ND01 M.sharma 2 gngr Mumbai
ND50 T Prasad 122-k sda NewDelhi MU32 MU15 S.Rai 6 hganz Chennai
ND48 ND50 P.Gautam 8 red st Chennai
i. Display the names of all senders from Mumbai.
ii. Display the recid, sendername, senderadd, recname, recadd for every recipient.
iii. Display recipients details in ascending order of recname.
iv. Display the no. of recipients from each city.
30. Give outputs for following queries for the tables SENDER and RECEPIENT given above: [2]
i. Select distinct sendercity from sender.
ii. Select a.sendername, b.recname from sender a, recipient b where a.senderid=b.senderid and
b.reccity=’Mumbai’
iii. Select recname., recadd from recipient where reccity not in(‘Mumbai’,’Kolkata’);
iv. Select recid,recname from recipient where senderid = ‘MU02’ or senderid=’ND50’;
32. Write SQL commands for (a) to (d) on the basis of the following table : [4]
PREPAID
Table:-
S.NO PREPAID
CNAME Model Connection Activation_date Validity Amount
(in days)
1 Sita Nokia Airtel 04/06/2004 365 3300
33. Give Outputs for following based on above Table PRPAID : [2]
a) Select count(Distinct) model from prepaid.
b) Select max(Activation), min(Activation) from prepaid.
c) Select avg(validity) from prepaid where model=’LG’;
d) Select max(Amount) form prepaid where connection=’IDEA’
34. Write SQL commands for (a) to (d) on the basis of the following tables DOCTOR and SALARY [4]
Table:- DOCTOR Table:- SALARY
ID NAME DEPT SEX EXPERIENCE ID BASIC ALLOWANCE CONSULTATION
a) Display names of all Doctors who are in medicine having more than 10 years experience from the
table DOCTOR.
b) Display the total salary of all Doctors working in ENT department using the tables DOCTOR and
SALARY where TotalSalary=BASIC+ALLOWANCE+CONSULTATION.
c) Display the minimum allowance of female doctors.
d) Display the highest consultation fee among all male doctors.
35. Write outputs for (a) to (d) on the basis of the above tables DOCTOR and SALARY : [2]
a) Select COUNT(*) From DOCTORS where SEX=’F’
b) Select NAME,DEPT,BASIC from DOCTOR,SALARY where DEPT=’ENT’ AND DOCTOR.ID=SALARY.ID.
c) Select AVG(BASIC) from SALARY where CONSULTATION between (100 AND 300).
d) Select Salary.ID, Name, Experience, Basic from Doctor, Salary where Salary.ID = DOCTOR.ID and Basic<=22000;
36. Consider the following tables BANK and CUSTOMER .Write the SQL queries for (i) to (iv) : [4]
CUSTOMER TABLE:- BANK
37. Write outputs for following on the basis of above Tables CUSTOMER and BANK : [2]
(I) Select Cname , Bname ,City from CUSTOMER, BANK where CUSTOMER.Bname=BANK.Bname;
(II) Select avg(amount) from CUSTOMER where Cname like ‘_a%’ ;
(III) Select Bname , sum(amount) from CUSTOMER group by Bname having count(*) <3;
(IV) Select max(amount) from CUSTOMER where dateofopen < ‘1-mar-09’ ;
38. Write SQL commands for (a) to (d) on the basis of PRODUCTS relation given below: [4]
a) To find stock value of the BPL company where stock value is sum of the products of price and stock.
b) To show number of products from each company.
c) To count the number of PRODUCTS which shall be out of warranty on 20-NOV-2010.
d) To show the PRODUCT name which are within warranty as on date.
39. Write output for following on the basis of PRODUCTS table given above : [2]
41. Write output for following on the basis of above Table CLUB : [2]