0% found this document useful (0 votes)
16 views7 pages

Ques Bank - Database and SQL (Sec-14 Indira Nagar)

The document is a question bank for a Computer Science subject focusing on Database Concepts and SQL. It includes various SQL-related questions such as distinguishing between commands, defining keys, and writing SQL queries for given tables. The questions cover a wide range of topics including data types, relational operators, and SQL commands for creating and manipulating databases and tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Ques Bank - Database and SQL (Sec-14 Indira Nagar)

The document is a question bank for a Computer Science subject focusing on Database Concepts and SQL. It includes various SQL-related questions such as distinguishing between commands, defining keys, and writing SQL queries for given tables. The questions cover a wide range of topics including data types, relational operators, and SQL commands for creating and manipulating databases and tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

QUESTION BANK

SUB: COMPUTER SCIENCE


DATABASE CONCEPTS AND SQL

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]

3. NAME THE SQL COMMANDS FOR FOLLOWING: [4]

a) TO SHOW ALL EXISTING DATABASES ON SYSTEM

b) TO OPEN A DATABASE NAMED ‘RLB’

c) TO SHOW ALL EXISTING TABLES IN A DATABASE

d) TO DELETE A TABLE PERMANENTLY.

4. IS NULL VALUE EQUIVALENT TO 0? WHAT DO YOU MEAN BY NULL VALUE IN SQL? [2]

5. EXPLAIN DDL AND DML COMPONENTS OF SQL WITH EXAMPLES. [2]

6. DEFINE CANDIDATE KEY AND PRIMARY KEY WITH SUITABLE EXAMPLE IN A TABLE. [2]

7. WHAT IS A RELATION IN RDBMS? GIVE EXAMPLE. [2]

8. DEFINE DEGREE AND CARDINALITY TAKING A TABLE AS EXAMPLE. [2]

9. WHAT IS A TUPLE AND AN ATTRIBUTE IN RDBMS. EXPLAIN WITH EXAMPLE. [2]

10. WHAT ARE THE ADVANTAGES OF DBMS? [2]

11. EXPLAIN FOREIGN KEY WITH A SUITABLE EXAMPLE. [2]

12. TAKING A TABLE AS EXAMPLE, EXPLAIN PRIMARY KEY, CANDIDATE AND ALTERNATE KEYS. [2]

13. GIVEN FOLLOWING TABLE: [4]

a) IDENTIFY THE ATTRIBUTE BEST SUITABLE TO BE DECLARED AS PRIMARY KEY.


b) ABHAY WANTSTO DISPLAY THE STRUCTURE OF TABLE STORE. WRITE QUERY TO DISPLAY THE SAME.
c) HE WANTS TO ADD ONE MORE COLUMN PRICE OF FLOAT TYPE IN THE ABOVE TABLE STORE. WHICH
COMMAND WILL HE USE FOR THE SAME?
d) HE WANTS TO REMOE THE TABLE FROM THE DATABASE. WHICH COMMAND WILL HE USE?

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]

1. Name of the database: MYSTORE


2. Name of the table: STORE
3. The attributes of STORE are as follows-
ItemNo numeric (PRIMARY KEY)
ItemName character of size 20 (UNIQUE)
Scode numeric (NOT NULL)
Quantity numeric
WRITE SQL COMMANDS TO HELP BIPIN TO CREATE THE DATABASE AND CREATE THE GIVEN TABLE.

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;

18. IDENTIFY RELATIONAL OPERATORS OF SQL FROM FOLLOWING: [2]


AND, >, <=, *, &&, !=, OR, !, NOT, =, +

19. DIFFERENTIATE BETWEEEN CHAR AND VARCHAR DATA TYPES IN SQL. [2]

20. WHICH SQL OPERATOR IS USED TO PEFORM THE FOLLOWING: [2]


a) PATTERN MATCHING
b) TO TEST A COLUMN FOR ABSENCE OF VALUE i.e. NULL

21. DIFFERENTIATE BETWEEN WHERE AND HAVING CLAUSES OF SELECT WITH EXAMPLE. [2]

22. NAME SQL CLAUSES USED FOR FOLLOWING: [2]


a) TO SORT QUERY RESULTS
B) TO GIVE CODITIONS ON GROUPS OF ROWS
c) TO SELECT ONLY THOSE ROWS THAT SATISFY A GIVEN CONDITION
d) TO DISPLAY ONLY THE UNIQUE VALUES OF A COLUMN

23. WRITE SQL COMMANDS TO: [3]


a. CREATE A DATABASE OFFICE
a. Create A TABLE EMPL from the given structure:
Column Name Data Type Constraints
Emp_id Numeric Primary key
Name Text with maximum 25 characters Not null
Date_of_birth Date
Salary Numeric
Deptno Numeric
Panno Text with maximum 12 characters Non repeated
24. WRITE SQL COMMANDS ON THE BASIS OF TABLE GIVEN BELOW : [3]

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

i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.


ii) To display the details of all Garments, which have READYDATE in between 08-dec-07 and 16-jun-08.
iii) To display the average PRICE of all the Garments, which are made up of FABRIC with FCODE as F03.
iv) To display FCODE wise highest and lowest price from GARMENT table.

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’;

31. Write SQL commands for the following statements: [4]


Table: RESULT
Rno Name Age Class Gender Dob Marks
100 Arjun 18 12B M 27-Oct-88 75
200 Anjan 18 12A F 28-Jan-88 68
300 Sharath 17 12C M 16-Jun-89 NULL
400 Jacob 17 12A M 14-Oct-90 72
500 Abrar 18 12B M 17-Jul-89 68
(i) Display the total marks scored by students of class “12A‟ and also by students of class “12B‟ separately.
(ii) Display the details of students who were absent for the exam. { A student is considered to be absent for the
exam, if he/she does not have a mark entry in the marks column.}
(iII) Display the roll number, name and marks of all the students sorted by marks in descending order.
(Iv) Increase the marks by 10 of those students whose name begins with ‘A’.

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

2 Ritesh Nokia Hutch 12/02/2005 60 3030

3 Reena Samsung Hutch 14/05/2004 365 3030

4 Meeta Nokia Indicom 24/09/2004 180 890

5 Rama Samsung Idea 16/10/2004 180 900

6 Anupam LG Hutch 18/01/2005 60 600


a) Display Cname and Amount paid by Customers having “Samsung” model and “Hutch” Connection arranged in
descending order of amount.
b) To display different types of connections available.
c) To display sum of validity for each type of connection grouping.
d) To display Cname, Connection and date of expiry where date of expiry is date of activation (of
connection) + validity (no. of days valid) .

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

101 John ENT M 12 101 12000 1000 300

104 Smith ORTHOPEDIC M 5 104 23000 2300 500

107 George CARDIOLOGY M 10 107 32000 4000 500

114 Lara SKIN F 3 114 12000 5200 100

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

Acno Cname Bname Amount Dateofopen B_Id City Bname


1 Karan Bank of Baroda 10000 26-feb-09 B00 Delhi State Bank
2 Puneet State Bank 25000 28-may-10 1
3 Yatin Oriental Bank 56000 17-nov-09 B00 Pune Uco Bank
4 Sunny Uco Bank 45000 20-dec-09 2
B00 Banglore Bank of Baroda
5 Jayant Bank of Baroda 30000 29-nov-09
3
6 Nikhil Oriental Bank 50000 25-mar-08
7 Tarun State Bank 36000 29-jun-09
8 Jisha Uco Bank 45000 01-jan-07
9 Madhu Bank of Baroda 54000 14-oct-09

( i ) Display data for all CUSTOMERs whose account no. is either 1 , 4, 6 or 7


( ii ) Display data for all CUSTOMERs sorted by their Date of opening account.
(iii) Count the no. of CUSTOMERs who are having account in State Bank.
(iv) List the minimum and maximum amount in each 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]

PCOD PNAME COMPANY PRICE STOCK MANUFACTURE WARRANTY


P001 TV BPL 10000 200 12-JAN-2008 3
P002 TV SONY 12000 150 23-MAR-2007 4
P003 PC LENOVO 39000 100 09-APR-2008 2
P004 PC COMPAQ 38000 120 20-JUN-2009 2
P005 HANDYCAM SONY 18000 250 23-MAR-2007 3

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]

(i) Select COUNT(distinct company) from PRODUCT.


(ii) Select MAX(price)from PRODUCT where WARRANTY<=3
40. Consider the following table “CLUB” with details about various sports conducted in the club. Write SQL
commands for (i) to (iv) : [4]
Table: CLUB
CoachId CoachName Age Sports DateOfApp Pay Gender
1 Kukreja 35 Karate 27-Mar-1996 1000 M
2 Ravina 34 Karate 20-Jan-1998 1200 F
3 Karan 34 Squash 19-Feb-1998 2000 M
4 Tarun 33 Basketball 01-Jan-1998 1500 M
5 Zubin 36 Swimming 12-Jan-1998 750 M
6 Ketaki 36 Swimming 24-Feb-1997 800 F
7 Ankita 39 Squash 20-Jun-1995 2200 F
8 Zareen 37 Karate 13-Apr-2000 1100 F
9 Kush 41 Swimming 19-May-1992 900 M
10 Shailya 37 Basketball 21-Oct-1995 1700 M

(i) Display the names of the coaches in descending order of DateOfApp.


(ii) Display the details of those coaches whose payment is in the range 1000 to 1500.
(iii) Display the total number of coaches for each sport.
(iv) Add a column named NoOfTrainee in the above table.

41. Write output for following on the basis of above Table CLUB : [2]

(i) select Sports from CLUB where Sports like “S%”;


(ii) select count (distinct Sports) from CLUB.
(iii) select CoachName from CLUB where Age<35;
(iv) SELECT DISTINCT SPORTS FROM CLUB;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy