0% found this document useful (0 votes)
659 views118 pages

DBMSMCQFINAL

The document contains 12 multiple choice questions about SQL concepts including aggregate functions, joins, subqueries, views and data manipulation. The questions test understanding of SQL clauses like SELECT, FROM, WHERE, GROUP BY and HAVING. They also cover functions like COUNT, SUM, AVG, MIN, MAX, ROUND, TRUNC, and date formatting functions.

Uploaded by

Akhilesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
659 views118 pages

DBMSMCQFINAL

The document contains 12 multiple choice questions about SQL concepts including aggregate functions, joins, subqueries, views and data manipulation. The questions test understanding of SQL clauses like SELECT, FROM, WHERE, GROUP BY and HAVING. They also cover functions like COUNT, SUM, AVG, MIN, MAX, ROUND, TRUNC, and date formatting functions.

Uploaded by

Akhilesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 118

1. Aggregate functions are functions that take a ___________ as input and return a single value.

a) Collection of values
b) Single value
c) Aggregate value
d) Both Collection of values & Single value

Answer: a

2. SELECT __________FROM instructor WHERE dept name= ’Comp. Sci.’;


Which of the following should be used to find the mean of the salary?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)

Answer: b

3. SELECT COUNT (____ ID) FROM teaches WHERE semester = ’Spring’ AND YEAR = 2010;
If we do want to eliminate duplicates, we use the keyword ______ in the aggregate expression.
a) Distinct
b) Count
c) Avg
d) Primary key

Answer: a

4. All aggregate functions except _____ ignore null values in their input collection.
a) Count (attribute)
b) Count(*)
c) Avg
d) Sum

Answer: b

5. The EXISTS keyword will be true if:


a) Any row in the subquery meets the condition only
b) All rows in the subquery fail the condition only
c) Both of these two conditions are met
d) Neither of these two conditions is met

Answer: a

6. The ____ connective tests for set membership, where the set is a collection of values produced by
a select clause. The ____ connective tests for the absence of set membership.
a) Or, in
b) Not in, in
c) In, not in
d) In, or
Answer: c

7. Which of the following should be used to find all the courses taught in the Fall 2009 semester but
not in the Spring 2010 semester.
a) SELECT DISTINCT course id FROM SECTION WHERE semester = ’Fall’ AND YEAR= 2009 AND course
id NOT IN (SELECT course id FROM SECTION WHERE semester = ’Spring’ AND YEAR= 2010);
b) SELECT DISTINCT course_id FROM instructor WHERE name NOT IN (’Fall’, ’Spring’);
c) (SELECT course idFROM SECTIONWHERE semester = ’Spring’ AND YEAR= 2010)
d) SELECT COUNT (DISTINCT ID) FROM takesWHERE (course id, sec id, semester, YEAR) IN (SELECT
course id, sec id, semester, YEARFROM teachesWHERE teaches.ID= 10101);

Answer: a

8. How many tables may be included with a join?


A. One
B. Two
C. Three
D. All the above

Answer: d

9. The SQL WHERE clause


A. Limits the column data that are returned
B. Limits the row data are returned
C. Both A and B are correct.
D. Neither a or b is correct

Answer: b

10. We can test for the nonexistence of tuples in a subquery by using the _____ construct.
a) Not exist
b) Not exists
c) Exists
d) Exist

Answer: b

1. Examine the description of the EMPLOYEES table:


EMP_ID NUMBER (4) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (30)
DEPT_ID NUMBER (2)
JOB_CAT VARCHAR (30)
SALARY NUMBER (8, 2)
Which statement shows the department ID, minimum salary, and maximum salary paid in that
department, only if the minimum salary is less than 5000 and maximum salary is more than 15000?

A. SELECT dept_id, MIN (salary), MAX (salary) FROM employees WHERE MIN(salary) <
5000 AND MAX (salary) > 15000;
B. SELECT dept_id, MIN (salary), MAX (salary) FROM employees WHERE MIN (salary) <
5000 AND MAX (salary) 15000 GROUP BY dept_id;
C. SELECT dept_id, MIN(salary), MAX(salary) FROM employees HAVING MIN (salary) <
5000 AND MAX (salary)
D. SELECT dept_id, MIN (salary), MAX (salary) FROM employees GROUP BY dept_id
HAVING MIN(salary) < 5000 AND MAX (salary) > 15000
E. SELECT dept_id, MIN (salary), MAX (salary) FROM employees GROUP BY dept_id,
salary HAVING MIN (salary) < 5000 AND MAX (salary) > 15000;

ANS: D

2. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) ENAME


VARCHAR2 (25) JOB_ID VARCHAR2(10) Which SQL statement will return the ENAME, length
of the ENAME, and the numeric position of the letter "a" in the ENAME column, for those employees
whose ENAME ends with a the letter "n"?

A. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, 'a') FROM EMPLOYEES


WHERE SUBSTR(ENAME, -1, 1) = 'n';
B. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, ,-1,1) FROM EMPLOYEES
WHERE SUBSTR(ENAME, -1, 1) = 'n';
C. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES
WHERE INSTR(ENAME, 1, 1) = 'n';
D. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES
WHERE INSTR(ENAME, -1, 1) = 'n';

ANS: A

3. You would like to display the system date in the format "Monday, 01 June, 2001". Which
SELECT statement should you use?

A. SELECT TO_DATE (SYSDATE, 'FMDAY, DD Month, YYYY') FROM dual;


B. SELECT TO_CHAR (SYSDATE, 'FMDD, DY Month, YYYY') FROM dual;
C. SELECT TO_CHAR (SYSDATE, 'FMDay, DD Month, YYYY') FROM dual;
D. SELECT TO_CHAR (SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual;
E. SELECT TO_DATE (SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual;

Ans: C
4. What is true about joining tables through an Equijoin?
A. You can join a maximum of two tables through an Equijoin.
B. You can join a maximum of two columns through an Equijoin.
C. You specify an Equijoin condition in the SELECT or FROM clauses of a SELECT statement.
D. To join two tables through an Equijoin, the columns in the join condition must be primary key
and foreign key columns.
E. You can join n tables (all having single column primary keys) in a SQL statement by
specifying a minimum of n-1 join conditions.

Ans. E

5. Which three is true regarding the use of outer joins?


A. You cannot use IN operator in a condition that involves an outer join.
B. You use (+) on both sides of the WHERE condition to perform an outer join.
C. You use (*) on both sides of the WHERE condition to perform an outer join.
D. You use an outer join to see only the rows that do not meet the join condition.
E. In the WHERE condition, you use (+) following the name of the column in the table without
matching rows, to perform an outer join.
F. You cannot link a condition that is involved in an outer join to another condition by using the
OR operator.

a. A,B,C
b. B,C,D
c. D,E,F
d. A,E,F

Ans: d

6. Evaluate the SQL statement:


SELECT ROUND (TRUNC (MOD (1600, 10),-1), 2) FROM dual;
What will be displayed?
A. 0
B. 1
C. 0.00
D. an error statement

Ans A
7. Evaluate the SQL statement:
TRUNCATE TABLE DEPT;
Which three are true about the SQL statement?

A. It releases the storage space used by the table.


B. It does not release the storage space used by the table.
C. You can roll back the deletion of rows after the statement executes.
D. You can NOT roll back the deletion of rows after the statement executes.
E. You must be the owner of the table or have DELETE ANY TABLE system
privileges to truncate the DEPT table
F. An attempt to use DESCRIBE on the DEPT table after the TRUNCATE statement
executes will display an error.
a. A,B,C
b. A,D,E
c. A,D,F
d. A,C,D

Answer: b

8. Which three statements are true regarding sub queries?

A. Multiple columns or expressions can be compared between the main query and sub
query.

B. Main query and sub query can get data from different tables
C. Sub queries can contain GROUP BY and ORDER BY clauses
D. Main query and sub query must get data from the same tables
E. Sub queries can contain ORDER BY but not the GROUP BY clause
F. Only one column or expression can be compared between the main query and
subquery

a. A,B,C
b. B,C,D
c. C,D,E
d. A,D,E

Answer: B

9. View the Exhibit and examine the structure of the PRODUCTS, SALES, and
SALE_SUMMARY tables.
SALE_VW is a view created using the following command:
SQL>CREATE VIEW sale_vw AS SELECT prod_id, SUM(quantity_sold) QTY_SOLD FROM sales
GROUP BY prod_id;
You issue the following command to add a row to the SALE_SUMMARY table:
SQL>INSERT INTO sale_summary (SELECT prod_id, prod_name, qty_sold FROM sale_vw JOIN
products USING (prod_id) WHERE prod_id = 16);

What is the outcome?


A. It executes successfully.
B. It gives an error because a complex view cannot be used to add data into the SALE_SUMMARY
table.
C. It gives an error because the column names in the subquery and the SALE_SUMMARY table do
not match.
D. It gives an error because the number of columns to be inserted does not match with the number of
columns in the SALE_SUMMARY table.

Answer: D

10. Which statements are true regarding the FOR UPDATE clause in a SELECT statement?
a. It locks only the columns specified in the SELECT list.
b. It locks the rows that satisfy the condition in the SELECT statement.
c. It can be used only in SELECT statements that are based on a single table.
d. It can be used in SELECT statements that are based on a single or multiple tables.
e. After it is enforced by a SELECT statement, no other query can access the same rows until a
COMMIT or ROLLBACK is issued.

A. a,b,c
B. b,d,e
C. b,c
D. b,d
E. a,b,c,d,e

Answer: B,D

11. View the Exhibits and examine the structures of the COSTS and PROMOTIONS tables.
Evaluate the following SQL statement:
SQL> SELECT prod_id FROM costs WHERE promo_id IN (SELECT promo_id FROM promotions
WHERE promo_cost < ALL (SELECT MAX(promo_cost) FROM promotions GROUP BY
(promo_end_datepromo_begin_date)));
What would be the outcome of the above SQL statement?

a. It displays prod IDs in the promo with the lowest cost.


b. It displays prod IDs in the promos with the lowest cost in the same time interval.
c. It displays prod IDs in the promos with the highest cost in the same time interval.
d. It displays prod IDs in the promos with cost less than the highest cost in the same time
interval.

Answer: D

12. Evaluate the following SQL statement:


SQL> SELECT cust_id, cust_last_name
FROM customers WHERE cust_credit_limit IN (select cust_credit_limit FROM customers WHERE
cust_city ='Singapore');

Which statement is true regarding the above query if one of the values generated by the subquery is
NULL?

a. It produces an error.
b. It executes but returns no rows.
c. It generates output for NULL as well as the other values produced by the subquery.
d. It ignores the NULL value and generates output for the other values produced by the
subquery.

Answer: C

13. Which of the following is true about the PL/SQL data structure VARRAY?
A - It also has a maximum size that cannot be changed.
B - A VARRAY type is created with the CREATE VARRAY statement, at the schema level.
C - Maximum size of a VARRAY can be changed using the ALTER TYPE statement.
D - Maximum size of a VARRAY can be changed using the ALTER VARRAY statement.

Ans: C

14. Which of the following statements is true about implicit cursors?


A. Implicit cursors are used for SQL statements that are not named.
B. Developers should use implicit cursors with great care.
C. Implicit cursors are used in cursor for loops to handle data processing.
D. Implicit cursors are no longer a feature in Oracle.

Ans: A

15. What is the value of customer_id within the nested block in the example below?
/* Start main block */
DECLARE
customer_id NUMBER(9) := 678;
credit_limit NUMBER(10,2) := 10000;
BEGIN
/* Start nested block */
DECLARE
customer_id VARCHAR2(9) := 'AP56';
current_balance NUMBER(10,2) := 467.87;
BEGIN
-- what is the value of customer_id at this point?
NULL;
END;
END;
Please select the best answer.
A. 678
B. 10000
C. 'AP56'
D. 467.87

Ans: B.

DBMS MCQ
1.You can add a row using SQL in a database with which of the following?
A. ADD B. CREATE
C. INSERT D.MAKE
Answer-c

2.Which of the following is the correct order of keywords for SQL SELECT statements?
A.SELECT,FROM,WHERE B.FROM,WHERE,SELECT
C.WHERE,FROM,SELECT D.SELECT,WHERE,FROM

Answer-A

3. The result of a SQL statement is a(n)_________.


A.report B.form
C.file D.table
Answer-D
4.Which of the following do you need to consider when you make a table in SQL?
A. Data types B.Primary Keys
C.Default Values D.All of the above

Answer-D

5. The view of total database content is


A. Conceptual view B.Internal View
C.External View D.Physical View

Answer-A

7.ODBC stands for


A. Object Database Connectivity.
B. Oral Database Connectivity.
C. Oracle Database Connectivity.
D. Open Database Connectivity.

Answer-D

8.An entity set that does not have sufficient attributes to form a primary key is a
A. strong entity set. B. weak entity set.
C. simple entity set. D. primary entity set.

Answer-B

9.In case of entity integrity, the primary key maybe


A. not Null B. Null
C. both Null & not Null. D. any value.
Answer-A

10.The database environment has all of the following components except:


A. Users B. separate files.
C. Database D. database administrator.

Answer-A

12.A logical schema


A. is the entire database.
B. is a standard way of organising information into accessible parts.
C. describes how data is actually stored on disk.
D. both (A) and (C)
Answer-A
13.The property/properties of a database is/are:
A. It is an integrated collection of logically related records.
B. It consolidates separate files into a common pool of data records.
C. Data stored in a database is independent of the application programs using it.
D. All of the above.
Answer-d

14.Key to represent the relationship between tables is called


A. Primary key
B. Secondary Key
C. Foreign Key
D. None of these
Answer-c

1. Select invalid variable types


A. CHAR
B. VARCHAR1
C. VARCHAR2
D. INTEGER
Answer-B

2. Which of the following is used to declare a record?


A. %ROWTYPE
B. %TYPE
C. Both A & B
D. None of the above
Answer-A

3. In a PL/SQL block, a variable is declared as NUMBER without an initial value.


What will its value be when it is first used in the executable section of the
PL/SQL block?
A. NULL
B. 0
C. Results in a compilation error
D. An exception will be raised
Answer-A

4. Which of the following is true about PL/SQL programs?


A. PL/SQL programs can exist with or without any SQL statements.
B. PL/SQL programs can exist only with any SQL statements.
C. PL/SQL programs can exist only without any SQL statements
D. SQL programs can exist only with PL/SQL statements
Answer-A

5. Which of the following is not true about keywords?


A. Reserved words and keywords are identifiers that have special meaning in
PL/SQL.
B. The difference between reserved words and keywords is that reserved words
cannot be used as identifiers.
C. Keywords can be used as identifiers, but it is not recommended
D. Reserved keywords can be used as ordinary user-defined identifiers.

Answer-D

6. Which of the following keyword is used with Data Control Language (DCL)
statements?
A. SELECT
B. INSERT
C. DELETE
D. GRANT
Answer-D

7. A type of query that is placed within a WHERE or HAVING clause of another query
is called
A. Master query
B. Sub query
C. Super query
D. Multi-query
Answer-B

8. A command that lets you change one or more fields in a record is


A. Insert
B. Modify
C. Look-up
D. All of the Mentioned
Answer-B

9. Which of the following is a Data Model?


A. Entity-Relationship model
B. Relational data model
C. Object-Based data model
D. All of the above
Answer-D
10. The column header is referred to as
A. Table
B. Relation
C. Attributes
D. Domain
Answer-C

1. Which data manipulation command is used to combines the records from


one or more tables?
A. SELECT

B. PROJECT

C. JOIN

D. PRODUCT

Answer-C

2. SQL permits attribute names to be repeated in the same relation. (True or


False)
A. FALSE
B. TRUE
Answer-A

3. Which of the following operations requires the relations to be union


compatible?
A. UNION

B. INTERSECTION

C. DIFFERENCE

D. ALL OF THESE

Answer-D

4. Which of the following is a legal expression in SQL?


A. SELECT NULL FROM SALES;
B. SELECT NAME FROM SALES;

C. SELECT * FROM SALES WHEN PRICE = NULL;

D. SELECT # FROM SALES;

Answer-B

5. The COUNT function in SQL returns the number of ______________


A. Values

B. Distinct values

C. Group By

D. Columns

Answer-A

6. The virtual table that its created by data from the result of an SQL 'Select'
statement is called _________
A. View

B. Synonym

C. Sequence

D. Transaction

Answer-A

7. What is the other name of INNER JOIN?

a) Equi Join
b) In Join
c) Out Join
d) All of the above
Answer-A

8. List the types of Inner join?

a) Out, In, Equi


b) Left, In, Cross
c) Equi, Natural

d) None of the above

Answer-C
9-What is the purpose of index in SQL server?

a) It leads to enhance the query performance.


b) It leads to provide an index to a record.
c) It leads to perform fast searches.
d) All of the above.
Answer-D

10. Does index take space in Disk?

a) It stores in memory as and when required.


b) Yes, Indexes are stored on the disk.
c) Indexes are never stored on the disk.
d) Index takes no space.

Answer-B

1. Consider the above tables A, B and C. How many tuples does the result of the following
SQL query contains?
Table A
Id Name Age
----------------
12 Arun 60
15 Shreya 24
99 Rohit 11

Table B
Id Name Age
----------------
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11

Table C
Id Phone Area
-----------------
10 2200 02
99 2100 01

SELECT A.id
FROM A
WHERE A.age > ALL (SELECT B.age
FROM B
WHERE B. name = "arun")
a. 4 b. 3 c. 0 d. 1
Answer-B
Explanation. The meaning of “ALL” is the A.Age should be greater than all the values
returned by the subquery. There is no entry with name “arun” in table B. So the subquery will
return NULL. If a subquery returns NULL, then the condition becomes true for all rows of A
(See this for details). So all rows of table A are selected.

2. Database table by name Loan_Records is given below.


Borrower Bank_Manager Loan_Amount
Ramesh Sunderajan 10000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 7000.00
What is the output of the following SQL query?

SELECT Count(*) FROM ( ( SELECT Borrower, Bank_Manager FROM Loan_Records)


AS S NATURAL JOIN ( SELECT Bank_Manager, Loan_Amount FROM Loan_Records)
AS T );
a. 3 b. 9 c. 5 d.6
Answer-C

Explanation: Following will be the result of natural join of above two tables. The key thing
to note is that the natural join happens on column name with same name which is
Bank_Manager in the above example. “Sunderajan” appears two times in Bank_Manager
column, so their will be four entries with Bank_Manager as “Sunderajan”.
Borrower Bank_Manager Load_Amount
------------------------------------
Ramesh Sunderajan 10000.00
Ramesh Sunderajan 7000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 10000.00
Mahesh Sunderajan 7000.00

3. Consider a relational table with a single record for each registered student with the
following attributes.
1. Registration_Number:< Unique registration number for each registered student 2.
UID: Unique Identity number, unique at the national level for each citizen 3.
BankAccount_Number: Unique account number at the bank. A student can have
multiple accounts or joint accounts. This attributes stores the primary account number
4. Name: Name of the Student 5. Hostel_Room: Room number of the hostel Which of
the following options is INCORRECT?
(A) BankAccount_Number is a candidate key
(B) Registration_Number can be a primary key
(C) UID is a candidate key if all students are from the same country
(D) If S is a superkey such that S ∩ UID is NULL then S ∪ UID is also a superkey
Answer-A

Explanation: A Candidate Key value must uniquely identify the corresponding row in table.
BankAccount_Number is not a candidate key. As per the question “A student can have
multiple accounts or joint accounts. This attribute stores the primary account number”. If two
students have a joint account and if the joint account is their primary account, then
BankAccount_Number value cannot uniquely identify a row.

4. A relational schema for a train reservation database is given below.


Passenger (pid, pname, age)
Reservation (pid, class, tid)
Table: Passenger
pid pname age
-----------------
0 Sachin 65
1 Rahul 66
2 Sourav 67
3 Anil 69

Table : Reservation
pid class tid
---------------
0 AC 8200
1 AC 8201
2 SC 8201
5 AC 8203
1 SC 8204
3 AC 8202
What pids are returned by the following SQL query for the above instance of the
tables?

SELECT pid FROM Reservation WHERE class ‘AC’ AND EXISTS (SELECT * FROM
Passenger WHERE age > 65 AND Passenger. pid = Reservation.pid)
(A) 1, 0
(B) 1, 2
(C) 1, 3
(D) 1, 5
Answer-C

Explanation: When a subquery uses values from outer query, the subquery is called correlated
subquery. The correlated subquery is evaluated once for each row processed by the outer
query.
The outer query selects 4 entries (with pids as 0, 1, 5, 3) from Reservation table. Out of these
selected entries, the subquery returns Non-Null values only for 1 and 3.
5. Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Consider the following relational query on the above database:
SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid
FROM Parts P
WHERE P.color<> 'blue'))
Assume that relations corresponding to the above schema are not empty. Which one of the
following is the correct interpretation of the above query?

a. Find the names of all suppliers who have supplied a non-blue part.

b. Find the names of all suppliers who have not supplied a non-blue part.

c. Find the names of all suppliers who have supplied only blue parts.

d. Find the names of all suppliers who have not supplied only blue

parts.

Answer-D

Explanation: (A): False, as this may include blue parts and may not include "null"
parts. (B): Obviously false because it returning other than any blue part. (C): Obviously false
because it does not return this. (D): Correct

6. Consider the following relational schema:


employee(empId, empName, empDept)
customer(custId, custName, salesRepId, rating)
salesRepId is a foreign key referring to empId of the employee relation. Assume that each
employee makes a sale to at least one customer. What does the following query return?
SELECT empName
FROM employee E
WHERE NOT EXISTS ( SELECT custId
FROM customer C
WHERE C.salesRepId = E.empId
AND C.rating <> `GOOD`);
a. Names of all the employees with at least one of their customers having a

‘GOOD’ rating.

b. Names of all the employees with at most one of their customers having a

‘GOOD’ rating.

c. Names of all the employees with none of their customers having a ‘GOOD’

rating.

d. Names of all the employees with all their customers having a ‘GOOD’

rating.

Answer-D

7. Consider the relation "enrolled(student, course)" in which (student, course) is the primary
key, and the relation "paid(student, amount)" where student is the primary key. Assume no
null values and no foreign keys or integrity constraints. Given the following four queries:
Query1: select student from enrolled where
student in (select student from paid)
Query2: select student from paid where
student in (select student from enrolled)
Query3: select E.student from enrolled E, paid P
where E.student = P.student
Query4: select student from paid where exists
(select * from enrolled where enrolled.student
= paid.student)
Which one of the following statements is correct?
A-All queries return identical row sets for any database

B-Query2 and Query4 return identical row sets for all databases but there

exist databases for which Query1 and Query2 return different row sets.

C-There exist databases for which Query3 returns strictly fewer rows than

Query2
D-There exist databases for which Query4 will encounter an integrity

violation at runtime.

Explanation:
Take an example:
Table enrolled
student course
----------------
abc c1
xyz c1
abc c2
pqr c1

Table paid
student amount
-----------------
abc 20000
xyz 10000
rst 10000

Output of Query 1
abc
abc
xyz

Output of Query 2
abc
xyz

Output of Query 3
abc
xyz
Output of Query 4
abc
xyz
Query 1 and Query 3 may return repetitive student values as "student" is not a key in relation
enrolled, however query 2 and query 4 always return same row sets. So, option (B) is correct.

8. The following table has two attributes A and C where A is the primary key and C is
the foreign key referencing A with on-delete cascade.
A C
-----
2 4
3 4
4 3
5 2
7 2
9 5
6 4
The set of all tuples that must be additionally deleted to preserve referential integrity
when the tuple (2,4) is deleted is:
(a) (3,4) and (6,4)
(b) (5,2) and (7,2)
(c) (5,2), (7,2) and (9,5)
(d) (3,4), (4,3) and (6,4)
Answer-C

When (2,4) is deleted. Since C is a foreign key referring A with delete on cascade, all entries
with value 2 in C must be deleted. So (5, 2) and (7, 2) are deleted. As a result of this 5 and 7
are deleted from A which causes (9, 5) to be deleted.
9. The relation book (title, price) contains the titles and prices of different books.
Assuming that no two books have the same price, what does the following SQL query
list?
select title
from book as B
where (select count(*)
from book as T
where T.price > B.price) < 5
(a) Titles of the four most expensive books
(b) Title of the fifth most inexpensive book
(c) Title of the fifth most expensive book
(d) Titles of the five most expensive books
Answer-D

Explanation: When a subquery uses values from outer query, the subquery is
called correlated subquery. The correlated subquery is evaluated once for each row processed
by the outer query.
The outer query selects all titles from book table. For every selected book, the subquery
returns count of those books which are more expensive than the selected book. The where
clause of outer query will be true for 5 most expensive book. For example count (*) will be 0
for the most expensive book and count(*) will be 1 for second most expensive book.

10. Consider the following ER diagram.

The minimum number of tables needed to represent M, N, P, R1, R2 is


(A) 2
(B) 3
(C) 4
(D) 5
Answer-B

Explanation: Answer is B, i.e, 3 minimum tables.


M, P are strong entities hence they must be represented by separate tables.
Many-to-one and one-to-many relationship sets that are total on the many-side can be
represented by adding an extra attribute to the “many” side, containing the primary key of the
“one” side. ( This way no extra table will be needed for Relationship sets )
M table is modified to include primary key of P side(i.e. P1). N is weak entity, and is
modified to include primary key of P (i.e, P1).
Therefore there would be minimum of 3 tables with schema given below :
M ( M1, M2, M3, P1)
P ( P1, P2 )
N ( P1, N1, N2 )

11. Consider the following relation schema pertaining to a students database:


Student (rollno, name, address)
Enroll (rollno, courseno, coursename)
where the primary keys are shown underlined. The number of tuples in the Student and Enroll
tables are 120 and 8 respectively. What are the maximum and minimum number of tuples that
can be present in (Student * Enroll), where '*' denotes natural join ?
a. 8,8 b. 120,8 c. 960, 8 d. 960,120
Answer-A

Explanation: The result of the natural join is the set of all combinations of tuples in R and S
that are equal on their common attribute names. What is the maximum possible number of
tuples? The result of natural join becomes equal to the Cartesian product when there are no
common attributes. The given tables have a common attribute, so the result of natural join
cannot have more than the number of tuples in larger table.
Student
-------------------------------------
Rollno name Address
-------------------------------------
1 a abc
2 b bcd
3 c cde

Enroll
----------------------------------------------
Rollno Courseno Coursename
----------------------------------------------
1 12 pqr
1 14 qrs
1 15 rst
2 13 uvw
2 14 qrs

Result of natural join


----------------------------------------------
Rollno Name Address Courseno Coursename
----------------------------------------------
1 a abc 12 pqr
1 a abc 14 qrs
1 a abc 15 rst
2 b bcd 13 uvw
2 b bcd 14 qrs
What is the minimum possible number of tuples?
a. 8 b. 6. c. 7 d. 12
Answer-A

It might be possible that there is no rollno common. In that case, the number of tuples would
be 0. But in the question rollno is a primary key in Student table and it is a prime attribute in
the Enroll table. So there is no chance of having null values in the rollno column in enroll
table and Student table and every tuple in Enroll will have a parent. So minimum number of
tuples possible are 8 (only 8 tuples in the Enroll table). Option (A) is correct.

12. The employee information in a company is stored in the relation


Employee (name, sex, salary, deptName)
Consider the following SQL query
select deptName from Employee where sex = 'M' group by deptName having avg
(salary) > (select avg (salary) from Employee)
It returns the names of the department in which
a. the average salary is more than the average salary in the company

b. the average salary of male employees is more than the average salary of all

male employees in the company

c. the average salary of male employees is more than the average salary of

employees in the same department

d. the average salary of male employees is more than the average salary

in the company

Answer-D

In this SQL query, we have


select deptName --------------- Select the department name
from Employee ---------------- From the database of employees
where sex = 'M' --------------- Where sex is male (M)
group by deptName ------------- Group by the name of the department
having avg (salary) >
(select avg (salary) from Employee) ----- Having the average salary
greater than the average salary of all employees in the
organization.
So, this query would return the name of all departments in which the average salary of male
employees is greater than the average salary of all employees in the company. Hence, D is the
correct choice

13. Consider the set of relations shown below and the SQL query that follows.
Students: (Roll_number, Name, Date_of_birth)
Courses: (Course number, Course_name, Instructor)
Grades: (Roll_number, Course_number, Grade)
select distinct Name
from Students, Courses, Grades
where Students. Roll_number = Grades.Roll_number
and Courses.Instructor = Korth
and Courses.Course_number = Grades.Course_number
and Grades.grade = A
Which of the following sets is computed by the above query?
a. Names of students who have got an A grade in all courses taught by Korth

b. Names of students who have got an A grade in all courses

c. Names of students who have got an A grade in at least one of the

courses taught by Korth

d. None of the above

Answer-C

Explanation:
The query gives the name of all the students who have scored "A" grade in any of the courses
that are taught by Korth. So, C is the correct choice.

14. Consider the following relation


Cinema (theater, address, capacity)
Which of the following options will be needed at the end of the SQL query
SELECT P1. address
FROM Cinema P1
Such that it always finds the addresses of theaters with maximum capacity?
a. WHERE P1. Capacity> = All (select P2. Capacity from Cinema P2)

b. WHERE P1. Capacity> = Any (select P2. Capacity from Cinema P2)
c. WHERE P1. Capacity > All (select max(P2. Capacity) from Cinema P2)

d. WHERE P1. Capacity > Any (select max (P2. Capacity) from Cinema P2)

Answer-A

Explanation:
When the ALL condition is followed by a list, the optimizer expands the initial condition to
all elements of the list and strings them together with AND operators. When
the ANY condition is followed by a list, the optimizer expands the initial condition to all
elements of the list and strings them together with OR operators

15. Consider the relations r1(P, Q, R) and r2(R, S, T) with primary keys P and R respectively.
The relation r1 contains 2000 tuples and r2 contains 2500 tuples. The maximum size of the
join r1⋈ r2 is :
a. 2000

b 2500

c. 4500

d. 5000

Answer-A

Explanation:
r1⋈ r2 is a join operation done on the common attribute R. Further R is the primary key of
R2 When we take a , the value of common attribute( R2 in this case) should match.The value
of R in r2 is matched with corresponding R in r1 . So it will have 2000 tuples. So correct
option is (A).

1. Evaluate the following SQL statement:


A. It executes successfully and displays rows in the descending order of
PROMO_CATEGORY.
B. It produces an error because positional notation cannot be used in the order by clause with set
operators.
C. It executes successfully but ignores the order by clause because it is not located at the end of the
compound statement.
D. It produces an error because the order by clause should appear only at the end of a
compound query-that is, with the last select statement.
ANS: D

2. You want to create a table employees in which the values of columns


EMPLOYEES_ID and LOGIN_ID must be unique and not null. Which two
SQL statements would create the required table?
A. Option A

B. Option B

C. Option C

D. Option D

E. Option E

F. Options F

Answer: F
3. View the Exhibit and examine the structure of the products table.

Using the products table, you issue the following query to generate the names,
current list price, and discounted list price for all those products whose list price falls
below $10 after a discount of 25% is applied on it.

The query generates an error. What is the reason for the error?
A. The parenthesis should be added to enclose the entire expression.
B. The double quotation marks should be removed from the column alias.
C. The column alias should be replaced with the expression in the where clause.
D. The column alias should be put in uppercase and enclosed within double
quotation marks in the where clause.

Answer: C
4. Examine the structure proposed for the transactions table:

Which two statements are true regarding the creation and storage of data in the
above table structure?

A. The CUST_STATUS column would give an error.


B. The TRANS_VALIDITY column would give an error.
C. The CUST_STATUS column would store exactly one character.
D. The CUST_CREDIT_LIMIT column would not be able to store decimal values.
E. Both A and D
F. Both B and C

Answer: F

5. See the Exhibit:

Which two SQL statements would execute successfully?


A. UPDATE promotions SET promo_cost = promo_cost+100 WHERE
TO_CHAR(promo_end_date,'yyyy'>'2000';
B. SELECT promo_begin_date FROM promotions WHERE
TO_CHAR(promo_begin_date,'mon dd yy')='jul 01 98';
C. Only A
D. Only B
E. Both A and B

Answer: E

6. Which three statements/commands would cause a transaction to end? (Choose three.)


A. COMMIT
B. SELECT
C. CREATE
D. ROLLBACK
E. Options A, C, D
Answer: E

7. See the Exhibit

You want to update the CUST_CREDIT_LIMIT column to NULL for all the customers,
where CUST_INCOME_LEVEL has NULL in the CUSTOMERS table. Which SQL
statement will accomplish the task?
A. UPDATE customers
SET cust_credit_limit = NULL
WHERE cust_income_level = NULL;
B. UPDATE customers
SET cust_credit_limit = NULL
WHERE cust_income_level IS NULL;
C. UPDATE customers
SET cust_credit_limit = TO_NUMBER(NULL)
WHERE cust_income_level = TO_NUMBER(NULL);
D. UPDATE customers
SET cust_credit_limit = TO_NUMBER(' ',9999)
WHERE cust_income_level IS NULL;

Answer: B

8. Examine the structure of the MARKS table:

Which two statements would execute successfully?


A. SELECT student_name, subject1 FROM marks
WHERE subject1 > AVG(subject1);

B. SELECT student_name,SUM(subject1) FROM marks


WHERE student_name LIKE 'R%';
C. SELECT SUM (subject1+subject2+subject3) FROM marks
WHERE student_name IS NULL
D. SELECT SUM (DISTINCT NVL(subject1,0)),MAX(subject1) FROM
marks WHERE subject1 > subject2;
E. Both C and D
Answer: E

9. See the Exhibit


Using the PROMOTIONS table, you need to display the names of all promos done after
January 1, 2001 starting with the latest promo. Which query would give the required result?
(Choose all that apply.)
8. SELECT promo_name,promo_begin_date
FROM promotions
WHERE promo_begin_date > '01-JAN-01' ORDER BY 2 DESC;
9. SELECT promo_name,promo_begin_date
FROM promotions
WHERE promo_begin_date > '01-JAN-01' ORDER BY promo_name DESC;
e. SELECT promo_name,promo_begin_date
FROM promotions
WHERE promo_begin_date > '01-JAN-01' ORDER BY 1 DESC;
f. SELECT promo_name,promo_begin_date "START DATE"
FROM promotions
WHERE promo_begin_date > '01-JAN-01' ORDER BY "START DATE" DESC;
g. Both A and D
Answer: E

10. See the Exhibit:

NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and


CUST_CITY that have the same data types and size as the corresponding columns in the
CUSTOMERS table.

Evaluate the following INSERT SQL statement:


The INSERT statement fails when executed. What could be the reason?
A. The VALUES clause cannot be used in an INSERT with a subquery
B. Column names in the NEW_CUSTOMERS and CUSTOMERS tables do not match
C. The WHERE clause cannot be used in a subquery embedded in an INSERT statement
D. The total number of columns in the NEW_CUSTOMERS table does not match the total
number of columns in the CUSTOMERS table
Answer: A

11. Evaluate these two SQL statements:


SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary
DESC;
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC;
What is true about them?
A. The two statements produce identical results.
B. The second statement returns a syntax error.
C. There is no need to specify DESC because the results are sorted in descending
order by default.
D. The two statements can be made to produce identical results by adding a column
alias for the salary column in the second SQL statement.
Answer: A

12. Where can sub queries be used? (Choose all that apply)
A. field names in the SELECT statement
B. the FROM clause in the SELECT statement
C. the HAVING clause in the SELECT statement
D. the GROUP BY clause in the SELECT statement
E. Options A, B
F. the WHERE clause in SELECT as well as all DML statements
G. Options A, B, C, F
Answer: G
13. Consider the following ER diagram.

The minimum number of tables needed to represent M, N, P, R1, R2 is


(A) 2
(B) 3
(C) 4
(D) 5

Explanation: Answer is B, i.e, 3 minimum tables.


M, P are strong entities hence they must be represented by separate tables.
14. EmployeeDetail (EmpId, FullName, ManagerID, DateOfJoining)
EmployeeSalary (EmpID, Project, Salary)
Consider the following relational query on the above database:
SELECT Salary
FROM EmployeeSalary Emp1
WHERE 2 = (
SELECT COUNT( DISTINCT ( Emp2.Salary ) )
FROM EmployeeSalary Emp2
WHERE Emp2.Salary > Emp1.Salary
)
Assume that relations corresponding to the above schema are not empty. Which one of the
following is the correct interpretation of the above query?
a. find the highest salary from table

b. find the 2nd highest salary from table

c. find the 3rd highest salary from table

d. None of above

Answer-C
15. Which of the following are the features of PL/SQL.
 It offers extensive error checking
 It offers numerous data types.
 It offers a variety of programming structures.
 All of the mentioned
Answer-D

1) Which of the following factors indicates that a table is not well-structured?


a. It contains multiple foreign keys.
b. The primary key consists of more than one attribute.
c. The data in the table represents more than one entity.
d. Referential integrity is violated when attempting to enter data.
Answer-C

2) Which SQL command would you use to define the primary key for a new table called
'Employee' with the primary column to be 'empid'?
A: ADD TABLE Employee ADD PRIMARY KEY (empid)

B: ATTACH TABLE Employee ADD


PRIMARY KEY (empid)

C: ADD TABLE Employee ATTACH


PRIMARY KEY (empid)

D: ALTER TABLE Employee ADD PRIMARY


KEY (empid)

Answer-D

3) The 'NULL' represents


A: 0 B: blank space C: absence of any value D: none of the above

Answer-C

4) Which SQL keyword is used to sort the result?


A: ORDER B: SORT-ORDER C: SORT D: ORDER BY

Answer-D
5) To change the value of a customer’s discount from 3 to 5, what command do we need
to use:

e. INSERT b) SELECT c) DELETE d) UPDATE.


Answer-D

6) The WHERE keyword comes before the condition in a normal Select query. When using the
command GROUP BY in the Select query, what keyword is used to start the condition section
?
A) Having B) Find C) Order D) Provide
Answer-A

7) The term first normal form (1NF) describes the tabular format in which
(check only one)

a. all the key attributes are defined


b. there are no repeating groups in the table. Row/column intersection can contain one and
only one value,
not a set of values.
c. all attributes are dependent on the primary key.
d. all of the above.
Answer-B

8) The referential integrity rule requires that (check only one) :


a. it makes it possible for an attribute to have a corresponding value.
b. every null foreign key value must reference an existing primary key value.
c. every non-null foreign key value must reference an existing primary key value
d. it makes it possible to delete a row in one table whose primary key does not have a
matching foreign key value in another table.
Answer-A

9) A table that is in 2NF and contains no transitive dependencies is said to be in


(check only one)

a. 1NF. b. 2NF. c. 3NF. d. 4NF.


Answer-C

10) An entity is in second normal form if:


A. all the values of nonprimary keys are dependent on the full primary key.
B. any nonkey attributes that are dependent on only part of the primary key should be
moved to any entity where that partial key is the actual full key.
C. it must already be in first normal form.
D. all of the above.
Answer-D
11) A functional dependency is a relationship between or among:
A) Tables B) Relations C) Rows D) Attributes

Answer-D

12) The 2NF describes the tabular format in which:


13) A: there are no repeating groups in the table
B: all attributes are dependent on the primary key

C: A & B with no partial dependency

D: there is no partial dependency

Answer-D

14) The process of converting complex object data structures into well-structured relations is
called:
b. object-relational modeling. b. normalization.
c. referential integrity. d. determinant analysis.

Answer-B

15) A relation is considered to be in second normal form if it is in first normal form and it has no
____________ dependencies.
a. referential b. functional c. partial key d. transitive

Answer-C

15) SELECT __________ FROM instructor WHERE dept name= ‘Comp. Sci.’;
Which of the following should be used to find the mean of the salary ?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)

Answer-B
1. .Consider the following two statements about database transaction schedules:

I. Strict two-phase locking protocol generates conflict serializable schedules that are

also recoverable.

II. Timestamp-ordering concurrency control protocol with Thomas’ Write Rule can generate

view serializable schedules that are not conflict serializable.

Which of the above statements is/are TRUE?

A. Neither I nor II
B. I only
C. II only
D. Both I and II

Ans. (d)

2. A relational database contains two tables Student and Performance as shown below:

Roll_no. Student_name Student Roll_no. Student_code Marks


1 Amit 1 A 86
2 Priya 1 B 95
3 Vinit 1 C 90
4 Rohan 2 A 89
5 Smita 2 C 92
3 C 80

Consider the SQL query given


below:
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks > 84
GROUP BY S.Student_name;
The number of rows returned by the above SQL query is ________.

A. 5
B. 11
C. 2
D. NONE OF ABOVE
ANS. A

3. Consider the following relational schemes for a library database: Book (Title, Author, Catalog_no, Publisher,
Year, Price) Collection (Title, Author, Catalog_no) with in the following functional dependencies:

I. Title Author --> Catalog_no


II. Catalog_no --> Title, Author, Publisher, Year
III. Publisher Title Year --> Price
Assume {Author, Title} is the key for both schemes. Which of the following statements is true?

A. Both Book and Collection are in BCNF


B. Both Book and Collection are in 3NF only
C. Book is in 2NF and Collection is in 3NF.
D. Both Book and Collection are in 2NF only.
ANS: C

4. Consider two transactions T1 and T2, and four schedules S1, S2, S3, S4 of
T1 and T2 as given below:
T1 = R1[X] W1[X] W1[Y]
T2 = R2[X] R2[Y] W2[Y]
S1 = R1[X] R2[X] R2[Y] W1[X] W1[Y] W2[Y]
S2 = R1[X] R2[X] R2[Y] W1[X] W2[Y] W1[Y]
S3 = R1[X] W1[X] R2[X] W1[Y] R2[Y] W2[Y]
S1 = R1[X] R2[Y]R2[X]W1[X] W1[Y] W2[Y]
Which of the above schedules are conflict-serializable?
(A) S1 and S2
(B) S2 and S3
(C) S3 only
(D) S4 only

Answer (B)

5. Consider a relation scheme R = (A, B, C, D, E, H) on which the following


functional dependencies hold: {A–>B, BC–> D, E–>C, D–>A}. What are the
candidate keys of R?
(a) AE, BE
(b) AE, BE, DE
(c) AEH, BEH, BCH
(d) AEH, BEH, DEH

Answer (d)

6. The following functional dependencies are given:

AB → CD, AF → D, DE → F, C → G , F → E, G → A
Which one of the following options is false?
(A)CF+ = {ACDEFG}
(B)BG+ = {ABCDG}
(C)AF+ = {ACDEFG}
(D)AB+ = {ABCDFG}

Answer (C)
7. Consider the table employee(empId, name, department, salary) and the two
queries Q1 ,Q2 below. Assuming that department 5 has more than one
employee, and we want to find the employees who get higher salary than
anyone in the department 5, which one of the statements is TRUE for any
arbitrary employee table?
Q1 : Select e.empId
From employee e
Where not exists
(Select * From employee s where s.department = “5” and
s.salary >=e.salary)
Q2 : Select e.empId
From employee e
Where e.salary > Any
(Select distinct salary From employee s Where s.department = “5”)
(A) Q1 is the correct query
(B) Q2 is the correct query
(C) Both Q1 and Q2 produce the same answer.
(D) Neither Q1 nor Q2 is the correct query
Answer A
Create a table like this:

create table employee(empId int(50), name varchar(50), department int(50), salary


int(50));
insert into employee values (1, 'a', 4, 90);
insert into employee values (2, 'b', 5, 30);
insert into employee values (3, 'c', 5, 50);
insert into employee values (4, 'd', 5, 80);
insert into employee values (8, 'f', 7, 10);

Q1 returns 1 for the above table

Q2 returns empId of those employees who get salary more than the minimum salary
offered in department 5. It returns 1,3,4 for the above table.
According the question the answer should be 1 for the above table.
The question implies that the required employee must not be from
department 5.

8. Consider the table R with attributes A, B and C. The functional dependencies that
hold on R are : A → B, C → AB. Which of the following statements is/are True ? I.
The decomposition of R into R1(C, A) and R2(A, B) is lossless. II. The decomposition
of R into R1(A, B) and R2(B, C) is lossy.
a) Only I

b) Only II

c) Both I and II

d) Neither I nor II

Answer c

9. Examine the data in the ORD_ITEMS table:

Evaluate the following query:

Which statement is true regarding the outcome of the above query?


A. It gives an error because the having clause should be specified after the
group by clause.

B. It gives an error because all the aggregate functions used in the having clause
must be specified in the select list.

C. It displays the item nos with their average quantity where the average
quantity is more than double the minimum quantity of that item in the table.
D. It displays the item nos with their average quantity where the average quantity
is more than double the overall minimum quantity of all the items in the table.

Answer: C

10 Which of the following gives a logical structure of the database graphically?


a) Entity-relationship diagram
b) Entity diagram
c) Database diagram
d) Architectural representation

ANS: a
11. We indicate roles in E-R diagrams by labeling the lines that connect ___________ to
__________
a) Diamond , diamond
b) Rectangle, diamond
c) Rectangle, rectangle
d) Diamond, rectangle
ANS: d

12. Examine the data in the ename and hiredate columns of the employees table:
You want to generate a list of user IDs as follows:

What is the outcome?


A. It executes successfully and gives the correct output.
B. It executes successfully but does not give the correct output.
C. It generates an error because the REPLACE function is not valid.
D. It generates an error because the SUBSTR function cannot be nested in the
CONCAT function.

Answer: A

13. View the Exhibit and examine the data in the promotions table.

PROMO_BEGIN_DATE is stored in the default date format, dd-mon-rr.


You need to produce a report that provides the name, cost, and start date of all
promos in the post category that were launched before January 1, 2000.
Which SQL statement would you use?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D

14. Which normal form is a table in if it has no multi-valued attributes


and no partial dependencies?
A. First normal form
B. Second normal form
C. Third normal form
D. Fourth normal form

Answer: B

15. Given the following relation instance.


x y z
1 4 2
1 5 3
1 6 3
3 2 2
Which of the following functional dependencies are satisfied by the instance?
(a) XY -> Z and Z -> Y
(b) YZ -> X and Y -> Z
(c) YZ -> X and X -> Z
(d) XZ -> Y and Y -> X
Answer: (b)

 1- Which statement adds a column called salary to the employees table


having 100 rows, which cannot contain null?

A. Option A
B. Option B
C. Option C
D. Option D
Answer: A: Correct because the requirement is add salary with not null
constraint only. Although, B will execute successfully but default constraint is
not required.

 2- You issue the following command to alter the country column in the
departments table:

Which statement is true?


A. It produces an error because column definitions cannot be altered to add default
values.

B. It executes successfully and all the rows that have a null value for the country
column will be updated with the value 'USA'.

C. It executes successfully. The modification to add the default value takes


effect only from subsequent insertions to the table.

D. It produces an error because the data type for the column is not specified.
Answer: C
 3- Examine the structure of the customers table:

CUSTNO is the primary key in the table. You want to find out if any customers'
details have been entered more than once using different CUSTNO, by listing all the
duplicate names.

Which two methods can you use to get the required result?
A. Self-join
B. Subquery
C. Left outer-join with self-join

D. Both A and B

Answer: Correct D
create table customer(
CUSTNO number primary key,
CUSTNAME varchar2(2))

insert into customer values (1,'A')


insert into customer values (2,'b')
insert into customer values (3,'A')
insert into customer values (4,'b')
insert into customer values (5,'A')
insert into customer values (6,'A')
insert into customer values(7,'C')

select distinct a.CUSTNAME from CUSTOMER a ,CUSTOMER b where


a.CUSTNAME=b.CUSTNAME and a.CUSTNO!=b.CUSTNO

select distinct a.CUSTNAME from CUSTOMER a where exists(select 1 from


CUSTOMER b where a.CUSTNAME=b.CUSTNAME and a.CUSTNO!=b.CUSTNO)

 View the Exhibit and examine the data in the products table.

You need to display product names from the products table that belong to the
'software/other' category with minimum prices as either S2000 or S4000 and no
unit of measure.
You issue the following query:
Which statement is true regarding the above query?
A. It executes successfully but returns no result.

B. It executes successfully and returns the required result.

C. It generates an error because the condition specified for


PROD_UNIT_OF_MEASURE is not valid.

D. It generates an error because the condition specified for the prod category column
is not valid.

Answer: A

 The customers table has the following structure

A. Option A
B. Option B
C. Option C
D. Option D
Answer: B

 Examine the description of the EMPLOYEES table:


EMP_ID NUMBER (4) NOT NULL

LAST_NAME VARCHAR2 (30) NOT NULL

FIRST_NAME VARCHAR2 (30)

DEPT_ID NUMBER (2)

JOB_CAT VARCHAR (30)

SALARY NUMBER (8, 2)

Which statement shows the department ID, minimum salary, and maximum salary paid in that department,
only if the minimum salary is less than 5000 and maximum salary is more than 15000?

A. SELECT dept_id, MIN (salary), MAX (salary) FROM employees WHERE MIN(salary) < 5000 AND
MAX (salary) > 15000;
B. SELECT dept_id, MIN (salary), MAX (salary) FROM employees WHERE MIN (salary) < 5000 AND
MAX (salary) 15000 GROUP BY dept_id;
C. SELECT dept_id, MIN(salary), MAX(salary) FROM employees HAVING MIN (salary) < 5000 AND
MAX (salary)
D. SELECT dept_id, MIN (salary), MAX (salary) FROM employees GROUP BY dept_id HAVING
MIN(salary) < 5000 AND MAX (salary) > 15000

ANS: D

7. You would like to display the system date in the format "Monday, 01 June, 2001". Which SELECT
statement should you use?

A. SELECT TO_DATE (SYSDATE, 'FMDAY, DD Month, YYYY') FROM dual;


B. SELECT TO_CHAR (SYSDATE, 'FMDD, DY Month, YYYY') FROM dual;
C. SELECT TO_CHAR (SYSDATE, 'FMDay, DD Month, YYYY') FROM dual;
D. SELECT TO_CHAR (SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual;

Ans: C
format_mask parameter begins with "FM"
8. What is true about joining tables through an Equijoin?

A. You can join a maximum of two tables through an Equijoin.


B. You can join a maximum of two columns through an Equijoin.
C. You specify an Equijoin condition in the SELECT or FROM clauses of a SELECT statement.
D. You can join n tables (all having single column primary keys) in a SQL statement by specifying a
minimum of n-1 join conditions.
Ans. D

9. What is the value of customer_id within the nested block in the example below?
/* Start main block */
DECLARE
customer_id NUMBER(9) := 678;
credit_limit NUMBER(10,2) := 10000;
BEGIN
/* Start nested block */
DECLARE
customer_id VARCHAR2(9) := 'AP56';
current_balance NUMBER(10,2) := 467.87;
BEGIN
-- what is the value of customer_id at this point?
NULL;
END;
END;
Please select the best answer.
A. 678
B. 10000
C. AP56
D. 467.87
Ans: C

10. Which of the following is used to store movie and image files?
a) Clob
b) Blob
c) Binary
d) Image

Answer:-B

11. In SQL the statement select * from R, S is equivalent to


a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S

Answer:-B

12. Choose the correct option regarding the query


SELECT branch_name, COUNT (DISTINCT customer_name)
FROM depositor, account
WHERE depositor.account_number = account.account_number
GROUP BY branch_id
HAVING avg(balance) = 10000;
a) The having clause checks whether the query result is true or not
b) The having clause does not check for any condition
c) The having clause allows only those tuples that have average balance 10000
d) None of the mentioned

Answer:-C
13. How many relations can a delete command operate on?
a) 0
b) 1
c) 2
d) Infinitely many

Answer:-B

14. Choose the correct option regarding the following query


INSERT INTO course ('CS-67' , 'course name', 'any' , 5);
a) Data is inserted into the course relation
b) Data is not inserted into the course relation due to incorrect specification
c) Data is inserted into the CS-67 relation
d) Data is not inserted due to the incorrect use of syntax

Answer:-D
15. The join operations that do not retain mismatched tuples are called as _________ operations
a) outer join
b) natural join
c) full outer join
d) inner join

Correct B,D
DBMS MCQ

1. What is the advantage of using union over union all?

(a)Removes duplicates (b) Ignore nulls (c) add readability (d) none of the above

Answer:-A

2. Which of the following is not an aggregate function?

(a) Sum (b) count (c)avg (d)abs

Answer:-D

2. Which DDL command is used to delete all the data from the table but preserving the structure?

(a) Drop (b) Delete (c) Alter (d) Truncate

Answer:-D

3. Select name, contact from emp where dno= (Select dno from dept where dname=’EC’)

Which of the following field may be used as a foreign key in the above database context?

(a) Name (b) contact (c) dno (d)dname

Answer:-C

4. What is the output of substr(‘Language’,6):

(a)Lang (b) guage (c)uage (d)age

Answer:-D

5. The combination of arithmetic operators used to show not equal to condition is:

(a)=, < (b)>,! (c)!,* (d)<,>

Answer:-D

8. How many sub queries can be included at max in a sql query?

(a)1 (b) 3 (c) any no. Of (d)5

Answer:-C

6. The attribute name could be structured as an attribute consisting of first name, middle initial, and
last name. This type of attribute is called
a) Simple attribute
b) Composite attribute
c) Multi valued attribute
d) Derived attribute

Answer:-B

7. In SQL the statement select * from R, S is equivalent to


a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S

Answer:-B

8. Which of the following is used to store movie and image files?


a) Clob
b) Blob
c) Binary
d) Image

Answer:-B

9. Which of the following is not a property of transactions?


a) Atomicity
b) Concurrency
c) Isolation
d) Durability

Answer:-B

10. Which of the following creates a virtual relation for storing the query?
a) Function
b) View
c) Procedure
d) None of the mentioned

Answer:-B

11. Choose the correct option regarding the query


SELECT branch_name, COUNT (DISTINCT customer_name)
FROM depositor, account
WHERE depositor.account_number = account.account_number
GROUP BY branch_id
HAVING avg(balance) = 10000;
a) The having clause checks whether the query result is true or not
b) The having clause does not check for any condition
c) The having clause allows only those tuples that have average balance 10000
d) None of the mentioned

Answer:-C
12. How many relations can a delete command operate on?
a) 0
b) 1
c) 2
d) Infinitely many

Answer:-B
13. Choose the correct option regarding the following query
INSERT INTO course ('CS-67' , 'course name', 'any' , 5);
a) Data is inserted into the course relation
b) Data is not inserted into the course relation due to incorrect specification
c) Data is inserted into the CS-67 relation
d) Data is not inserted due to the incorrect use of syntax

Answer:-D
14. The join operations that do not retain mismatched tuples are called as _________ operations
a) outer join
b) natural join
c) full outer join
d) inner join

Answer:-D

15. Create view student select ID, address, name from student;

What is the result of the above query?


a) It creates a view named student with 3 attributes
b) It creates a view named student with 1 attribute
c) It creates a view named ID with 2 attributes
d) It is syntactically wrong and does not give a result

Answer:-D

1. Concurrency control is important for which of the following reasons?

a. To ensure data integrity when updates occur to the database in a

multiuser environment

b. To ensure data integrity when updates occur to the database in a

single-user environment

c. To ensure data integrity while reading data occurs to the database

in a multiuser environment

d. To ensure data integrity while reading data occurs to the database

in a single-user environment
Answer D

2. Consider the relation "enrolled(student, course)" in which (student, course) is


the primary key, and the relation "paid(student, amount)" where student is the
primary key. Assume no null values and no foreign keys or integrity
constraints. Given the following four queries:
Query1: select student from enrolled where
student in (select student from paid)
Query2: select student from paid where
student in (select student from enrolled)
Query3: select E.student from enrolled E, paid P
where E.student = P.student
Query4: select student from paid where exists
(select * from enrolled where enrolled.student
= paid.student)
Which one of the following statements is correct?
a. All queries return identical row sets for any database

b. Query2 and Query4 return identical row sets for all databases but

there exist databases for which Query1 and Query2 return different

row sets.

c. There exist databases for which Query3 returns strictly fewer rows

than Query2

d. There exist databases for which Query4 will encounter an integrity

violation at runtime.

Answer B
3. Given relations r(w, x) and s(y, z), the result of
SELECT DISTINCT w, x
FROM r, s
is guaranteed to be same as r, provided
a. r has no duplicates and s is non-empty

b. r and s have no duplicates

c. s has no duplicates and r is non-empty

d. r and s have the same number of tuples

Answer A

4. In SQL, relations can contain null values, and comparisons with null values
are treated as unknown. Suppose all comparisons with a null value are
treated as false. Which of the following pairs is not equivalent?
a. x = 5 AND not(not(x = 5))

b. x = 5 AND x> 4 and x < 6, where x is an integer

c. x ≠ 5 AND not (x = 5)

d. None of the above

Answer C

5. Consider the following Employee table


ID salary DeptName
1 10000 EC
2 40000 EC
3 30000 CS
4 40000 ME
5 50000 ME
6 60000 ME
7 70000 CS
How many rows are there in the result of following query?
SELECT E.ID
FROM Employee E
WHERE EXISTS (SELECT E2.salary
FROM Employee E2
WHERE E2.DeptName = 'CS'
AND E.salary > E2.salary)
a. 0

b. 4

c. 5

d. 6

Answer C

6.

following relations:
SELECT S. Student_Name, sum(P.Marks)
FROM Student S, Performance P
WHERE S.Roll_No = P.Roll_No
GROUP BY S.Student_Name
The number of rows that will be returned by the SQL query is _________
0

1
2

Answer C

7. Which of the following is true? I. Implementation of self-join is possible in SQL with


table alias. II. Outer-join operation is basic operation in relational algebra. III. Natural
join and outer join operations are equivalent.
a. I and II are correct.

b. II and III are correct.

c. Only III is correct.

d. Only I is correct.

Answer d

8) The following table has two attributes A and C where A is the primary key
and C is the foreign key referencing A with on-delete cascade.
A C
-----
2 4
3 4
4 3
5 2
7 2
9 5
6 4
The set of all tuples that must be additionally deleted to preserve referential
integrity when the tuple (2,4) is deleted is:
(a) (3,4) and (6,4)
(b) (5,2) and (7,2)
(c) (5,2), (7,2) and (9,5)
(d) (3,4), (4,3) and (6,4)
Answer (C)
9. Given the following relation instance.
x y z
1 4 2
1 5 3
1 6 3
3 2 2
Which of the following functional dependencies are satisfied by the instance?
(GATE CS 2000)
(a) XY -> Z and Z -> Y
(b) YZ -> X and Y -> Z
(c) YZ -> X and X -> Z
(d) XZ -> Y and Y -> X
Answer: (b)

10) Consider the following schedules involving two transactions. Which one of
the following statements is TRUE?

(A) Both S1 and S2 are conflict serializable.


(B) S1 is conflict serializable and S2 is not conflict serializable.
(C) S1 is not conflict serializable and S2 is conflict serializable.
(D) Both S1 and S2 are not conflict serializable.

Answer (C)

11) Which of the following functional dependencies hold for relations R(A, B,
C) and S(B, D, E):
B → A,
A→C
The relation R contains 200 tuples and the rel ation S contains 100 tuples.
What is the
maximum number of tuples possible in the natural join R◊◊S (R natural join S)
(A) 100
(B) 200
(D) 300
(D) 2000
Answer (A)

12) The following functional dependencies are given:

AB → CD, AF → D, DE → F, C → G , F → E, G → A
Which one of the following options is false?
(A)CF+ = {ACDEFG}
(B)BG+ = {ABCDG}
(C)AF+ = {ACDEFG}
(D)AB+ = {ABCDFG}
Answer (C, D)

13. Consider the data given in above question. Which of the following is a correct attribute
set for one of the tables for the correct answer to the above

question?

A-{M1, M2, M3, P1}

B-{M1, P1, N1, N2}

C-{ M1, P1, N1 }

D-{M1, P1}

Answer (A)

14. Which of the following is the preferred way to recover a database after a system failure?

a. Rollback

b. Rollforward

c. Switch to duplicate database

d. Reprocess transactions

Answer: c
15. What SQL command will allow you to change the table STUDENT to add the constraint
named GradeCheck that states that the values of the Grade column must be greater than 0?

a. ALTER TABLE STUDENT ALTER CONSTRAINT GradeCheck (Grade > 0);

b. ALTER TABLE STUDENT ADD CONSTRAINT GradeCheck (Grade > 0);

c. ALTER TABLE STUDENT ADD CONSTRAINT GradeCheck CHECK (Grade > 0);

d. None of the above is correct.

Answer: c

1. Table employee has 10 records. It has a non-NULL SALARY


column which is also UNIQUE.
The SQL statement
SELECT COUNT(*) FROM employee WHERE SALARY >
ALL (SELECT SALARY FROM EMPLOYEE);
prints
A. 10
B. 9
C. 5
D. 0
ANS D
2. Which of the following is true ?
I. Implementation of self-join is possible in SQL with table alias.
II. Outer-join operation is basic operation in relational algebra.
III. Natural join and outer join operations are equivalent.
(A) I and II are correct.
(B) II and III are correct.
(C) Only III is correct.
(D) Only I is correct.

Answer: (D)

3. Consider a relation book (title, price) which contains the titles and prices of different books.
Assuming that no two books have the same price, what does the following SQL query list ?
Select title
from book as B
where (select count ( * )
from book as T
where T.price > B.price) < 7
(A) Titles of the six most expensive books.
(B) Title of the sixth most expensive books.
(C) Titles of the seven most expensive books.
(D) Title of the seventh most expensive books.

Answer: (C)

4. Consider the following tables :

What will be the output of following SQL query ?


SELECT * FROM EMPLOYEE E
WHERE 2 = (SELECT COUNT(DISTINCT E1.SALARY)
FROM EMPLOYEE E1
WHERE E1.SALARY>E.SALARY)

(A) Second highest salary


(B) Two distinct salary of employees
(C) Third highest salary
(D) Employee with second highest salary

Answer: (C)

5. Consider the following two tables and four queries in SQL.


Book (isbn, bname), Stock (isbn, copies)
Query 1:
SELECT B.isbn, S.copies
FROM Book B INNER JOIN Stock S
ON B.isbn = S.isbn;
Query 2:
SELECT B.isbn, S.copies
FROM B B LEFT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 3:
SELECT B.isbn, S.copies
FROM Book B RIGHT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 4:
SELECT B.isbn, S.copies
FROM B B FULL OUTER JOIN Stock S
ON B.isbn = S.isbn;
Which one of the queries above is certain to have an output that is a superset of the outputs of the other three
queries?
(A) Query 1
(B) Query 2
(C) Query 3
(D) Query 4

Answer: (D)

6. Consider the schema


Sailors(sid, sname, rating, age) with the following data

SID SNAME RATING AGE

22 Dustin 7 45

29 Borg 1 33

31 Pathy 8 55

32 Robert 8 25

58 Raghu 10 17

64 Herald 7 35

71 Vishnu 10 16

74 King 9 35

85 Archer 3 26

84 Bob 3 64

96 Flinch 3 17

For the query


SELECT S.rating, AVG(S.age) AS avgage FROM Sailors S
Where S.age >= 18
GROUP BY S.rating
HAVING 1 < (SELECT COUNT(*) FROM Sailors S2 where S.rating = S2.rating)
The number of rows returned is
(A) 6
(B) 5
(C) 4
(D) 3

Answer: (D)
7. Below Query using Case Expression is:

UPDATE Customer
SET State_Code = CASE State_Code
WHEN 'CDG' THEN 'CHANDIGARH'
WHEN 'NDG' THEN 'NEW DELHI'
WHEN 'RJS' THEN 'RAJASTHAN'
ELSE NULL
END
A) Valid
B) Invalid
Answer: (A)

8. A developer would like to use referential datatype declaration on a


variable. The variable name is EMPLOYEE_LASTNAME, and the
corresponding table and column is EMPLOYEE, and LNAME,
respectively. How would the developer define this variable using
referential datatypes?

A. Use employee.lname%type.
B. Use employee.lname%rowtype.
C. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
D. Declare it to be type LONG.
Ans: A

9. Which identifier is valid?

A. customer_12
B. loop
C. customer@orgA
D. 12customer
Ans: A
10. The || is is an example of what function

SELECT last_name || ', ' || first_name || ' ' || middle_name

FROM employees;

A. Incantination
B. Integration
C. Continuation
D. Concatenation
E. None of the above
ANS: D

11. You attempt to query the database with this command:

SELECT nvl (100 / quantity, NONE)


FROM inventory;
Why does this statement cause an error when QUANTITY values are null?
a) The expression attempts to divide by a null value
b) The data types in the conversion function are incompatible
c) The character string none should be enclosed in single quotes (‘ ‘)
d) A null value used in an expression cannot be converted to an actual
value
ANS: A

12. The result of _____unknown is unknown.


a) Xor
b) Or
c) And
d) Not
Answer: d

13. Which of the following deletes all tuples in the instructor relation for those instructors associated
with a department located in the Watson building which is in department relation.
a)
DELETE FROM instructor
WHERE dept_name IN 'Watson';

b)
DELETE FROM department
WHERE building='Watson';

c) DELETE FROM instructor


WHERE dept_name IN (SELECT dept name
FROM department
WHERE building = ’Watson’);

d)None
Answer: c

14. Which of the following relation updates all instructors with salary over $100,000 receive a 3
percent raise, whereas all others receive a 5 percent raise.
a)
UPDATE instructor
SET salary = salary * 1.03
WHERE salary > 100000;
UPDATE instructor
SET salary = salary * 1.05
WHERE salary <= 100000;

b)
UPDATE instructor
SET salary = salary * 1.05
WHERE salary < (SELECT avg (salary)
FROM instructor);

c)
UPDATE instructor
SET salary = CASE
WHEN salary <= 100000 THEN salary * 1.03
ELSE salary * 1.05
END

d) None of the mentioned

Answer: a

15..SELECT *
FROM student JOIN takes USING (ID);

The above query is equivalent to


a)
SELECT *
FROM student INNER JOIN takes USING (ID);

b)
SELECT *
FROM student OUTER JOIN takes USING (ID);

c)
SELECT *
FROM student LEFT OUTER JOIN takes USING (ID);

d) None of the mentioned

Answer: a

1. Consider a relation office with the following schema;


Office(Cabin_no, Room_no, Phone)
Room number is unique. Each room consists of approximately 20 cabins
and each cabin number is unique with respect to room number. The same
cabin number may be used in different rooms. Each room has unique
phone number.
Which of the following is correct?
a) Room_no is a candidate key
b) Phone is a candidate key
c) (Cabin_no, Phone) and (Cabin_no, Room_no) are the candidate keys.
d) (Room_no, Phone) and (Room_no, Cabin_no) are the candidate keys.
Answer C

2. Consider the following schema of relation R;


R (A, B, C)
Attributes A, B, and C are all unique valued attributes. Which of the
following is TRUE for R?
a) A is a candidate key for R
b) B is a candidate key for R
c) (A, C) is a super key for R
d) all of the above
Answer:
d) all of the above

3. For a relation R(A, B, C), if A → B and A → C holds,


then A → BC also holds. Which of the following rule
ensures this?
(a) Augmentation rule
(b) Union rule
(c) Decomposition rule
(d) None of the above
Answer:
(b) Union rule

4. Consider the following ER diagram.

The minimum number of tables needed to represent M, N, P, R1, R2 is


a. 2

b. 3

c. 4

d. 5

Answer b

Q5) Which of the following is not an integrity constraint?


a) Not null
b) Positive
c) Unique
d) Check ‘predicate’

Answer b

6)
CREATE TABLE course
( . . .
FOREIGN KEY (dept name) REFERENCES department
. . . );
Which of the following is used to delete the entries in the referenced table when the tuple is deleted in
course table?
a) Delete
b) Delete cascade
c) Set null
d) All of the mentioned
Answer b

7) If you were collecting and storing information about your music collection, an album would be
considered a(n) _____
a) Relation
b) Entity
c) Instance
d) Attribute
Answer b

8. Evaluate the following query:


SQL> SELECT TRUNC(ROUND(156.00,-1),-1) FROM DUAL;
What would be the outcome?
A. 16
B. 155
C. 157
D. 160

Answer: D

9. Where can subqueries be used?


1. field names in the SELECT statement
2. the FROM clause in the SELECT statement
3. the HAVING clause in the SELECT statement
4. the GROUP BY clause in the SELECT statement
5. the WHERE clause in only the SELECT statement
6. the WHERE clause in SELECT as well as all DML statements

A. 1, 2
B. 1, 3, 6
C. 1, 2, 3, 6
D. 1, 2, 6

Answer: C

10. You created an ORDERS table with the following description:


Name Null Type
----------------- ------------- --------------
ORD_ID NOT NULL NUMBER(2)
CUST_ID NOT NULL NUMBER(3)
ORD_DATE NOT NULL DATE
ORD_AMOUNT NOT NULL NUMBER (10,2)

You inserted some rows in the table. After some time, you want to alter the table by creating the
PRIMARY KEY constraint on the ORD_ID column.

Which statement is true in this scenario?


A. You cannot have two constraints on one column.
B. You cannot add a primary key constraint if data exists in the column.
C. The primary key constraint can be created only at the time of table creation.
D. You can add primary key constraint even if data exists, provided that there are no duplicate
values.
Answer: D

11. You need to extract details of those products in the SALES table where the PROD_ID column
contains the string '_D123'. Which WHERE clause could be used in the SELECT statement to get the
required output?
A. WHERE prod_id LIKE '%_D123%' ESCAPE '_'
B. WHERE prod_id LIKE '%\_D123%' ESCAPE '\'
C. WHERE prod_id LIKE '%_D123%' ESCAPE '%_'
D. WHERE prod_id LIKE '%\_D123%' ESCAPE '\_'

12. Examine the description of the EMPLOYEES table:

EMP_ID NUMBER(4) NOT NULL


LAST_NAME VARCHAR2(30) NOT NULL
FIRST_NAME VARCHAR2(30)
DEPT_ID NUMBER(2)
JOB_CAT VARCHARD2(30)
SALARY NUMBER(8,2)
Which statement shows the maximum salary paid in each job category of each
department?
A. SELECT dept_id, job_cat, MAX(salary)
FROM employees
WHERE salary > MAX(salary);
B. SELECT dept_id, job_cat, MAX(salary)
FROM employees
GROUP BY dept_id, job_cat;
C. SELECT dept_id, job_cat, MAX(salary)
FROM employees;
D. SELECT dept_id, job_cat, MAX(salary)
FROM employees
GROUP BY dept_id;
E. SELECT dept_id, job_cat, MAX(salary)
FROM employees
GROUP BY dept_id, job_cat, salary;
Answer: B
13)
Management has asked you to calculate the value 12*salary* commission_pct for all the
employees in the EMP table. The EMP table contains these columns:
LAST NAME VARCNAR2(35) NOT NULL
SALARY NUMBER(9,2) NOT NULL
COMMISION_PCT NUMBER(4,2)
Which statement ensures that a value is displayed in the calculated columns for all
employees?
A. SELECT last_name, 12*salary* commission_pct
FROM emp;
B. SELECT last_name, 12*salary* (commission_pct,0)
FROM emp;
C. SELECT last_name, 12*salary*(nvl(commission_pct,0))
FROM emp;
D. SELECT last_name, 12*salary*(decode(commission_pct,0))
FROM emp;
Answer: C

14)
Examine the description of the STUDENTS table:
STD_ID NUMBER(4)
COURSE_ID VARCHARD2(10)
START_DATE DATE
END_DATE DATE
Which two aggregate functions are valid on the START_DATE column?
A. SUM(start_date)
B. AVG(start_date)
C. COUNT(start_date)
D. AVG(start_date, end_date)
Answer: C,
Explanation:
It is possible to apply COUNT() and MIN() functions on the column with DATE data type.

15
What does the TRUNCATE statement do?
A. Removes the table
B. Removes all rows from a table
C. Shortens the table to 10 rows
D. Removes all columns from a table
E. Removes foreign keys from a table
Answer: B
Q.1 - Consider the following schema −
STUDENTS(student_code,first_name,last_name, email,
phone_no,date_of_birth,honours_subject,percentage_of_marks);
Which query will display the names and honours subjects of all students and if a
student has not yet been given ahonours subject yet, then it should display ‘No
Honours Yet’.
A - selectfirst_name, last name, nvl(honours_subject, ‘No Honours Yet’) from
students;
B - selectfirst_name, last name, nvl2(honours_subject, ‘No Honours Yet’) from
students;
C - selectfirst_name, last name, honours_subject, from students;
D - selectfirst_name, last name, nullif(honours_subject, ‘No Honours Yet’) from
students;
ANSWER A
Q 2 - Consider the following schema −
STUDENTS(student_code,first_name,last_name, email,
phone_no,date_of_birth,honours_subject,percentage_of_marks);

Which of the following query would correctly display the students’ first name, last name, honours
subject and date of birth, born between July 1st 1996, and 30th June 1999.
A - selectfirst_name, last name, honours_subject, date_of_birth from students where
date_of_birth between ’30-JUN-1999’ and ’01-JUL-1996’;
B - selectfirst_name, last name, honours_subject, date_of_birth from students where
date_of_birth in (’30-JUN-1999’ , ’01-JUL-1996’);
C - selectfirst_name, last name, honours_subject, date_of_birth from students where
date_of_birth like ’30-JUN-1999’ and ’01-JUL-1996’;
D - selectfirst_name, last name, honours_subject, date_of_birth from students where
date_of_birth between ’01-JUL-1996’ and ’30-JUN-1999’;
ANSWER D
Q 3 - Which of the following is not true about single row functions?
A - They operate on single rows only and return one result per row.
B - They accept arguments that could be a column or any expression.
C - They cannot be nested.
D - They may modify the data type.
ANSWER C
Q4 - Which of the following is not a character manipulation function?
A - concat
B - substr
C - instr
D - coalesce
ANSWER D
Q 5 - What is returned by INSTR(‘TUTORIALS PPOINT’, ‘P’)?
A - 11
B- 2
C - PPOINT
D- 12
ANSWER A
Q 6 - What is returned by SUBSTR(‘TUTORIALS POINT’, 1, 9)?
A - TUTORIAL
B- T S
C - TUTORIALS
D - UTORIALS
ANSWER C
Q 7 - What is returned by SUBSTR(‘TUTORIALS POINT’, -1, 1)?
A-T
B - NULL
C-0
D-N
ANSWER A
Q 8- Which of the following is/are true with reference to ‘view’ in DBMS ? (a) A ‘view’
is a special stored procedure executed when certain event occurs. (b) A ‘view’ is a
virtual table, which occurs after executing a pre-compiled query. code:
A – TRUE A
B – FALSE A
C - Both TRUE
D - Both FALSE
ANSWER B
Q 9-

output of the following SQL query?


select count(*) from ((select Employee, Department from
Overtime_allowance) as S natural join (select Department, OT_allowance
from Overtime_allowance) as T);
A- 16

B- 4

C- 8

D- NONE

ANSWER B
Q-10 Consider the set of relations given below and the SQL query that follows
Students : (Roll number, Name, Date of birth)
Courses: (Course number, Course name, instructor)
Grades: (Roll number, Course number, Grade)
SELECT DISTINCT Name
FROM Students, Courses, Grades
WHERE Students.Roll_number = Grades.Roll_number
AND Courses.Instructor =Sriram AND Grades.Grade = A
AND Courses.Course_number = Grades.Course_number

Which of the following sets is computed by the above query?


A- Names of Students who have got an A grade in all courses taught by Sriram
B- Names of Students who have got an A grade in all courses
C- Names of Students who have got an A grade in at least one of the courses
taught by Sriram
D- None of the above
ANSWER C
Q-11 Consider the following three table to store student enrollements in different
courses.
Student(EnrollNo, Name)
Course(CourseID, Name)
EnrollMents(EnrollNo, CourseID)
What does the following query do?
SELECT S.Name
FROM Student S, Course C, Enrollments E
WHERE S.EnrollNo = E.EnrollNo AND
C.Name = "DBMS" AND
E.CourseID = C.CourseID AND
S.EnrollNo IN
(SELECT S2.EnrollNo
FROM Student S2, Course C2, Enrollments E2
WHERE S2.EnrollNo = E2.EnrollNo AND
E2.CourseID = C2.CourseID
C2.Name = "OS")

A- Name of all students who are either enrolled in "DBMS" or "OS" courses
B- Name of all students who are enrolled in "DBMS" and "OS"
C- Name of all students who are either enrolled in "DBMS" or "OS" or both.

D- NONE
ANSWER B

12. The number of tuples in a relation is called its …………. While the number of
attributes in a relation is called it’s ………………..
A) Degree, Cardinality
B) Cardinality, Degree
C) Rows, Columns
D) Columns, Rows
Answer-B
13. …………………… is the process of organizing data into related tables.
A) Normalization
B) Generalization
C) Specialization
D) None of the above
Answer-A

14) Which are the two ways in which entities can participate in a relationship?
A. Passive and active
B. Total and partial
C. Simple and Complex
D. All of the above
Answer-B

15) The language that requires a user to specify the data to be retrieved without specifying exactly
how to get it is
A. Procedural DML
B. Non-Procedural DML
C. Procedural DDL
D. Non-Procedural DDL
Answer-B

 What is the cardinality of table with 1000 rows and 100 column?
a) 10
b) 100
c) 1000
d) None of these

ANS: c

 Examine the structure of the products table:

You want to display the names of the products that have the highest total
value for UNIT_PRICE * QTY_IN_HAND.
Which SQL statement gives the required output?

A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
 You need to produce a report where each customer's credit limit has been
incremented by $1000. In the output, the customer's last name should have
the heading Name and the incremented credit limit should be labeled New
credit Limit. The column headings should have only the first letter of each
word in uppercase.

Which statement would accomplish this requirement?

A. Option A
B. Option B
C. Option C
D. Option D
Answer: C

 View the Exhibit and examine the data in the costs table:

You need to generate a report that displays the IDs of all products in the costs table
whose unit price is at least 25% more than the unit cost. The details should be
displayed in the descending order of 25% of the unit cost.
You issue the following query:

Which statement is true regarding the above query?


A. It executes and produces the required result.
B. It produces an error because an expression cannot be used in the order by
clause.
C. It produces an error because the DESC option cannot be used with an expression
in the order by clause.

D. It produces an error because the expression in the ORDER by clause should


also be specified in the SELECT clause.

Answer: A

 View the Exhibit and examine the structure of the products table
Evaluate the following query:

What would be the outcome of executing the above SQL statement?


A. It produces an error.
B. It shows the names of all products in the table.
C. It shows the names of products whose list price is the second highest in the table.
D. It shows the names of all products whose list price is less than the maximum list
price.
Answer: C

 You issued the following command:


SQL> DROP TABLE employees;
Which three statements are true?
A. All uncommitted transactions are committed.
B. All indexes and constraints defined on the table being dropped are also
dropped.
C. The space used by the employees table is reclaimed immediately.
D. Options A, C
Answer: B

 Examine the create table statements for the stores and sales tables.
SQL> CREATE TABLE stores(store_id NUMBER(4) CONSTRAINT
store_id_pk PRIMARY KEY, store_name VARCHAR2(12), store_address
VARCHAR2(20), start_date DATE);
SQL> CREATE TABLE sales(sales_id NUMBER(4) CONSTRAINT
sales_id_pk PRIMARY KEY, item_id NUMBER(4), quantity NUMBER(10),
sales_date DATE, store_id NUMBER(4), CONSTRAINT store_id_fk
FOREIGN KEY(store_id) REFERENCES stores(store_id));
You executed the following statement:
SQL> DELETE from stores
WHERE store_id=900;
The statement fails due to the integrity constraint error:
ORA-02292: integrity constraint (HR.STORE_ID_FK) violated
Which three options ensure that the statement will execute successfully?
A. Disable the primary key in the STORES table.
B. Use CASCADE keyword with DELETE statement.
C. DELETE the rows with STORE_ID = 900 from the SALES table and
then delete rows from STORES table.
D. Disable the FOREIGN KEY in SALES table and then delete the rows.
E. Options A, C, D
Answer: E

 Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic


values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of
functional dependencies (FDs) so that F+ is exactly the set of FDs that hold
for R. How many candidate keys does the relation R have?

A. 3
B. 4
C. 5
D. 6
Answer: B

 Which of the following is TRUE?


(A) Every relation in 3NF is also in BCNF
(B) A relation R is in 3NF if every non-prime attribute of R is fully functionally
dependent on every key of R
(C) Every relation in BCNF is also in 3NF
(D) No relation can be in both BCNF and 3NF

Answer: (C)

10. Consider a relational table with a single record for each registered student with
the following attributes.
1. Registration_Num: Unique registration number
of each registered student
2. UID: Unique identity number, unique at the
national level for each citizen
3. BankAccount_Num: Unique account number at
the bank. A student can have multiple accounts
or join accounts. This attribute stores the
primary account number.
4. Name: Name of the student
5. Hostel_Room: Room number of the hostel
Which one of the following option is INCORRECT?
(A) BankAccount_Num is candidate key
(B) Registration_Num can be a primary key
(C) UID is candidate key if all students are from the same country
(D) If S is a superkey such that S∩UID is NULL then S∪UID is also a superkey

Answer: (A)

11.. Consider the following relational schema:


Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Assume that, in the suppliers relation above, each supplier and each street within a
city has a unique name, and (sname, city) forms a candidate key. No other functional
dependencies are implied other than those implied by primary and candidate keys.
Which one of the following is TRUE about the above schema?
(A) The schema is in BCNF
(B) The schema is in 3NF but not in BCNF
(C) The schema is in 2NF but not in 3NF
(D) The schema is not in 2NF

Answer: (A)

12. Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, M} and the set of


functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E, H} -> {K, L}, K -> {M}, L -> {N}
on R. What is the key for R?
(A) {E, F}
(B) {E, F, H}
(C) {E, F, H, K, L}
(D) {E}
Answer: (B)

13. The maximum number of super keys for the relation schema R(E,F,G,H) with E as the
key is
(A) 5
(B) 6
(C) 7
(D) 8

Answer: (D)

14. Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional


dependencies hold: {A–>B, BC–>D, E–>C, D–>A}. What are the candidate keys of R?
(A) AE, BE
(B) AE, BE, DE
(C) AEH, BEH, BCH
(D) AEH, BEH, DEH

Answer: (D)

15. The relation scheme Student Performance (name, courseNo, rollNo, grade) has
the following functional dependencies:
name, courseNo → grade
rollNo, courseNo → grade
name → rollNo
rollNo → name
The highest normal form of this relation scheme is
(A) 2 NF
(B) 3 NF
(C) BCNF
(D) 4NF

Answer: (B)
DBMS MCQ
Q1) can use the following three rules to find logically implied functional dependencies. This
collection of rules is called
a) Axioms
b) Armstrong’s axioms
c) Armstrong
d) Closure

2. Relational databases store structured data while Big Data stores data in any format. Most
of real world data is of which type?
(a) Hierarchical (b) Relational (c) Big data (d)Cloud

Ans c

3. Index can be created on multiple attributes as well which is called as:


(a)Primary Index (b)Complex Index (c)Cluster Index (d) Composite Index

Ans d

4) Suppose relation R(A,B) currently has tuples {(1,2), (1,3), (3,4)} and relation S(B,C) currently
has {(2,5), (4,6), (7,8)}. Then the number of tuples in the result of the SQL query:
SELECT*
FROM R NATURALOUTERJOIN S;

a) 2

b) 4

c) 6

d) None of the mentioned

Ans: A

5. Which one of the following depicts the property of transaction that, it must be performed
completely or nor performed at all?
(a) Atomicity (b) Durability (c) Consistency(d) Isolation

Ans A
6.Consider two statements about outer and inner queries in context of SQL sub-queries?
i. The inner queries can get data from only one table
ii. The inner queries can get data from more than one table
Which of the above statements are true?

A. (i)
B. (ii)
C. Both (i) and (ii)
D. Neither (i) nor (ii)

Ans b

7. The value of ‘age’ filed can be calculated by using ‘date-of-birth’ field. This type of
attribute is called
a) Simple attribute
b) Composite attribute
c) Multi valued attribute
d) Derived attribute

Ans d

8. This property express the number of entities to which another entity can be associated in
a relationship:
a) Degree
b) Cardinality
c) Redundancy
d) Anomaly

Ans b

9. Which of the following statements creates a new table temp instructor that has the same
schema as an instructor with no data.
a) create table temp_instructor as select * from instructor;
b) Create table temp_instructoras select * from instructor where 1=2;
c) Create Table as temp_instructor;
d) Create table like temp_instructor;

Ans b
10: In a large DBMS
a. each user can "see" only a small part of the entire database
b. each subschema contains every field in the logical schema
c. each user can access every subschema
d. all of the above
Answer: a

11) Functional Dependencies are the types of constraints that are based on______
a) Key
b) Key revisited
c) Superset key
d) None of the mentioned

Ans A
12) Which prefixes are available to Oracle triggers?
a) : new only
b) : old only
c) Both :new and : old
d) Neither :new nor : old
Ans: c

13) What are the after triggers?


a) Triggers generated after a particular operation
b) These triggers run after an insert, update or delete on a table
c) These triggers run after an insert, views, update or delete on a table
d) All of the mentioned
Ans: b

15: The ascending order of a data hierarchy is:


a. bit-byte-record-field-file-database
b. byte-bit-field-record-file-database
c. bit-byte-field-record-file-database
d. bit-byte-file-record-field-database

Answer: c
11. Select invalid variable types

A. CHAR
B. VARCHAR1
C. VARCHAR2
D. INTEGER

Answer-B

12. Which of the following keyword is used with Data Control Language (DCL)
statements?

 A. SELECT

 B. INSERT

 C. DELETE

 D. GRANT

Answer-D

13. A type of query that is placed within a WHERE or HAVING clause of another
query is called

 A. Master query

 B. Sub query

 C. Super query

 D. Multi-query

Answer-B

14. A command that lets you change one or more fields in a record is
 A. Insert

 B. Modify

 C. Look-up

 D. All of the Mentioned

Answer-B
15. Which of the following is a Data Model?
A. Entity-Relationship model
B. Relational data model
C. Object-Based data model
D. All of the above
Answer-D

16. The column header is referred to as


A. Table
B. Relation
C. Attributes
D. Domain
Answer-C

17. A SQL query automatically eliminates duplicates (True / False) ?

A. TRUE

B. FALSE

Answer-B
18.Which of the following is a comparison operator in SQL?
A. Double equal sign ( == )

B. LIKE

C. BETWEEN

D. Single equal sign ( = )

Answer-A

9. Which function is used to divides one numeric expression by another and get
the remainder ?
A. POWER

B. MOD

C. ROUND

D. REMAINDER
Answer-B

10. The virtual table that its created by data from the result of an SQL
'Select' statement is called _________
A. View

B. Synonym

C. Sequence

D.Transaction

Answer-A

11. The DROP TABLE statement:


a. deletes the table structure only.
b. deletes the table structure along with the table data.
c. works whether or not referential integrity constraints would be violated.
d. is not an SQL statement.

Answer-B

12. SQL views can be used to hide:

a. columns and rows only.

b. complicated SQL syntax only.

c. both of the above can be hidden by an SQL view.

d. None of the above is correct.

Answer-C

13.Which of the following is NOT a type of SQL constraint?


a.PRIMARY KEY
b.FOREIGN KEY
c.ALTERNATE KEY
d. UNIQUE

Answer-C
14. What is an SQL virtual table that is constructed from other tables?
a. Just another table
b. A view
c. A relation
d. Query results

Answer-B

15. When using the SQL INSERT statement:


A .rows can be modified according to criteria only.
b. rows cannot be copied in mass from one table to another only.
c. rows can be inserted into a table only one at a time only.
d. rows can either be inserted into a table one at a time or in groups.

Answer-D

DBMS MCQ
1. Display EmployeeId and EmployeeName of those employees where their Company is
‘Wipro’ or ‘Datamane’.
The EmployeeId should display only the numeric value of the EmployeeId. for example e101
should be displayed as 101.?
(a) Select substr(Empid,2),Ename from emp where company_name in(‘Wipro’,’Datamane’)
(b) Select Empid,Ename from emp where company_name=’Wipro’,’Datamane’
(c) Select Ename,Empid from emp where company_name=’Wipro’ or
company_name=’Datamane’
(d) none of the above

Ans A

2. Relational databases store structured data while Big Data stores data in any format. Most
of real world data is of which type?
(a) Hierarchical (b) Relational (c) Big data (d)Cloud
Ans c

3. Index can be created on multiple attributes as well which is called as:


(a)Primary Index (b) Complex Index (c) Cluster Index (d) Composite
Index

Ans d

4. Which DDL command is used to delete all the data from the table but preserving the
structure?
(a) Drop (b) Delete (c) Alter (d) Truncate

Ans d

5. A functional dependency is a relationship between or among:


(a) Tables (b) Records (c) Attributes (d)Entities

Ans c

6. What is the purpose of second normal form?


(a) Remove duplicates (b) Removes partial dependency
(c)Split composite attributes (d)Removes transitive dependency

Ans b

7. Which one of the following depicts the property of transaction that, it must be performed
completely or nor performed at all?
(a) Atomicity (b) Durability (c) Consistency (d) Isolation

Ans A

8. Consider two statements about outer and inner queries in context of SQL sub-queries?
i. The inner queries can get data from only one table
ii. The inner queries can get data from more than one table
Which of the above statements are true?
A. (i)
B. (ii)
C. Both (i) and (ii)
D. Neither (i) nor (ii)

Ans b

9. The value of ‘age’ filed can be calculated by using ‘date-of-birth’ field. This type of
attribute is called
a) Simple attribute
b) Composite attribute
c) Multi valued attribute
d) Derived attribute

Ans d

10. This property express the number of entities to which another entity can be associated
in a relationship:
a) Degree
b) Cardinality
c) Redundancy
d) Anomaly

Ans b

11. Which of the following statements creates a new table temp instructor that has the
same schema as an instructor with no data.
a) create table temp_instructor as select * from instructor;
b) Create table temp_instructor as select * from instructor where 1=2;
c) Create Table as temp_instructor;
d) Create table like temp_instructor;

Ans b

12. Which of the following is a DCL command?


a) Create
b) Grant, Revoke
c) Commit, Rollback
d) None of the mentioned

Ans b

13. Which of the following makes the transaction permanent in the database?
a) View
b) Commit
c) Rollback
d) Flashback

Ans: B

14) Which of the following statements contains an error?


a) Select * from emp where empid = 10003;
b) Select empid from emp where empid = 10006;
c) Select empid from emp;
d) Select empid where empid = 1009 and lastname = ‘GELLER’;
Ans: d

15) Functional Dependencies are the types of constraints that are based on______
a) Key
b) Key revisited
c) Superset key
d) None of the mentioned

Ans A

 View the Exhibits and examine products and sales tables.


You issue the following query to display product name and the number of times the
product has been sold:

What happens when the above statement is executed?


A. The statement executes successfully and produces the required output.

B. The statement produces an error because item_cnt cannot be displayed in


the outerquery.

C. The statement produces an error because a subquery in the from clause and
outer-joinscannot be used together.

D. The statement produces an error because the group by clause cannot be


used in asubquery in the from clause.

Answer: A

 Examine the types and examples of relationships that follow:


1. One-to-one a) Teacher to students
2. One-to-many b) Employees to Manager
3. Many-to-one c) Person to SSN
4. Many-to-many d) Customers to products
Which option indicates the correctly matched relationships?
A. 1-a, 2-b, 3-c, and 4-d
B. 1-c, 2-d, 3-a, and 4-b
C. 1-c, 2-a, 3-b, and 4-d
D. 1-d, 2-b, 3-a, and 4-c
Answer: C

 ......................... is used to define code that is executed / fired when certain


actions or event occur.
A Cursor
B Trigger
C Keywords
D Replace

Answer: B

4. . A pilot can fly three types of planes and a plane can be piloted by any qualified pilot. The pilot-
plane type relationship is
(a) N:3
(b) 3:N
(c) 1:3
(d) 3:1

Answer: A

5. . Which of the SQL query is legal?


a) SELECT deptno, count(deptno) FROM emp GROUP BY ename;
b) SELECT deptno, count(deptno), job FROM emp GROUP BY deptno;
c) SELECT deptno, avg(sal) FROM emp;
d) SELECT deptno, avg(sal) FROM emp GROUP BY deptno;

Answer: D

6. What will be appropriate SQL Query to find the name of cities with temperature and condition
whose condition is neither sunny nor cloudy
a) SELECT city, temperature, condition FROM weather WHERE condition NOT IN ('sunny', 'cloudy')
b) SELECT city, temperature, condition FROM weather WHERE condition NOT BETWEEN ('sunny',
'cloudy')
c) SELECT city, temperature, condition FROM weather WHERE condition IN ('sunny', 'cloudy')
d) SELECT city, temperature, condition FROM weather WHERE condition BETWEEN ('sunny', 'cloudy')

Answer: A

7. Which of the following is true about the execution section of a PL/SQL block?
a) It is enclosed between the keywords BEGIN and END.
b) It is a mandatory section.
c) It consists of the executable PL/SQL statements.
d) All of the above.

Answer: D

8. The pre-defined exception NO_DATA_FOUND is raised when


a) A null object is automatically assigned a value.
b) A SELECT INTO statement returns no rows.
c) PL/SQL has an internal problem.
d) PL/SQL ran out of memory or memory was corrupted.

Answer: B

9. Which of the following is the syntax for views where v is view name?
a) Create view v as “query name”;
b) Create “query expression” as view;
c) Create view v as “query expression”;
d) Create view “query expression”;

Answer:C

10.Which are the two ways in which entities can participate in a relationship?

(A)Passive and active (B)Total and Partial (C)Simplex and Complex (D)All of the above

Answer: B

11 - Which of the following is not true about SQL statements?

A - SQL statements are not case sensitive.

B - SQL statements can be written on one or more lines.

C - Keywords cannot be split across lines.

D - Clauses must be written on separate lines.


Answer D

12 - Consider the following schema −

STUDENTS(student_code, first_name, last_name, email,


phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following query would display all the students where the second letter in the first name
is ‘i’?
A - select first_name from students where first_name like ‘_i%’;
B - select first_name from students where first_name like ‘%i_’;
C - select first_name from students where first_name like ‘%i%’;
D - select first_name from students where first_name like ‘_i_’;

Answer A

13 - Consider the following schema −

STUDENTS(student_code, first_name, last_name, email,


phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following query would display names of all the students whose email ids are not
provided?
A - select first_name, last name from students where email = 0;
B - select first_name, last name from students where email = ‘ ‘;
C - select first_name, last name from students where email is null;
D - select first_name, last name from students where email = ‘null’;

Answer C

14 - Which of the following is true about Cartesian Products?


A - A Cartesian product is formed when a join condition is omitted.
B - A Cartesian product is formed when a join condition is valid.
C - Some rows in the first table are joined to all rows in the second table.
D - All rows in the first table are joined to some rows in the second table.
Answer A

15. Which of the following is not a database model


A.Network Database Model
B.Relational Database Model
C.Object Oriented Database Model
D.None

Answer : Option D
1. An advantage of the database management approach is
a) Data is dependent on programs.
b) Data redundancy increases.
c) Data is integrated and can be accessed by multiple programs.
d) None of the above.

Answer: C

2. Which one of the following is used to define the structure of the relation, deleting relations and
relating schemas?
a) DML(Data Manipulation Language)
b) DDL(Data Definition Language)
c) Query
d) Relational Schema

Answer: B

3. Aggregate functions can be used in the select list or the_______clause of a select statement or
subquery. They cannot be used in a ______ clause.
a) Where, having
b) Having, where
c) Group by, having
d) Group by, where

Answer: B

4. Data integrity constraints are used to:


a) Control who is allowed access to the data
b) Ensure that duplicate records are not entered into the table
c) Improve the quality of data entered for a specific property (i.e., table column)
d) Prevent users from changing the values stored in the table
Answer: C

5. Updating the value of the view


a) Will affect the relation from which it is defined
b) Will not change the view definition
c) Will not affect the relation from which it is defined
d) Cannot determine
Answer: A

6. A stored procedure in SQL is a___________.


a) Block of functions
b) Group of Transact-SQL statements compiled into a single execution plan.
c) Group of distinct SQL statements.
d) None of mentioned

Answer: B

7. Which of the following options is true regarding the NATURAL JOIN in Oracle DB?
a. While using NATURAL JOIN mentioning the names of all the columns from both the tables is
mandatory
b. NATURAL JOIN can be used only if the names of all the columns of both the tables are identical
c. The join in NATURAL JOIN happens only when the user specifies the columns of the source and the
target tables.
d. There is no need to mention the columns when using NATURAL JOINS.

Answer: D

8. Which group functions ignore NULL values?


a) MAX, COUNT
b) COUNT, SUM
c) MAX, SUM
d) MAX, COUNT, SUM

Answer: D

9. Which of the following statements contains an error?


a) Select * from emp where empid = 10003;
b) Select empid from emp where empid = 10006;
c) Select empid from emp;
d) Select empid where empid = 1009 and lastname = ‘GELLER’;

Answer:D

10. The ______ clause allows us to select only those rows in the result relation of the ____
clause that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where

Answer: A

11. Which of the following is not an integrity constraint?


a) Not null
b) Positive
c) Unique
d) Check ‘predicate’

Answer: B

12. CREATETABLE Manager(ID NUMERIC,Name VARCHAR(20),budget NUMERIC,Details VARCHAR(


30));
Inorder to ensure that the value of budget is non-negative which of the following should be used?
a)Check(budget>0)
b)Check(budget<0)
c)Alter(budget>0)
d) Alter(budget<0)
Answer: A

13. The _____________ is essentially used to search for patterns in target string.
a) Like Predicate
b) Null Predicate
c) In Predicate
d) Out Predicate

Answer: A

14. ______ is a special type of integrity constraint that relates two relations & maintains
consistency across the relations.
a) Entity Integrity Constraints
b) Referential Integrity Constraints
c) Domain Integrity Constraints
d) Domain Constraints

Answer: B

15. The overall description of a database is called______.


A.Data integrity

B.Data manipulation

C.Database schema

D.Data definition
Answer:C

1. View the Exhibit for the structure of the student and faculty tables.
You need to display the faculty name followed by the number of students handled by the
faculty at the base location.
Examine the following two SQL statements:

A. Only statement 1 executes successfully and gives the required result.

B. Only statement 2 executes successfully and gives the required result.

C. Both statements 1 and 2 execute successfully and give different results.

D. Both statements 1 and 2 execute successfully and give the same required result.
Answer: D

2. See the Exhibit


You want to create a SALE_PROD view by executing the following SQL statements:

Which statement is true regarding the execution of the above statement?


A. The view will be created and you can perform DLM operations on the view
B. The view will be created but no DML operations will be allowed on the view
C. The view will not be created because the join statements are not allowed
for creating a view
D. The view will not be created because the GROUP BY clause is not allowed for creating a
view
Answer: B
3. An instance of relational schema R (A, B, C) has distinct values of A including NULL values.
Which one of the following is true?
a) is a candidate key
b) A is not a candidate key
c) A is a primary Key
d) Both (A) and (C)
ANS: b

4. You execute the following commands:

For which substitution variables are you prompted for the input?
A. None, because no input required
B. Both the substitution variables 'hiredate' and 'mgr_id’
C. Only 'hiredate'
D. Only 'mgr_id'
Answer: B
5. View the Exhibit and examine the data in the employees table:

You want to display all the employee names and their corresponding manager
names.
Evaluate the following query:
Which join option can be used in the blank in the above query to get the required
output?
A. INNER JOIN
B. FULL OUTER JOIN
C. LEFT OUTER JOIN
D. RIGHT OUTER JOIN
Answer: C

6. Which of the following single-row operators can be used for


writing a sub-query?

A. >=
B. <
C. =
D. All of the above

Answer: D.

7.You need to find the salaries for all the employees who have a
higher salary than the Vice President of a company 'ABC'.Which of
the following queries will give you the required result? (Consider the
table structure as given)

SQL> DESC employees

Name Null? Type

-----------------------------------------------

EMPLOYEE_ID NOT NULL NUMBER(6)

FIRST_NAME VARCHAR2(20)

LAST_NAME NOT NULL VARCHAR2(25)

EMAIL NOT NULL VARCHAR2(25)


PHONE_NUMBER VARCHAR2(20)

HIRE_DATE NOT NULL DATE

JOB_ID NOT NULL VARCHAR2(10)

SALARY NUMBER(8,2)

COMMISSION_PCT NUMBER(2,2)

MANAGER_ID NUMBER(6)

DEPARTMENT_ID NUMBER(4)

(a)

SELECT first_name, last_name, salary

FROM employees

WHERE salary >(SELECT salary

FROM employees

WHERE job_id ='VICE-PRESIDENT');

(b)

SELECT first_name, last_name, salary

FROM employees

WHERE salary =(SELECT salary

FROM employees

WHERE job_id ='VICE-PRESIDENT');

(c)

SELECT first_name, last_name, salary

FROM employees

WHERE job_id ='VICE-PRESIDENT');

D. None of the above


Answer: A.

8. What will be the outcome of the following query? (Choose the


most appropriate answer)

SQL> DESC employees

Name Null? Type

-----------------------------------------------

EMPLOYEE_ID NOT NULL NUMBER(6)

FIRST_NAME VARCHAR2(20)

LAST_NAME NOT NULL VARCHAR2(25)

EMAIL NOT NULL VARCHAR2(25)

PHONE_NUMBER VARCHAR2(20)

HIRE_DATE NOT NULL DATE

JOB_ID NOT NULL VARCHAR2(10)

SALARY NUMBER(8,2)

COMMISSION_PCT NUMBER(2,2)

MANAGER_ID NUMBER(6)

DEPARTMENT_ID NUMBER(4)

SELECT last_name, job_id, salary

FROM employees

WHERE salary =(SELECT max(salary)

FROM employees);

A. It executes successfully and gives the employees who have salaries equal to
the max salary.
B. It executes successfully but does not give the required results
C. It throws an error as a group function is used in the sub-query
D. It throws an error as a single row sub-query should contain a multi-row
operator
Answer: A.

9.What will be the outcome of the query that follows?

SELECT first_name, last_name, min(salary)

FROM employees

GROUP BY department_id

HAVING MIN(salary)>

(SELECT min(salary)

FROM employees

WHERE department_id =100);

A. It executes successfully and gives the names and minimum salary greater
than department 100 of all employees
B. It executes successfully and gives the salaries of the employees in
department 100
C. It executes successfully and gives the names and minimum salaries of all the
employees.
D. It throws an error.

Answer: A.

10. Which of the following is not a format for Outer Joins in Oracle
DB?

A. Right
B. Left
C. Centre
D. Full

Answer: C.
11. For which two constraints does the Oracle Server implicitly create a unique index?
A. NOT NULL
B. PRIMARY KEY
C. FOREIGN KEY
D. CHECK
E. Default
Answer: B

12 . Consider the following code −


DECLARE
a number(3) := 100;
b number(3) := 200;
BEGIN
IF( a = 100 ) THEN
IF( b <> 200 ) THEN
dbms_output.put_line(b);
END IF;
END IF;
dbms_output.put_line(a);
END;
a) It has syntax error, so there will not be any output.
b) 200
c) 300
d) 100

Answer: D

13. Consider the following code snippet: how many times the loop will run?
DECLARE
a number(2) := 9;
BEGIN
WHILE a < 30 LOOP
a := a + 3;
dbms_output.put_line(a);
END LOOP;
END;
a) 10
b) 8
c) 7
d) 9

Answer: C

14.Consider the join of a relation R with relation S. If R has m tuples and S has n tuples, then the
maximum size of join is:

(A) mn (B) m+n (C) (m+n)/2 (D) 2(m+n)

Answer: A

15 - Consider the following schema −


STUDENTS(student_code, first_name, last_name, email,
phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following query would display all the students whose first name starts with the character
‘A’?
A - select first_name from students where first_name like ‘A%’;
B - select first_name from students where first_name like ‘%A’;
C - select first_name from students where first_name like ‘%A%’;
D - select first_name from students where first_name like ‘A’;
Answer: A

1. Which of the following relational algebra operations do not require the


participating tables to be union-compatible?
(A) Union
(B) Intersection
(C) Difference
(D) Join
Ans: (D)

2. Which of the following is not a property of transactions?


(A) Atomicity
(B) Concurrency
(C) Isolation
(D) Durability
Ans: (B)
3. Checkpoints are a part of
(A) Recovery measures.
(B) Security measures.
(C ) Concurrency measures.
(D) Authorization measures.
Ans: (A)

4. Tree structures are used to store data in


(A) Network model.
(B) Relational model.
(C) Hierarchical model.
(D) File based system.
Ans: (C )

5. Precedence graphs help to find a


(A) Serializable schedule.
(B) Recoverable schedule.
(C) Deadlock free schedule.
(D) Cascadeless schedule.
Ans: (A)

6. It is an abstraction through which relationships are treated as higher level entities


(A) Generalization.
(B) Specialization.
(C) Aggregation.
(D) Inheritance.
Ans: (C )

7. A relation is in ____________ if an attribute of a composite key is dependent on


an attribute of other composite key.
(A) 2NF
(B) 3NF
(C) BCNF
(D) 1NF
Ans: (B)

8. What are the desirable properties of a decomposition?


(A) Partition constraint.
(B) Dependency preservation.
(C) Redundancy.
(D) Security.
Ans: (B)

9. In an E-R diagram double lines indicate


(A) Total participation.
(B) Multiple participation.
(C) Cardinality N.
(D) None of the above.
Ans: (A)

10. In SQL the statement select * from R, S is equivalent to


(A) Select * from R natural join S.
(B) Select * from R cross join S.
(C) Select * from R union join S.
(D) Select * from R inner join S.
Ans: (B)

11. Which of the following is not a consequence of concurrent operations?


(A) Lost update problem.
(B) Update anomaly.
(C) Unrepeatable read.
(D) Dirty read.
Ans: (B)

12. If the closure of an attribute set is the entire relation then the attribute set is a
(A) superkey
(B) candidate key
(C) primary key
(D) not a key
Ans: (A)

13.Which one is correct statement?


Logical data independence provides following without changing application
programs:
(i) Changes in access methods.
(ii) Adding new entities in database
(iii) Splitting an existing record into two or more records
(iv) Changing storage medium
(A) (i) and (ii)
(B) (iv) only,
(C) (i) and (iv)
(D) (ii) and (iii)
Ans: (D)

14. Which of the following statement on the view concept in SQL is invalid?
(A) All views are not updateable
(B) The views may be referenced in an SQL statement whenever tables are
referenced.
(C) The views are instantiated at the time they are referenced and not when they
are defined.
(D) The definition of a view should not have GROUP BY clause in it.

Ans: (D)

15.The FD A B , DB C implies


(A) DA C
(B) A C
(C) B A
(D) DB A
Ans: (A)
1. An instance of relational schema R (A, B, C) has distinct values of A including NULL values.
Which one of the following is true?
e) is a candidate key
f) A is not a candidate key
g) A is a primary Key
h) Both (A) and (C)
ANS: b

2. View the Exhibit and examine the data in the employees table:

You want to display all the employee names and their corresponding manager
names.
Evaluate the following query:

Which join option can be used in the blank in the above query to get the required
output?
A. INNER JOIN
B. FULL OUTER JOIN
C. LEFT OUTER JOIN
D. RIGHT OUTER JOIN
Answer: C

3. Which of the following single-row operators can be used for


writing a sub-query?

E. >=
F. <
G. =
H. All of the above
Answer: D.

4.You need to find the salaries for all the employees who have a
higher salary than the Vice President of a company 'ABC'.Which of
the following queries will give you the required result? (Consider the
table structure as given)

SQL> DESC employees

Name Null? Type

-----------------------------------------------

EMPLOYEE_ID NOT NULL NUMBER(6)

FIRST_NAME VARCHAR2(20)

LAST_NAME NOT NULL VARCHAR2(25)

EMAIL NOT NULL VARCHAR2(25)

PHONE_NUMBER VARCHAR2(20)

HIRE_DATE NOT NULL DATE

JOB_ID NOT NULL VARCHAR2(10)

SALARY NUMBER(8,2)

COMMISSION_PCT NUMBER(2,2)

MANAGER_ID NUMBER(6)

DEPARTMENT_ID NUMBER(4)

(a)

SELECT first_name, last_name, salary

FROM employees

WHERE salary >(SELECT salary

FROM employees

WHERE job_id ='VICE-PRESIDENT');


(b)

SELECT first_name, last_name, salary

FROM employees

WHERE salary =(SELECT salary

FROM employees

WHERE job_id ='VICE-PRESIDENT');

(c)

SELECT first_name, last_name, salary

FROM employees

WHERE job_id ='VICE-PRESIDENT');

D. None of the above

Answer: A.

5. What will be the outcome of the following query? (Choose the


most appropriate answer)

SQL> DESC employees

Name Null? Type

-----------------------------------------------

EMPLOYEE_ID NOT NULL NUMBER(6)

FIRST_NAME VARCHAR2(20)

LAST_NAME NOT NULL VARCHAR2(25)

EMAIL NOT NULL VARCHAR2(25)

PHONE_NUMBER VARCHAR2(20)

HIRE_DATE NOT NULL DATE

JOB_ID NOT NULL VARCHAR2(10)

SALARY NUMBER(8,2)

COMMISSION_PCT NUMBER(2,2)

MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

SELECT last_name, job_id, salary

FROM employees

WHERE salary =(SELECT max(salary)

FROM employees);

E. It executes successfully and gives the employees who have salaries equal to
the max salary.
F. It executes successfully but does not give the required results
G. It throws an error as a group function is used in the sub-query
H. It throws an error as a single row sub-query should contain a multi-row
operator

Answer: A.

6.What will be the outcome of the query that follows?

SELECT first_name, last_name, min(salary)

FROM employees

GROUP BY department_id

HAVING MIN(salary)>

(SELECT min(salary)

FROM employees

WHERE department_id =100);

E. It executes successfully and gives the names and minimum salary greater
than department 100 of all employees
F. It executes successfully and gives the salaries of the employees in
department 100
G. It executes successfully and gives the names and minimum salaries of all the
employees.
H. It throws an error.

Answer: A.
7. Which of the following is not a format for Outer Joins in Oracle
DB?

E. Right
F. Left
G. Centre
H. Full

Answer: C.
8. For which two constraints does the Oracle Server implicitly create a unique index?
A. NOT NULL
B. PRIMARY KEY
C. FOREIGN KEY
D. CHECK
E. Default
Answer: B

9.Consider the join of a relation R with relation S. If R has m tuples and S has n tuples, then the
maximum size of join is:

(A) mn (B) m+n (C) (m+n)/2 (D) 2(m+n)

Answer: A

10 - Which of the following is not true about SQL statements?

A - SQL statements are not case sensitive.

B - SQL statements can be written on one or more lines.

C - Keywords cannot be split across lines.

D - Clauses must be written on separate lines.


Answer D
11. ‘AS’ clause is used in SQL for
(A) Selection operation. (B) Rename operation.
(C) Join operation. (D) Projection operation.
Ans: None of the above…Used for execution time rename only

12 The language which has recently become the defacto standard for
interfacing application programs with relational database system is
(A) Oracle. (B) SQL.
(C) DBase. (D) 4GL.
Ans: B

13 It is possible to define a schema completely using


(A) VDL and DDL. (B) DDL and DML.
(C) SDL and DDL. (D) VDL and DML.
Ans: B
14. Key to represent the relationship between tables is called
(A) Primary key
(B) Secondary Key
(C) Foreign Key
(D) None of these
Ans: C

15. Which of the following are the properties of entities?


(A) Groups (B) Table
(C) Attributes (D) Switchboards
Ans: C

1. A relational database developer refers to a record as


(A) Criteria. (B) a relation.
(C) a tuple. (D) an attribute.
Ans: C

2. Count function in SQL returns the number of


(A) values. (B) distinct values.
(C) groups. (D) columns.
Ans: A

3. An advantage of the database management approach is


(A) data is dependent on programs.
(B) data redundancy increases.
(C) data is integrated and can be accessed by multiple programs.
(D) none of the above.
Ans: C

4. A DBMS query language is designed to


(A) support end users who use English-like commands.
(B) support in the development of complex applications software.
(C) specify the structure of a database.
(D) all of the above.
Ans: D

5. E-R model uses this symbol to represent a weak entity set?


(A) Dotted rectangle.
(B) Diamond
(C) Doubly outlined rectangle
(D) None of these
Ans: C

6. Key to represent the relationship between tables is called


(A) Primary key
(B) Secondary Key
(C) Foreign Key
(D) None of these
Ans: C

7. NULL is
(A) the same as 0 for integer
(B) the same as blank for character
(C) the same as 0 for integer and blank for character
(D) not a value
Ans: D

8. What do you mean by one to many relationship between Teacher and Class
table?
A.One class may have many teachers
B.One teacher can have many classes
C.Many classes may have many teachers
D.Many teachers may have many classes
Ans: B

9. This key that uniquely identifies each record is called :


A.Primary Key
B.Key Record
C.Unique Key
D.Field Name
Ans: A

10. Which name must be unique within a database?


A.Table
B.Field
C.Record
D.Character

Answer : Option A

11. If the tuples are satisfying the where predicate, then they are placed
into groups by the
 Having clause
 Group by clause
 Like clause
 Distinct clause
Answer : Option B

12. Orders table:


O_Id OrderDate OrderPrice Customer
1 2009/12/12 1000 Harry
2 2008/03/23 1600 Nancy
3 2008/09/02 700 Harry
4 2008/09/03 300 Harry
5 2008/08/30 2000 Jensen
6 2008/03/04 100 Nancy

We want to find the total sum (total order) of each customer. Which of the below statement
should we use:

A) SELECT Customer,SUM(OrderPrice) FROM Order


GROUP BY Customer

B) SELECT Customer,SUM(OrderPrice) FROM Orders


GROUP BY Orders

C) SELECT Customer,SUM(OrderPrice) FROM Orders


GROUP BY Customer

D) SELECT Customer,SUM(OrderPrice) FROM Orders


GROUP BY OrderPrice
Ans:-A
13. Which one is correct syntax for Insert Statement?

a) Insert Columns(Col1, Col2,Col3);


b) Insert into (Col1, Col2,Col3) VALUES (Val1,Val2,Val3);
c) Insert Columns(Col1, Col2,Col3) VALUE (Val1, Val2,Val3) Into ;
d) None of the above.
Ans:-D

14. What is the purpose of Order By Clause in SQL server?

a) It is used to sort the result.


b) It is used to change sequence order of columns
c) It can’ be used in SQL Server
d) None of the above
Ans:-A

15. What needs to be added when user want to show results by Descending Order?

a) Descending order cannot be possible.


b) User can add DESC with Order By clause
c) User can add ‘<>ASC’ with Order by Clause.
d) None of the above
Ans:-B

You might also like