250+ TOP MCQs on Join Expressions and Answers

Database Multiple Choice Questions on “Join Expressions”.

1. The____condition allows a general predicate over the relations being joined.
a) On
b) Using
c) Set
d) Where

Answer: a
Clarification: On gives the condition for the join expression.

2. Which of the join operations do not preserve non matched tuples?
a) Left outer join
b) Right outer join
c) Inner join
d) Natural join

Answer: c
Clarification: INNER JOIN: Returns all rows when there is at least one match in BOTH tables.

3.

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
Clarification: Join can be replaced by inner join.

4. What type of join is needed when you wish to include rows that do not have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the mentioned

Answer: c
Clarification: An outer join does not require each record in the two joined tables to have a matching record..

5. How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the mentioned

Answer: d
Clarification: Join can combine multiple tables.

6. Which are the join types in join condition:
a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned

Answer: d
Clarification: There are totally four join types in SQL.

7. How many join types in join condition:
a) 2
b) 3
c) 4
d) 5

Answer: d
Clarification: Types are inner join, left outer join, right outer join, full join, cross join.

8. Which join refers to join records from the right table that have no matching key in the left table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join

Answer: b
Clarification: RIGHT OUTER JOIN: Return all rows from the right table and the matched rows from the left table.

9. The operation which is not considered a basic operation of relational algebra is
a) Join
b) Selection
c) Union
d) Cross product

Answer: a
Clarification: None.

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

Answer: b

250+ TOP MCQs on Reduction to Relational Schemas and Answers

Database Problems on “Reduction to Relational Schemas”.

Consider the following relational schemas and answer the questions below

The section relation


Course_id Sec_id Semester Year Building
BIO-101 1 Spring 2010 Painter
CS-102 4 Summer 2009 Packyard
EE-201 3 Fall 2010 Watson
FIN-301 1 Spring 2011 Richard

The teaches relation


Id Course_id Sec_id Semester Year
1001 CS-101 1 Fall 2009
1002 EE-201 2 Spring 2010
1003 FIN-301 3 Fall 2009
1004 BIO-101 1 Summer 2011

1. Which one of the following can be treated as a primary key in teaches relation?
a) Id
b) Semester
c) Sec_id
d) Year

Answer: a
Clarification: Here Id is the only attribute that has to have a unique entry.

2. The primary key in the section relation is
a) Course_id
b) Sec_id
c) Both Course_id and Sec_id
d) All the attributes

Answer: c
Clarification: Both the entries has unique entry.

3.

SELECT * FROM teaches WHERE Sec_id = 'CS-101';

Which of the following Id is selected for the following query?
a) 1003
b) 1001
c) None
d) Error message appears

Answer: d
Clarification: The value CS-101 matches the Course_id but not Id.

4.

SELECT Id, Course_id, Building FROM SECTION s AND teaches t WHERE t.year=2009;

Which of the following Id are displayed?
a) 1003
b) 1001
c) Both 1003 and 1001
d) Error message appears

Answer: c
Clarification: Two rows are select in the above query.

5. The query which selects the Course_id ‘CS-101’ from the section relation is
a) Select Course_id from section where Building = ‘Richard’;
b) Select Course_id from section where Year = ‘2009’;
c) Select Course_id from teaches where Building = ‘Packyard’;
d) Select Course_id from section where Sec_id = ‘3’;

Answer: b
Clarification: The year ‘2009’ should be selected from the section relation.

6.

CREATE TABLE SECTION
(Course_id VARCHAR (8),
Sec_id VARCHAR (8),
Semester VARCHAR (6),
YEAR NUMERIC (4,0),
Building NUMERIC (15),
PRIMARY KEY (course id, sec id, semester, YEAR),
FOREIGN KEY (course id) REFERENCES course);

Which of the following has an error in the above create table for the relation section
a) Primary key (course id, sec id, semester, year)
b) Foreign key (course id) references course
c) Year numeric (4,0)
d) Building numeric (15)

Answer: d
Clarification: It should be replaced by Year Building varchar (15).

7. The relation with primary key can be created using
a) Create table instructor (Id, Name)
b) Create table instructor (Id, Name, primary key(name))
c) Create table instructor (Id, Name, primary key (Id))
d) Create table instructor ( Id unique, Name )

Answer: c
Clarification: The value Name cannot be a primary key.

8. How can the values in the relation teaches be deleted?
a) Drop table teaches;
b) Delete from teaches;
c) Purge table teaches;
d) Delete from teaches where Id =’Null’;

Answer: b
Clarification: Delete table cleans the entry from the table.

9. In the above teaches relation ” Select * from teaches where Year = ‘2010’” displays how many rows?
a) 2
b) 4
c) 5
d) 1

Answer: a
Clarification: There are two tuples with the year is 2009.

10. The relation changes can be got back using ________ command
a) Flashback
b) Purge
c) Delete
d) Getback

Answer: a
Clarification: Purge deletes the table and delete cleans the table entry.

250+ TOP MCQs on Application Performance and Answers

Database Multiple Choice Questions on “Application Performance”.

1. The indirect change of the values of a variable in one module by another module is called
a) Internal change
b) Inter-module change
c) Side effect
d) Side-module update

Answer: c
Clarification: The module of the search tree and the flow is directed by its values.

2. Which of the following data structure is not linear data structure?
a) Arrays
b) Linked lists
c) Arrays & Linked lists
d) None of the mentioned

Answer: d
Clarification: Both array and linked lists are in data structure concepts.

3. Which of the following data structure is linear data structure?
a) Trees
b) Graphs
c) Arrays
d) None of the mentioned

Answer: c
Clarification: Tree and graphs are not linear.

4. Which of the following criterion is NOT written using the proper syntax?
a) “Haris”
b) <500
c) NO VALUE
d) Between #1/1/2000# and #12/31/2000#

Answer: c
Clarification: NO VALUE cannot be specified.

5. The operation of processing each element in the list is known as
a) Sorting
b) Merging
c) Inserting
d) Traversal

Answer: d
Clarification: There are several types of traversals.

6. Finding the location of the element with a given value is:
a) Traversal
b) Search
c) Sort
d) None of the mentioned

Answer: b
Clarification: Search is performed by traversing through the tree.

7. Arrays are best data structures
a) For relatively permanent collections of data
b) For the size of the structure and the data in the structure are constantly changing
c) All of the mentioned
d) None of the mentioned

Answer: a
Clarification: The operator tree has a tree like format where the evaluation starts from root of the tree.

8. Linked lists are best suited
a) For relatively permanent collections of data
b) For the size of the structure and the data in the structure are constantly changing
c) All of the mentioned
d) None of the mentioned

Answer: b
Clarification: A linked list is a data structure consisting of a group of nodes which together represent a sequence.

9. Each array declaration need not give, implicitly or explicitly, the information about
a) The name of array
b) The data type of array
c) The first data from the set to be stored
d) The index set of the array

Answer: c
Clarification: The operator tree has a tree like format where the evaluation starts from root of the tree.

10. The elements of an array are stored successively in memory cells because
a) By this way computer can keep track only the address of the first element and the addresses of other elements can be calculated
b) The architecture of computer memory does not allow arrays to store other than serially
c) All of the mentioned
d) None of the mentioned

Answer: a
Clarification: Memory is always allotted in order.

250+ TOP MCQs on Query Processing and Answers

Database Multiple Choice Questions on “Query Processing”.

1. A collection of data designed to be used by different people is called a/an
a) Organization
b) Database
c) Relationship
d) Schema

Answer: b
Clarification: Database is a collection of related tables.

2. Which of the following is the oldest database model?
a) Relational
b) Deductive
c) Physical
d) Network

Answer: d
Clarification: The network model is a database model conceived as a flexible way of representing objects and their relationships.

3. Which of the following schemas does define a view or views of the database for particular users?
a) Internal schema
b) Conceptual schema
c) Physical schema
d) External schema

Answer: d
Clarification: An externally-defined schema can provide access to tables that are managed on any PostgreSQL, Microsoft SQL Server, SAS, Oracle, or MySQL database.

4. Which of the following is an attribute that can uniquely identify a row in a table?
a) Secondary key
b) Candidate key
c) Foreign key
d) Alternate key

Answer: b
Clarification: A Candidate Key can be any column or a combination of columns that can qualify as unique key in database.

5. Which of the following are the process of selecting the data storage and data access characteristics of the database?
a) Logical database design
b) Physical database design
c) Testing and performance tuning
d) Evaluation and selecting

Answer: b
Clarification: The physical design of the database optimizes performance while ensuring data integrity by avoiding unnecessary data redundancies.

6. Which of the following terms does refer to the correctness and completeness of the data in a database?
a) Data security
b) Data constraint
c) Data independence
d) Data integrity

Answer: d
Clarification: ACID property is satisfied by transaction in database.

7. The relationship between DEPARTMENT and EMPLOYEE is a
a) One-to-one relationship
b) One-to-many relationship
c) Many-to-many relationship
d) Many-to-one relationship

Answer: b
Clarification: One entity department is related to several employees.

8. A table can be logically connected to another table by defining a
a) Super key
b) Candidate key
c) Primary key
d) Unique key

Answer: c
Clarification: A superkey is a combination of attributes that can be uniquely used to identify a database record.

9. If the state of the database no longer reflects a real state of the world that the database is supposed to capture, then such a state is called
a) Consistent state
b) Parallel state
c) Durable state
d) Inconsistent state

Answer: d
Clarification: SQL data consistency is that whenever a transaction is performed, it sees a consistent database.

10. Ensuring isolation property is the responsibility of the
a) Recovery-management component of the DBMS
b) Concurrency-control component of the DBMS
c) Transaction-management component of the DBMS
d) Buffer management component in DBMS

Answer: b
Clarification: Concurrency control ensures that correct results for concurrent operations are generated while getting those results as quickly as possible.

250+ TOP MCQs on Implementation of Isolation Levels and Answers

Database Multiple Choice Questions on “Implementation of Isolation Levels”.

1. In concurrency control policy the lock is obtained on
a) Entire database
b) A particular transaction alone
c) All the new elements
d) All of the mentioned

Answer: a
Clarification: It is to avoid deadlock.

2. A concurrency-control policy such as this one leads to ______ performance since it forces transactions to wait for preceding transactions to finish before they can start.
a) Good
b) Average
c) Poor
d) Unstable

Answer: c
Clarification: It provides a poor degree of concurrency.

3. __________ are used to ensure that transactions access each data item in order of the transactions’ ____ if their accesses conflict.
a) Zone
b) Relay
c) Line
d) Timestamps

Answer: d
Clarification: When this is not possible, offending transactions are aborted and restarted with a new timestamp.

4. EMPDET is an external table containing the columns EMPNO and ENAME. Which command would work in relation to the EMPDET table?
a)

UPDATE empdet
SET ename = 'Amit'
WHERE empno = 1234;

b)

DELETE FROM empdet
WHERE ename LIKE 'J%';

c)

CREATE VIEW empvu
AS
SELECT * FROM empdept;

d)

CREATE INDEX
empdet_idx
ON empdet(empno);

View Answer

Answer: c
Clarification: View is the temporary space created for the database.

 

5. In which scenario would you use the ROLLUP operator for expression or columns within a GROUP BY clause?
a) To find the groups forming the subtotal in a row
b) To create group-wise grand totals for the groups specified within a GROUP BY clause
c) To create a grouping for expressions or columns specified within a GROUP BY clause in one direction, from right to left for calculating the subtotals
d) To create a grouping for expressions or columns specified within a GROUP BY clause in all possible directions, which is cross-tabular report for calculating the subtotals

Answer: c
Clarification: View is the temporary space created for the database.

6.

Name Null? Type
Cust_id Not null Number(2)
Cust_Name Varchar2(15)

Evaluate the following SQL statements executed in the given order:

ALTER TABLE cust
ADD CONSTRAINT cust_id_pk PRIMARY KEY(cust_id) DEFERRABLE INITIALLY DEFERRED; INSERT
INTO cust VALUES (1,'RAJ'); --row 1
INSERT INTO cust VALUES (1,'SAM'); --row 2
COMMIT;
SET CONSTRAINT cust_id_pk IMMEDIATE;
INSERT INTO cust VALUES (1,'LATA'); --row 3
INSERT INTO cust VALUES (2,'KING'); --row 4
COMMIT;

Which rows would be made permanent in the CUST table?
a) row 4 only
b) rows 2 and 4
c) rows 3 and 4
d) rows 1 and 4

Answer: c
Clarification: View is the temporary space created for the database.

7. Which statement is true regarding external tables?
a) The default REJECT LIMIT for external tables is UNLIMITED
b) The data and metadata for an external table are stored outside the database
c) ORACLE_LOADER and ORACLE_DATAPUMP have exactly the same functionality when used with an external table
d) The CREATE TABLE AS SELECT statement can be used to unload data into regular table in the database from an external table

Answer: d
Clarification: This will replicate the table as in the select statement.

8. A non-correlated subquery can be defined as ______
a) A set of sequential queries, all of which must always return a single value
b) A set of sequential queries, all of which must return values from the same table
c) A SELECT statement that can be embedded in a clause of another SELECT statement only
d) A set of one or more sequential queries in which generally the result of the inner query is used as the search value in the outer query

Answer: d
Clarification: This will replicate the table as in the select statement.

9. Evaluate the following SQL statements in the given order:

DROP TABLE dept;
CREATE TABLE dept
(deptno NUMBER(3) PRIMARY KEY,
deptname VARCHAR2(10));
DROP TABLE dept;
FLASHBACK TABLE dept TO BEFORE DROP;

Which statement is true regarding the above FLASHBACK operation?
a) It recovers only the first DEPT table
b) It recovers only the second DEPT table
c) It does not recover any of the tables because FLASHBACK is not possible in this case
d) It recovers both the tables but the names would be changed to the ones assigned in the RECYCLEBIN

Answer: b
Clarification: This will replicate the table as in the select statement.

10.

CREATE TABLE digits
(id NUMBER(2),
description VARCHAR2(15));
INSERT INTO digits VALUES (1,'ONE');
UPDATE digits SET description ='TWO' WHERE id=1;
INSERT INTO digits VALUES (2,'TWO');
COMMIT;
DELETE FROM digits;
SELECT description FROM digits
VERSIONS BETWEEN TIMESTAMP MINVALUE AND MAXVALUE;

What would be the outcome of the above query?
a) It would not display any values
b) It would display the value TWO once
c) It would display the value TWO twice
d) It would display the values ONE, TWO, and TWO

Answer: c
Clarification: This will replicate the table as in the select statement.

250+ TOP MCQs on Views and Answers

Database Multiple Choice Questions on “Views”.

1. 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
Clarification: Any such relation that is not part of the logical model, but is made visible to a user as a virtual relation, is called a view.

2. 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
Clarification: is any legal query expression. The view name is represented by v.

3.

SELECT course_id
FROM physics_fall_2009
WHERE building= ’Watson’;

Here the tuples are selected from the view.Which one denotes the view.
a) Course_id
b) Watson
c) Building
d) physics_fall_2009

Answer: c
Clarification: View names may appear in a query any place where a relation name may appear.

4. Materialised views make sure that
a) View definition is kept stable
b) View definition is kept up-to-date
c) View definition is verified for error
d) View is deleted after specified time

Answer: b
Clarification: None.

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
Clarification: None.

6. SQL view is said to be updatable (that is, inserts, updates or deletes can be applied on the view) if which of the following conditions are satisfied by the query defining the view?
a) The from clause has only one database relation
b) The query does not have a group by or having clause
c) The select clause contains only attribute names of the relation and does not have any expressions, aggregates, or distinct specification
d) All of the mentioned

Answer: d
Clarification: All of the conditions must be satisfied to update the view in sql.

7. Which of the following is used at the end of the view to reject the tuples which do not satisfy the condition in where clause?
a) With
b) Check
c) With check
d) All of the mentioned

Answer: c
Clarification: Views can be defined with a with check option clause at the end of the view definition; then, if a tuple inserted into the view does not satisfy the view’s where clause condition, the insertion is rejected by the database system.

8. Consider the two relations instructor and department
Instructor:

ID Name Dept_name Salary
1001 Ted Finance 10000
1002 Bob Music 20000
1003 Ron Physics 50000

Department:

Dept_name Building Budget
Biology Watson 40000
Chemistry Painter 30000
Music Taylor 50000

Which of the following is used to create view for these relations together?
a)

CREATE VIEW instructor_info AS
SELECT ID, name, building
FROM instructor, department
WHERE instructor.dept name= department.dept name;

b)

CREATE VIEW instructor_info 
SELECT ID, name, building
FROM instructor, department;

c)

CREATE VIEW instructor_info AS
SELECT ID, name, building
FROM instructor;

d)

CREATE VIEW instructor_info AS
SELECT ID, name, building
FROM department;

View Answer

Answer: a
Clarification: None.

 

9. For the view Create view instructor_info as

                SELECT ID, name, building
                FROM instructor, department
                WHERE instructor.dept name= department.dept name;

If we insert tuple into the view as insert into instructor info values (’69987’, ’White’, ’Taylor’);
What will be the values of the other attributes in instructor and department relations?
a) Default value
b) Null
c) Error statement
d) 0

Answer: b
Clarification: The values take null if there is no constraint in the attribute else it is an Erroneous statement.

10.

CREATE VIEW faculty AS
    SELECT ID, name, dept name
    FROM instructor;

Find the error in this query.
a) Instructor
b) Select
c) View …as
d) None of the mentioned

Answer: d
Clarification: Syntax is – create view v as ;