Objective Type Questions Multiple Choice Questions
Objective Type Questions Multiple Choice Questions
Objective Type Questions Multiple Choice Questions
3. Which one of the following uniquely identifies the tuples / rows in a relation. 1
(a) Secondary Key (b) Primary Key (c) Composite Key (d) Foreign Key
5. Which of the following is a group of one or more attributes that uniquely identifies a row? 1
(a) Key (b) Determinant (c) Tuple(d) Relation
6. Which of the following attributes cannot be considered as a choice for Primary Key ? 1
(a) Id(b) License number (c) Dept_Id (d) Street
7. An attribute in a relation is a foreign key if it is the ______ key in any other relation. 1
(a) Candidate (b) Primary (c) Super (d) Sub
11. In SQL, which of the following will select only one copy of each set of duplicate rows
from a table.
(a) SELECT UNIQUE
(b) SELECT DISTINCT
(c) SELECT DIFFERENT
(d) All of these.
12. Which of the following keywords will you use in the following query to display the unique 1
values of the column dept_name?
SELECT________ dept_name FROM COMPANY;
(a) All (b) From(c) Distinct (d) Name
13. The___ clause of SELECT query allows us to select only those rows in the result that 1
satisfy a specified condition.
(a) where (b) from (c) having (d) like
93 | P a g e
14. Which operator can take wild card characters for query condition? 1
(a) BETWEN (b) LIKE (c) IN (d) NOT
16. Which of the following SQL commands retrives data from table(s) ? 1
(a) UPDATE (b) SELECT (c) Union (d) All of these
(a) Misha, Khushi (b) Khushi, Japneet (c) Japneet (d)Misha, Japneet
21. Which operator tests a column for the absence of data(i.e. NULL value) ? 1
(a) Exist Operator (b) NOT Operator (c) IS Operator (d) None of these
29. Which of the following types of table constraints will prevent the entry of duplicate rows? 1
(a) Unique (b) Distinct (c) Primary Key (d) Null
30. Consider the following SQL Statement. What type of statement is this ? 1
INSERT INTO instructor VALUES (10211, ‘SHREYA’ , ‘BIOLOGY’, 69000);
(a) Procedure (b) DML (c) DCL (d) DDL
31. Which of the following statements will delete all rows in a table namely mytablewithout 1
deleting the table’s structure.
(a) DELETE FROM mytable;’
(b) DELETE TABLE mytable;
(c) DROP TABLE mytable;
(d) None of these.
32. Which of the following query will drop a column from a table ? 1
(a) DELETE COLUMN column_name;
(b) DROP COLUMN column_name;
(c) ALTER TABLE table_name DROP COLUMN column_name;
(d) None of these
34. Which of the following requirement can be implemented using a CHECK constraint? 1
(a) Student must be greater than 18 years old.
(b) Student must be form a BRICS Country (Brazil, Russia, India, China, South
Africa)
(c) Student’s roll number must exist in another table(say, namely Eligible)
(d) None of these
95 | P a g e
35. An attribute in a relation is termed as a foreign key when it reference the _____ of another 1
relation.
(a) Foreign Key (b) Primary Key (c) Unique Key (d) Check Constraint
37. A relationship is formed via _______ that relates two tables where one table references 1
other table’s key.
(a) Candidate Key (b) Primary Key (c) Foreign Key (d) Check Constraint
39. What should be the data type for the column Pricestoring values less than Rs.1000 e.g. 1
200.21
(a) VARCHAR(50) (b) NUMBER (c) NUMBER(5,2) (d) NUMBER(6)
41. Data manipulation language (DML) includes statements that modify the_____ of the 1
tables of database.
(a) Structure (b) Data (c) User (d) Size
42. All aggregate functions ignore NULLs except for the __________ function. 1
(a) Distinct (b) Count(*) (c) Average() (d) None of these
45. Aggregate functions can be used in the select list or the ____ clause of the select statement. 1
They cannot be used in a _______ clause.
(a) Where, having (b) Having, where (c) Group by, having (d) Group by where
96 | P a g e
(d) None of the mentioned.
97 | P a g e
Fill in the Blanks
1. The SQL keyword _______ is used to specify the table(s) that contains the data to be 1
retrieved.
2. The ________ command of SQL lets you make queries to fetch data from tables. 1
3. To remove duplicate rows from the result of a query, specify the SQL qualifier_____ in select 1
list.
4. To obtain all columns, use a(n) _______ instead of listing all the column names in the select 1
list.
5. The SQL _______ clause contains the condition that specifies which rows are to be selected. 1
6. The SQL keyword _______ is used in SQL expressions to select records based on patterns. 1
7. The ________ operator is used for making range checks in SELECT queries. 1
8. The null values in a column can be searched for in a table using _____ ______ in the WHERE 1
clause of SELECT query.
9. To sort the rows of the result table, the _____ _____ clause is specified.
10. Columns can be sorted in descending sequence by using the SQL keyword ________. 1
16. To define a column as a primary key, _______ ________ constraint is used in CREATE 1
TABLE.
19. To increase the size of a column in an existing table, use commond _________. 1
21. _______ _______ command is used to alter the definition of already created table. 1
98 | P a g e
22. To remove table data as well table structure, use command ______ ________ 1
23. Use _____ _______ command to add new columns in an existing table. 1
24. A column added via ALTER TABLE command initially contains _____ value for all rows. 1
26. The ______ _______ clause is used to divide result of SELECT query in groups. 1
29. Nested grouping can be done by providing ________ ______ in the GROUP BY expression. 1
30. The _________ clause is used in SELECT queries to specify filtering condition for groups. 1
32. The SQL built-in function ____ total values in numeric columns. 1
33. The SQL built-in function ____ computes the average of values in numeric columns. 1
34. The SQL built-in function ____ obtains the largest value in a in numeric columns. 1
35. The SQL built-in function ____ obtains the smallest value in a in numeric columns. 1
36. The SQL built-in function ____ computes the number of rows in a table. 1
37. The functions that work with one row at a time are _____ _____ functions. 1
39. In equi-join, the join condition joins the two tables using _______ operator 1
40. To get a substring of a string other than Substr() function ______ is also used. 1
43. To remove a character from the right side of a string, _____ function is used 1
45. An SQL _________ clause combines records from two or more tables in database. 1
46. An _______ is specific type of join that uses only equality comparisons in the join-condition. 1
99 | P a g e
47. _____ join select all data starting from the left table and matching rows in the right table. 1
49. _____ join produces a data set that includes only those rows from the left table which have 1
matching rows from the right table.
3. A common attribute of two tables is called a foreign key it is the primary key in one table and 1
the other table reference it.
4. Part of SQL which creates and defines tables and other database objects, is called DDL 1
6. Part of SQL which access and manipulates data in tables is called DML 1
10. The condition in a WHERE clause in a SELECT query can refer to only one value. 1
11. SQL provides the AS keyword, which can be used to assign meaningful column name to the 1
results of queries using the SQL built-in functions.
13. SELECT DISTINCT is used if a user wishes to see duplicate columns in a query. 1
15. DELETE FROM <table> command is same as DROM TABLE <table> command. 1
16. The unique constraint can only be defined once in the CREATE TABLE command. 1
18. Tuple based constraints can use multiple columns of the table. 1
100 | P a g e
19. The table based constraints can use multiple column of the table. 1
20. You can add a column with a NOT NULL constraint using ALTER TABLE, only to a table 1
that contains no rows.
21. You can use the INSERT statement only to add one new row and not multiple new rows to 1
an existing table.
23. The HAVING clauses can take any valid SQL function in its condition. 1
101 | P a g e
Very Short Answer Questions
1. What is a primary key? 1
3. How many primary key and unique keys can be there in a table? 1
6. What is a tuple 1
8. What is DML ? 1
9. Give some examples of DML commands. Or Write the name of any two DML Commands of
SQL ?
10. In SQL,write the query to display the list of tables stroe in database. 1
19. Which SQL aggregate function is used to count all records of a table? 1
20. Write a query to create a string from the ASCII values 70,65,67,69 1
21. Write a query to concatenate the two strings : “Hello” and “World” 1
22. Display 4 characters extracted from 5th right character onwards from the string ‘ABCDEFG’ 1
25. Display the position of occurrence of string ‘OR’ in the string ‘CORPORATE FLOOR’ 1
27. Write a query to extract 2 digit year from a string ‘USS/23/67/09’. The last two character tell 1
the year.
28. Write a query to extract institute code from a string ‘USS/23/67/09’. The first three characters 1
tell the institute code.
30. Write a query to round off value 15.193 to one decimal place. 1
31. Write a query to find out the square root of value 26. 1
34. Write a query to extract month part from date 3rd Feb 2021 1
35. Write a query to display name of weekday for date 03rd Feb 2021 1
ANSWER
Multiple Choice Questions
1 (b) Key 2 (d) All of these 3 (b) Primary Key 4 (c) Candidate Key
5 (a) Key 6 (d) Street 7 (b) Primary 8 (d) ID
9 (b) QAL 10 (b) ALTER 11 (b) SELECT 12 (c) Distinct
DISTINCT
13 (a) where 14 (b) LIKE 15 (a) BETWEEN 16 (b) SELECT
17 (d) 18 (a) Misha, Khushi 19 (b) LIKE 20 (d) %
21 (c) IS Operator 22 (a) Order By 23 (d) Ascending 24 (c) Desc, Asc
25 (d) 26 (a) ALTER 27 (d) All of these 28 (c)
TABLE
29 (a) Unique 30 (b) DML 31 (a) 32 (c)
33 (a) 34 (a) and (c) 35 (b) Primary Key 36 (c)
37 (b)Foreign Key 38 (c)99.99 39 (c) NUMBER(5,2) 40 (b) column Name
41 (b) Data 42 (b)Count(*) 43 (b)And (c) 44 (b)And (c)
45 (c) Group by, 46 (a) 47 (b) TRUNCATE() 48 (b) 3
having
49 (c) 153.67 50 (a) 5
103 | P a g e
Fill in the Blanks
1 FROM 2 SELECT 3 DISTINCT 4 ASTRIK(*)
5 WHERE 6 LIKE 7 BETWEEN 8 IS NULL
9 ORDER BY 10 DESC 11 ASCENDING 12 USE
13 CREATE TABLE 14 CONSTRAINT 15 REFERENCES 16 PRIMARY KEY
17 INSERT INTO 18 DELETE 19 ALTER TABLE 20 DROP TABLE
21 ALTER TABLE 22 DROP TABLE 23 ALTER TABLE 24 NULL
25 COMMIT 26 GROUP BY 27 HAVING 28 AGGREGATE
29 MULTIPLE 30 HAVING 31 WHERE 32 SUM()
FIELDS
33 AVG() 34 MAX() 35 MIN() 36 COUNT()
37 SINGLE ROW 38 HAVING 39 = 40 MID()
41 DAY() 42 DAYNAME() 43 RTRIM() 44 CURDATE()
45 JOIN 46 EQUI-JOIN 47 LEFT JOIN 48 RIGHT JOIN
49 INNER 50 AGGREGATE
FUNCTION
True / False
1 False 2 False 3 True 4 True
5 False 6 True 7 True 8 False
9 False 10 False 11 True 12 False
13 False 14 True 15 False 16 False
17 False 18 False 19 True 20 True
21 False 22 False 23 False 24 False
25 False 26 True 27 False 28 False
29 True 30 False
2. A Unique key in table/relation is any non-primary key field which also stores unique values 1
for each row just like a primary-key does. But only one key is designated as primary key. So
unique refers to a unique non-key field of a table.
3. There can be multiple unique keys in a table but there can be only primary key in a table. 1
4. A foreign key is a field of a table which is the primary key of another table through a foreign 1
key a relationship is established between two tables.
5. If a table / relation has a primary key which is a combination of multiple columns of a table, 1
it is known as a composite primary key.
8. DML refers to the Data Manipulation Language component of SQL. The DML commands 1
are used to manipulate and query upon the data stored in various tables of a database.
104 | P a g e
9. INSERT, UPDATE, SELECT and DELETE 1
11. Constraints are the rules or conditions imposed on various attributes of a table in a database 1
so that only the data that satisfy these rules and conditions can get stored in the data table.
13 It indicates that in the data being inserted, the column must have some value and can not be 1
left NULL.
14 This constraint ensures that for an attribute there will be unique value for each row and no
value is being repeated in any other row for that attribute.
15 This constraint is used to ensure the referential integrity of data in the table. It matches the 1
value of the column designated as the foreign key in one table with another table’s Primary
key.
16 No, A Null value is not the same aa zero or a blank space. A zero is a legal numeric value 1
and blank space is legal character value, whereas NULL is a legal empty value that cannot
be accessed or compared with other values.
17 The SELECT ALL command will fetch all the rows from a table as per the defined commands. 1
19. COUNT(*)
26 SELECT LENGTH(‘CANDIDE’) 1
---------------------------------------
7
27 SELECT RIGTH(‘ÚSS/23/67/09’,2); 1
-------------------------------------
09
28 SELECT LEFT(‘ÚSS/23/67/09’,3); 1
-------------------------------------
USS
30 SELECT ROUND(15.193,1); 1
---------------------------
15.2
31 SELECT SQRT(26); 1
----------------------
5.09901951
32 SELECT TRUNCATE(15.79,1); 1
------------------------------------
15.7
34 SELECT MONTH(‘2021-02-03’); 1
---------------------------------------
02
35 SELECT DAYNAME(‘2021-02-03’); 1
---------------------------------------
Wednesday
106 | P a g e
SHORT ANSWER QUESTIONS
1. Explain each of the following with illustrations using a table 3
(i) Candidate Key (ii) Primary Key (iii) Foreign Key
2. Observe the following tables TRANSACTIONS and CUSTOMERS carefully and answer the 2
questions that follows :
Table : Transaction
Table : Customer
CNo CNAME
C1 ZEESHAN
C2 AMAN
C3 JASPREET
(i) What is the degree of the table Transaction ? what is the cardinality of the table
Customers ?
(ii) Identify the primary key and candidate keys from the table Transcations.
3. Are count(*) and count(<column-name>) the same functions? Why/ Why not? 2
7. Anjali writes the following commands with respect to a table employee having fields, empno, 2
name, department, commission.
Command1: Select count(*) from employee;
Command2 :Select count(commission) from employee;
She gets the output 4 for the first command but get an output 3 for the second command.
Explain the output with justification.
107 | P a g e
9. A relation Vehicles is given below : 3
Vno Type Company Price Qty
AW125 Wagon Maruti 250000 25
J0083 Jeep Mahindra 4000000 15
S9090 SUV Mitsubishi 2500000 18
M0892 Mini van Datsun 1500000 26
W9760 SUV Maruti 2500000 18
R2409 Mini van Mahindra 350000 15
Write SQL Commands to :
(a) Display the average price of each type of vehicle having quantity more than 20.
(b) Count the type of vehicles manufactured by each company.
(c) Display the total price of all the types of vehicles.
10. Shanya Khanna is using a table Employee. It has the following columns : 2
Admno, Name, Agg, Stream
[Column Agg contain Aggregate marks]
She wants to display the highest Agg obtain in each Stream.
She wrote the following statement:
SELECT Stream, Max(Agg) FROM Employee;
But she did not get the desired result.
Rewrite the above query with necessary changes to help her get the desired output.
11. Write SQL queries for (i) to (iii), which are based on the following table PARTICIPANTS: 3
PNO EVENT SNAME CLASS DOB
P1 DEBATE SANYAM 12 2001-12-25
P2 DEBATE SHRUTI 10 2003-11-10
P3 DEBATE MEHER 12 2001-11-10
P4 QUIZ SAKSHI 11 2002-10-12
P5 QUIZ RITESH 12 2001-10-12
P6 QUIZ RAHUL 10 2003-10-12
P7 CROSSWORD AMEER 11 2002-05-09
P8 CROSSWORD MINAKSHI 12 2001-05-09
(i) To display details of all PARTICIPANTS of class 10 and 12.
(ii) To display the SNAME and Class of all PARTICIPANTS in ascending order of
their SNAME.
(iii) To display the number of PARTICIPANTS along with their respective CLASS, of
every CLASS.
12. Write ouputs for SQL queries (i) to (iii), which are based on the following tables 3
CUSTOMERS and PURCHASES :
Table : CUSTOMERS
CNO CNAME CITIES
C1 SANYAM DELHI
C2 SHRUTI DELHI
C3 MEHER MUMBAI
C4 SAKSHI CHENNAI
C5 RITESH INDORE
C6 RAHUL DELHI
C7 AMEER CHENNAI
C8 MINAKSHI BANGLORE
C9 ANSHUL MUMBAI
108 | P a g e
Table : PURCHASES
SNO QTY PUR_DATE CNO
S1 15 2018-12-25 C2
S2 10 2018-11-10 C1
S3 12 208-11-10 C4
S4 7 2019-01-12 C7
S5 11 2019-02-12 C2
S6 10 2018-10-12 C6
S7 5 2019-05-09 C8
S8 20 2019-05-09 C3
S9 8 208-05-09 C9
S10 15 2018-11-12 C5
S11 6 2018-08-04 C7
13. Write SQL queries for (i) to 9iv), which are based on the tables : CUSTOMERS and 3
PURCHASES given in above. /
(i) To Display details of all CUSTOMERS whose CITIES are neither Delhi nor 4
Mumbai.
(ii) To Display the CNAME and CITIES of all CUSTOMERS in ascending order of
their CNAME.
(iii) To Display the number of CUSTOMERS along with their respective CITITES in
each of the CITITES.
(iv) To Display details of all PURCHASES whose Quantity is more than 15.
14. Consider the following table ACTIVITY and COACH and answer the following parts of this 4
question : Table : ACTIVITY
Table :COACH
PCode Name ACode
1 Ahmad Hussain 1001
2 Ravinder 1008
3 Janila 1001
109 | P a g e
4 Naaz 1003
Give the output of the following SQL queries:
(i) SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY;
(ii) SELECT MAX(ScheduleDate), MIN(ScheduleDate) FROM ACTIVITY;
(iii) SELECT Name,ActivityName FROM ACTIVITY A, COACH C
WHERE A.Acde=C.Acode AND A.ParticipantsNum=10;
(iv) SELECT DISTINCT ParticipantsNum FROM ACTIVITY;
15. Consider the following table STOCK and DEALERS and answer the following parts of this 4
question :
Table :STOCK
Table :DEALERS
Dcode Dname
101 Reliable Stationers
103 Classis Plastics
102 Clear Deals
110 | P a g e
ANSWER
Short Answer Questions
1. (i) Candidate Key :It refers to any column/attribute that can uniquely identify record in a
table.
(ii) Primary key : It referes to designated attribute(s)/column(s) that uniquely identifies a
row/tuple in a table/relation. It is one of the candidates keys.
(iii) Foreign key :is an attribute in a table which is the primary key in linked table
4 The problem with the given SQL query is that there is no GROUP BY clause is given and
thus, it will lead to an error.
The reason being that the select list use COUNT() function, which is an aggregate function,
along with a field. When we use an aggregate function in the select list along with a database
field, we need to add a GROUP BY clause.
To correct the error it should use GROUP BY clasue.
SELECT house, count(*) FROM student
GROUP BY house;
7. The Count(*) function returns the total number of records in the table while count(<field>)
will return the count of non-null values in the given field and this is the reason for the different
results by the given queries above.
The field commission must be containing a NULL value and thus count(commission) returned
the count of non-null values and count(*) return total number of records (Irrespective of
NULL values in the field).
8 SELECT Deptcode,Max(Salary)
FROM Employee
GROUP BY Deptcode;
9 (a) SELECT Type, avg(Price) FROM Vehicle GROUP BY Type having Qty>20;
(b) SELECT Company, count(Distinct Type) FROM Vehicle GROUP BY Compnay;
111 | P a g e
(c) SELECT Type, Sum(Price*Qty) FROM Vehicle GROUP BY Type;
112 | P a g e
15. (i) COUNT(DISTINCT Dcode)
------------------------------
3
(ii) QTY*UnitPrice
------------------
4400
(iii) Item Dname (iv) MIN(StockDate)
------------------------ ------------------------
Eraser Big Clear Deals 01-Jan-09
(a) Identify the table that uses a composite primary key from the library database. 1
(i) Book Table (ii) Member Table (iii) Loan Table (iv) all of these
(b) I. Identify the possible alternate keys from relations Book and Member. 1
(i) Book : Title (ii) Books Author (iii) Member:EmailID (iv) Member:FirstName’
II. Can the Loan relation have an alternate key ?Why ? 1
B1103 - - -
B2902 - - -
B2950 - - -
B3100 - - -
B3275 - - -
Member
BookID
B1103
B2902
B2950
B3100
B3275
113 | P a g e
Write an example of the valid record for the loan relation. Write a query to insert a
valid record in the Loan relation.
(d) Write a SQL query to retrieve the names and email addresses of the members who 1
have not returned their books.
2 A library uses database management system(DBMS) to store the details of the books that it
stocks, its registered membes and the book-loan that the library has made. These details are
stored in a database using the following three relations. Name of the Database : KV Library
• Book (BookID : Char(5), Title : Varchar(25), Author :Varchar(25), Publisher :
Varchar(100))
• Member(MemberID:Char(5), LastName:Varchar(25), FirstName:Varchar(25),
Correspondence-Address : Varchar(100), Pincode : Char(6), DateofBirth : Date,
EmailID : Varchar(50))
• Loan(MemberID: Char(5), BookID:Char(5), LastDate:Date, DueBackDate:Date,
Returned :Boolean)
Note : The Library does not stock more than one copy of the same book.
(a) Identify following types of keys from all the relations of the given database Foreign 2
keys along with parent relations.
(b) Can a relation have multiple foreign keys? Give example. 1
(c) Can a foreign key be part of a primary key? Give example. 1
(d)Write a SQL query to retrieve the names and email addresses of the members 1
belonging to KVS (they have email ids as _____@kvs.in) and wo have not returned their
books.
3. FurnFly is a furniture company selling furniture to customers of its store and operates a
follows:
• The store does not keep the furniture in stock.
• The company places orders for the furniture required from its suppliers ONLY AFTER
a customer places an order at the store.
• When the ordered furniture arrives at the store, the customer is informed via
telephone or e-mail that it is ready for delivery.
• Customers often order more than one type of furniture on the same order, for example,
a sofa, two puffy chairs and centre table.
Details of the furniture, customers and orders are to be stored in a relational database using
the following four relations :
Database Name :FurnFly Furnishers
Furniture (FurnitureID : Char(7), FurnitureName : Varchar(50), Category : Varchar(25),
Price : Float, SupplierName : Varchar(100))
CustomerOrder(OrderId : Number(8,0), CustomerID : Char(10), OrderDate:Date)
CustomerOrderLine :(OrderID : Number(8,0), FurnitureID: Char(7), Quantity:
Number(4,0))
Customer :(CustomerID : Char(10), CustomerName:Varchar(100), EmailAddress :
Varchar(30), TelephoneNumber: Number(15,0))
4. Rachana Mittal runs a beauty parlor. She uses a database management system(DBMS) to
store the information that she needs to manage her business. This information includes
customer contact details, staff names, the treatments that the parlor offer (for example, ‘’Hair
Massage’) and appointment that customers have made for treatments. A separate
appointment must be made for each treatment.
The details are stored in a database using the following four relations:
Customer: (CustomerID, FirstName, LastName, TelephoneNumber, EmailAddress)
Staff :(StaffID, FirstName,LastName, IsQualified)
Treatment: (TreatmentName,Price,TimeTaken,NeedsQualification)
Appointment : (CustomerID,TreatmentName,ApDate,ApTime)
• The IsQualifiedattribute for a member of staff stores one of the value True or False,
to indicate if the member of staff is fully qualified or not.
• The NeedsQualifictionattribute for a treatment stores True or False to indicate if the
treatment can only be given by a qualified member of staff.
• The TimeTakenattribute for a treatment is the number of minutes (a whole number)
that the treatment takes.
(a) Write a SQL statement to create the table staff. 1
(b) Write a query to Insert a record in the table Staff with following data ;
(2009, ‘Sheril’, ‘Mark’, ‘True’)
(c) Which table’s records can be deleted without affecting any other table? 1
(i) Customer (ii) Staff (iii) Treatment (iv) Appointment
(d) Write a query to Modify table Appointment to add a new column StaffID, which
should hold a legal StaffID value from the staff table.
(e) Rachana wants to send e-mail advertisement to all the customers who had a ‘RF 1
Facial’ treatmentin 2020. To send the email, the customer’s email address, firstname
and lastname are needed.
Write a SQL query to retrieve the email address, firstname and lastname of each
customer to whom email should be sent.
Anand
Chetan
Geet
Preeti
(i) Select Name from student where class= ‘XI’ and class=‘XII’;
(ii) Select Name from student where not class= ‘XI’ and class=‘XII’;
(iii) Select Name from student where city = ‘Agra’ or city = ‘Mumbai’;
(iv) Select Name from student where city IN(‘Agra’ , ‘Mumbai’);
(ii)
RollNo Name Class DOB Gender City Marks
6 Maakhiy XI 12/12/94 F Dubai 256
7 Neha X 8/12/95 F Moscow 324
3 Geet XI 6/5/97 F Agra 470
4 Preeti XII 8/8/95 F Mumbai 492
(iii)
Gender Marks
F 256
F 324
F 470
F 492
(iv)
116 | P a g e
Gender Marks
F 492
F 470
F 324
F 256
(iii) Prachi has given the following command to obtain the highest marks 1
SELECT max(Marks) from student where group by class;
But she is not getting the desired result. Help her by writing the correct command.
(a) Select max(Marks) from student where group by class;
(b) Select class, max(Marks) from student group by Marks;
(c) Select class, max(Marks) group by class from students;
(d) Select class, max(Marks) from student group by class;
(iv) State the command to display the average marks scored by students of each gender who 1
are in class XI?
(a) Select Gender, avg(Marks) from student where class= ‘XI’ group by gender;
(b) Select Gender, avg(Marks) from student group by gender where class= ‘XI’;
(c) Select Gender, avg(Marks) group by Gender from student having class= ‘XI’;
(d) Select Gender, avg(Marks) from student group by Gender having class= ‘XI’;
Choose the correct option:
(a) Both (ii) and (iii)
(b) Both (ii) and (iv)
(c) Both (i) and (iii)
(d) Only (iii)
(v) Help Ritesh to write the command to display the name of the youngest student.
(a) Select Name, min(DOB) from student;
(b) Select Name, max(DOB) from student;
(c) Select Name, min(DOB) from student group by Name;
(d) Select Name, maximum(DOB) from student;
ANSWER
CASE STUDY BASED QUESTIONS
1. (a) (iii) Loan Table
(b) I. (i) Book : Title (ii) Member: EmailID
II. No, the Loan relation cannot have alternate key as its primary key is a composite key
having foreign key.
117 | P a g e
(b) Yes, a relation can have multiple foreign keys, e.g., the loan relation given above has
two foreign keys – MemberID and BookID
(c) Yes, a foreign key can be a part of composite primary key, e.g., the primary key of
relation loan is : (MemberID, BookID, LoanDate), which contains two foreign keys :
MemberID and BookID.
(d) Select FristName,LastName, EmailID
From Member, Loan
Where Member.MemberID=Loan.MemberID
AND EmailID LIKE “%@kvs.in” AND Returned = ‘False’;
(c) (ii) Staff table’s records can be deleted without affecting any other table as of now,
because this table is not linked with any other table yet.
(d) Alter Table Appointment Add StaffIDNumber(4,0) NOT NULL Reference Staff(StaffID);
118 | P a g e
(e) Select EmailAddress, FirstName,LastName
From Customer C, Appointment A
Where C.CustomerID=A.CustomerID
AND TreatmentName= ‘RF Facial’;
(ii) (b)
(iii) (d)
(v) (b)
119 | P a g e
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: