Question Bank for Practice
Question Bank for Practice
Question Bank for Practice
What is a database?
A. An organized collection of data
B. A software program used to store and manage data
C. A computer system used to store and manage data
D. All of the above
Correct Answer : D
Which of the following is a database security vulnerability that can be exploited to gain
unauthorized access to data?
A. SQL injection
B. Cross-site scripting (XSS)
C. Broken authentication and session management
D. All of the above.
Correct Answer : D
What is the difference between a public and private object in a PL/SQL package?
A. A public object is accessible to other PL/SQL objects, while a private object is only
accessible to other objects in the same package.
B. A public object is a named object, while a private object is an unnamed object.
C. A public object is a stored procedure, while a private object is a function.
D. A public object is a trigger, while a private object is a PL/SQL block.
Correct Answer : A
What is the purpose of the NEW and OLD pseudo-variables in PL/SQL triggers?
A. The NEW and OLD pseudo-variables are used to access the new and old values of a row
that is being inserted, updated, or deleted, respectively.
B. The NEW and OLD pseudo-variables are used to generate new values for a row.
C. The NEW and OLD pseudo-variables are used to compare the new and old values of a
row.
D. The NEW and OLD pseudo-variables are used to set the new values for a row.
Correct Answer : A
What is the difference between a WHILE loop and a DO-WHILE loop in DBMS?
A. A WHILE loop checks the condition before executing the block of code, while a DO-
WHILE loop checks the condition after executing the block of code.
B. A WHILE loop is a conditional control structure, while a DO-WHILE loop is a loop
control structure.
C. A WHILE loop is a procedural statement, while a DO-WHILE loop is a declarative
statement.
D. None of the above.
Correct Answer : A
In a PL/SQL package, which section is used to declare public variables and cursors
accessible outside the package?
A. PROCEDURE
B. FUNCTION
C. PUBLIC
D. PACKAGE
Correct Answer : C
What is the purpose of the Two-Phase Locking (2PL) protocol in DBMS concurrency
control?
A. It ensures that transactions acquire all the necessary locks before releasing any locks.
B. It allows transactions to release locks at any time.
C. It allows transactions to acquire and release locks multiple times during their
execution.
D. It does not relate to concurrency control.
Correct Answer : A
Which type of subquery can be used with the UPDATE and DELETE statements to perform
operations based on values from another table?
A. Correlated Subquery
B. Scalar Subquery
C. Nested Subquery
D. Inline View Subquery
Correct Answer : A
What will a subquery return if it does not find any matching rows in the database?
A. NULL
B. 0
C. Error
D. Empty string
Correct Answer : A
In a SQL NATURAL JOIN, what happens if there are columns with the same name but
different data types in the joined tables?
A. An error is raised
B. The columns with the same name are automatically cast to a common data type
C. The join is not allowed
D. The columns with the same name are ignored
Correct Answer : B
Which isolation level allows the highest concurrency but may result in non-repeatable
reads?
A. Read Uncommitted
B. Read Committed
C. Repeatable Read
D. Serializable
Correct Answer : A
What is the closure of a set of attributes with respect to a set of functional dependencies?
A. The set of all attributes that can be derived from the given attributes and functional
dependencies
B. The set of primary keys in a table
C. The set of attributes that are directly related to each other
D. The set of attributes that are not related to each other
Correct Answer : A
Q51. Choose the correct option.
Which normal form ensures that there are no partial dependencies in a relational
database?
A. Boyce-Codd Normal Form (BCNF)
B. Third Normal Form (3NF)
C. Second Normal Form (2NF)
D. First Normal Form (1NF)
Correct Answer : A
Consider an order database with two tables: orders (order_id | order_date | customer_id |
total_amount) and customers(customer_id | customer_name). What SQL query would you use to
find the total amount spent by each customer?
A. SELECT customer_id, SUM(total_amount) FROM orders GROUP BY customer_id;
B. SELECT customer_name, SUM(total_amount) FROM customers JOIN orders ON
customers.customer_id = orders.customer_id GROUP BY customer_name;
C. SELECT customer_name, SUM(total_amount) FROM customers LEFT JOIN orders ON
customers.customer_id = orders.customer_id GROUP BY customer_name;
D. SELECT customer_id, total_amount FROM orders;
Correct Answer : A
When one transaction updates a database item, and somehow the transaction fails, and
the data doesn't get ___ back, another transaction tries to access the updated database item.
A. Rolled
B. Committed
C. Aborted
D. None
Correct Answer : A
The CREATE TRIGGER statement is used to create the trigger. THE _____ clause specifies the
table name on which the trigger is to be attached. The ______ specifies that this is an AFTER
INSERT trigger.
A. for insert, on
B. On, for insert
C. For, insert
D. None of the mentioned
Correct Answer : B
Suppose a database system crashes again while recovering from a previous crash. Assume
checkpointing is not done by the database either during the transactions or during recovery.
Which of the following statements is/are correct?
A. The same undo and redo list will be used while recovering again.
B. The database will become inconsistent.
C. All the transactions that are already undone and redone will not be recovered again.
D. The system cannot recover any further.
Correct Answer : A
Q61. Choose the correct option.
Which of the following types of errors occurs when a user tries to access a table that does
not exist in the database?
A. Table Not Found Error
B. Semantic Error
C. Logical Error
D. Syntax Error
Correct Answer : A
Which type of error occurs when the database crashes while a transaction is being
executed?
A. System error
B. Media error
C. Transaction error
D. Operator error
Correct Answer : A
Which recovery technique uses backward recovery to undo the changes made by a failed
transaction?
A. Undo logging
B. Redo logging
C. Deferred update
D. Immediate update
Correct Answer : A
Which of the following recovery techniques is based on maintaining multiple copies of the
database at different points in time?
A. Replication
B. Deferred update
C. Redo logging
D. Undo logging
Correct Answer : A
Q68. Choose the correct option.
Which normal form allows for a partial dependency but eliminates transitive
dependencies?
A. Boyce-Codd Normal Form (BCNF)
B. Third Normal Form (3NF)
C. Second Normal Form (2NF)
D. First Normal Form (1NF)
Correct Answer : A
When a database operation attempts to insert a duplicate value into a unique key column,
what type of error occurs?
A. Semantic Error
B. Logical Error
C. Syntax Error
D. Duplicate Key Error
Correct Answer : D
Which type of error in DBMS occurs when a query retrieves incorrect data due to a flawed
database design or query logic?
A. Semantic Error
B. Logical Error
C. Syntax Error
D. Data Retrieval Error
Correct Answer : B
Which type of error occurs when there is a mismatch between the data type of a column
and the data being inserted into it?
A. Data Integrity Error
B. Semantic Error
C. Logical Error
D. Type Error
Correct Answer : D
When a query attempts to divide a number by zero, what type of error is encountered?
A. Data Arithmetic Error
B. Semantic Error
C. Division by Zero Error
D. Syntax Error
Correct Answer : C
Which ACID property ensures that once a transaction is committed, its changes are
permanent and will survive system crashes or failures?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : D
Which ACID property ensures that a transaction, once completed, brings the database
from one consistent state to another?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : B
Which ACID property ensures that concurrent transactions do not interfere with each
other, preserving transaction integrity?
A. Durability
B. Isolation
C. Consistency
D. Atomicity
Correct Answer : B
Which component of a package in DBMS defines the interface and public entities?
A. Package body
B. Package Signature
C. Package Constructor
D. Package specification
Correct Answer : D
A. table
B. view
C. schema
D. All of the above
Correct Answer : D
Which ACID property ensures that a database remains in a consistent state before and
after a transaction?
A. Durability
B. Isolation
C. Consistency
D. Atomicity
Correct Answer : C
Q99. Choose the correct option.
Packages are schema objects that groups logically related PL/SQL types, variables, and
subprograms.
A. Yes
B. No
C. Can be yes or no
D. none of the above
Correct Answer : C
Which recovery technique in DBMS involves periodically saving a copy of the entire
database to a separate storage location?
A. Checkpoints
B. Shadow Paging
C. Write-Ahead Logging
D. Database Backup
Correct Answer : D
Which of the following is used to input the entry and give the result in a variable in a
procedure?
A. Put and get
B. Get and put
C. Out and In
D. In and out
Correct Answer : D
Repeat
sequence of statements;
__________________
end repeat
Fill in the correct option :
A. While Condition
B. Until variable
C. Until boolean expression
D. Until 0
Correct Answer : C
Q105. Choose the correct option.
Which package lets PL/SQL programs read and write operating system (OS) text files?
A. UTL_HTTP
B. UTL_FILE
C. UTL_SMTP
D. UTL_FMT
Correct Answer : B
The property of a schedule that states that the result of executing concurrent transactions
is the same as executing them serially is known as:
A. Consistency
B. Atomicity
C. Serializability
D. Durability
Correct Answer : C
Consider a sales database with two tables: sales (sale_id | sale_date | product_id |
quantity | unit_price) and products (product_id | product_name | category). You need to retrieve
the sale details for products that have been sold more than the average
A. SELECT * FROM sales WHERE product_id IN (SELECT product_id FROM sales HAVING
AVG(quantity) < quantity);
B. SELECT * FROM sales WHERE quantity > (SELECT AVG(quantity) FROM sales);
C. SELECT * FROM sales WHERE product_id IN (SELECT product_id FROM sales WHERE
AVG(quantity) < quantity);
D. SELECT * FROM sales WHERE product_id IN (SELECT product_id FROM sales HAVING
quantity > AVG(quantity));
Correct Answer : B
Consider a sales database with two tables: sales (sale_id | sale_date | product_id |
quantity | unit_price) and products (product_id | product_name | category). Consider a student
database with a students table. You want to retrieve the names of students
A. SELECT student_name FROM students WHERE student_id IN (SELECT student_id FROM
grades WHERE grade = 'A' GROUP BY student_id HAVING COUNT(DISTINCT course) =
(SELECT COUNT(DISTINCT course) FROM grades));
B. SELECT student_name FROM students WHERE student_id IN (SELECT student_id FROM
grades WHERE grade = 'A' GROUP BY student_id HAVING COUNT(DISTINCT course) =
(SELECT COUNT(DISTINCT course) FROM grades WHERE grades.grade = 'A'));
C. SELECT student_name FROM students WHERE student_id IN (SELECT student_id FROM
grades WHERE grade = 'A' GROUP BY student_id HAVING COUNT(course) = (SELECT
COUNT(DISTINCT course) FROM grades));
D. SELECT student_name FROM students WHERE student_id IN (SELECT student_id FROM
grades WHERE grade = 'A' GROUP BY student_id HAVING COUNT(course) = (SELECT
COUNT(course) FROM grades WHERE grades.grade = 'A'));
Correct Answer : B
Which recovery technique allows a DBMS to recover from a failure without requiring
redoing all committed transactions?
A. Immediate Database Backup
B. Deferred Database Backup
C. Write-Ahead Logging
D. Checkpoints
Correct Answer : C
Consider an order database with two tables: orders and customers. You need to retrieve a
list of customers who have placed orders in February 2023. What SQL query should you use?
A. SELECT customer_name FROM customers WHERE customer_id IN (SELECT customer_id
FROM orders WHERE order_date BETWEEN '2023-02-01' AND '2023-02-28');
B. SELECT customer_name FROM customers JOIN orders ON customers.customer_id =
orders.customer_id WHERE order_date BETWEEN '2023-02-01' AND '2023-02-28';
C. SELECT customer_name FROM customers JOIN orders ON customers.customer_id =
orders.customer_id WHERE order_date = '2023-02-15';
D. SELECT customer_name FROM customers WHERE customer_id IN (SELECT customer_id
FROM orders WHERE order_date = '2023-02-15');
Correct Answer : B
Q123. Choose the correct option.
The relationship associating the weak entity sets with specific strong entity set is called as
A. Identifying relationship
B. Connecting relationship
C. Completing relationship
D. Unique relationship
Correct Answer : A
Which ACID property ensures that a transaction is either fully completed or fully undone?
A. Durability
B. Isolation
C. Consistency
D. Atomicity
Correct Answer : D
In order to undo the work of transaction after last commit which one should be used?
A. View
B. Commit
C. Rollback
D. Flashback
Correct Answer : C
PL/SQL supports programmers to catch such conditions using ________ block in the
program
A. Try
B. Throw
C. Catch
D. Exception
Correct Answer : D
In the context of ACID properties, what does the acronym "ACID" stand for?
A. Atomicity, Cohesion, Isolation, Durability
B. Atomicity, Consistency, Isolation, Durability
C. Atomicity, Correctness, Isolation, Durability
D. Atomicity, Consistency, Isolation, Downtime
Correct Answer : B
Which of the following recovery techniques allows the database to be restored to a specific
point in time by applying both redo and undo operations?
A. Write-Ahead Logging
B. ARIES
C. Shadow Paging
D. Rollback
Correct Answer : B
Q152. Choose the correct option.
Which ACID property ensures that a transaction is treated as a single, indivisible unit of
work?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : A
Consider a sales database with two tables: sales (sale_id | sale_date | product_id |
quantity | unit_price) and products (product_id | product_name | category). You want to retrieve
the names of products that have never been sold. What SQL query should y
A. SELECT product_name FROM products WHERE product_id NOT IN (SELECT product_id
FROM sales);
B. SELECT product_name FROM products LEFT JOIN sales ON products.product_id =
sales.product_id WHERE sale_id IS NULL;
C. SELECT product_name FROM products WHERE product_id IN (SELECT product_id
FROM sales HAVING COUNT(sale_id) = 0);
D. SELECT product_name FROM products WHERE product_id NOT EXISTS (SELECT
product_id FROM sales);
Correct Answer : A
Which recovery technique is associated with the use of "fuzzy checkpoints" to minimize
the amount of work required during recovery?
A. Shadow Paging
B. Deferred Database Backup
C. ARIES
D. Write-Ahead Logging
Correct Answer : C
Consider a sales database with two tables: sales (sale_id | sale_date | product_id |
quantity | unit_price) and products (product_id | product_name | category). Which SQL query
should you use to find the total revenue generated from the sale of all elect
A. SELECT SUM(quantity * unit_price) FROM sales WHERE product_id IN (SELECT
product_id FROM products WHERE category = 'Electronics');
B. SELECT SUM(total_sales) FROM sales GROUP BY category HAVING category =
'Electronics';
C. SELECT SUM(quantity * unit_price) FROM sales WHERE product_id IN (SELECT
product_id FROM products WHERE category = 'Electronics');
D. SELECT SUM(total_sales) FROM sales WHERE product_id IN (SELECT product_id FROM
products WHERE category = 'Electronics');
Correct Answer : C
Which technique is used to manage conflicts in a DBMS by locking data items to prevent
simultaneous access by multiple transactions?
A. Two-Phase Locking (2PL)
B. Multi-Version Concurrency Control (MVCC)
C. Optimistic Concurrency Control (OCC)
D. Deadlock Detection and Resolution
Correct Answer : A
How can concurrent access to shared data lead to data inconsistency in a DBMS?
A. By preventing data updates
B. By enforcing data integrity rules
C. By allowing simultaneous updates
D. By reducing query performance
Correct Answer : C
In a DBMS, what is the term for a package that only contains the package specification
without a package body?
A. A minimal package
B. A comprehensive package
C. A bodiless package
D. A complete package
Correct Answer : C
In a multi-user DBMS, what problem can arise when transactions are executed
concurrently without control?
A. Faster data retrieval
B. Enhanced data consistency
C. Reduced code duplication
D. Increased code modularity
Correct Answer : B
What does the term "serializability" imply in the context of transaction execution?
A. Transactions occur in sequence
B. Transactions can execute concurrently
C. Transactions are aborted
D. Transactions are isolated
Correct Answer : A
What does the term "transaction isolation" refer to in the context of concurrency control?
A. A transaction's lifespan
B. A transaction's ability to update data
C. A transaction's isolation level
D. A transaction's recovery
Correct Answer : C
What is the ACID property that ensures that transactions are performed correctly and
completely?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : A
What is the primary purpose of "deadlock detection" mechanisms in a DBMS that uses
locking for concurrency control?
A. To prevent transaction conflicts
B. To optimize query performance
C. To eliminate transactions
D. To create database triggers
Correct Answer : C
What is the role of a "transaction log" in a DBMS with respect to concurrency control?
A. To manage database locks
B. To record transaction history
C. To optimize query performance
D. To create database triggers
Correct Answer : B
What part of a procedure in a DBMS is responsible for declaring the input and output
variables?
A. Procedure header
B. Procedure specification
C. Procedure body
D. Procedure parameters
Correct Answer : B
Q207. Choose the correct option.
Which ACID property ensures that a transaction's effects on the database are permanent?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : D
Which database system component is responsible for managing transactions and ensuring
data integrity?
A. Database schema
B. Data dictionary
C. Concurrency control manager
D. Query optimizer
Correct Answer : C
Which of the following database languages is used to define the structure and organization
of a database?
A. Data Manipulation Language (DML)
B. Data Definition Language (DDL)
C. Data Control Language (DCL)
D. Data Query Language (DQL)
Correct Answer : B
Which of the following statements is true about First Normal Form (1NF)?
A. It allows for multivalued dependencies.
B. It allows for partial dependencies.
C. It eliminates repeating groups and ensures atomicity of data.
D. It enforces referential integrity constraints.
Correct Answer : C
Which property of a transaction ensures that it does not interfere with other transactions
while executing?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : C
Which property of a transaction ensures that it does not interfere with other transactions
while executing?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : C
Q218. Choose the correct option.
Which property of a transaction ensures that the database remains in a consistent state
after transaction execution?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : B
Which type of database constraint ensures that a foreign key value matches a primary key
value in another table?
A. Unique constraint
B. Primary key constraint
C. Foreign key constraint
D. Not null constraint
Correct Answer : C
Which of the following SQL statements is used to select all rows from a table?
A. SELECT * FROM table_name;
B. INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
C. UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
D. DELETE FROM table_name WHERE condition;
Correct Answer : A
Which of the following SQL statements is used to select all rows from a table where the
value of a column is equal to a specific value?
A. SELECT * FROM table_name WHERE column_name = value;
B. SELECT * FROM table_name WHERE column_name > value;
C. SELECT * FROM table_name WHERE column_name < value;
D. SELECT * FROM table_name WHERE column_name LIKE '%value%';
Correct Answer : A
Which of the following SQL statements is used to select all rows from a table where the
value of a column is between two values?
A. SELECT * FROM table_name WHERE column_name BETWEEN value1 AND value2;
B. SELECT * FROM table_name WHERE column_name > value1 AND column_name <
value2;
C. SELECT * FROM table_name WHERE column_name >= value1 AND column_name <=
value2;
D. All of the above.
Correct Answer : D
Which of the following normal forms eliminates all partial and transitive dependencies?
A. First normal form (1NF)
B. Second normal form (2NF)
C. Third normal form (3NF)
D. Boyce-Codd normal form (BCNF)
Correct Answer : D
Which of the following SQL statements is used to group rows and count the number of
rows in each group?
A. SELECT column_name, COUNT(*) AS count FROM table_name GROUP BY
column_name;
B. SELECT column_name, COUNT() AS count FROM table_name HAVING COUNT() > 1;
C. SELECT column_name, COUNT(*) AS count FROM table_name ORDER BY count DESC;
D. All of the above.
Correct Answer : A
Which of the following SQL statements is used to insert a new row into a table?
A. INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
B. UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
C. DELETE FROM table_name WHERE condition;
D. None of the above.
Correct Answer : A
Which of the following is a tool that can be used to monitor database activity for
suspicious behavior?
A. Intrusion detection system (IDS)
B. Security information and event management (SIEM) system
C. Database auditing tool
D. All of the above.
Correct Answer : D
Which of the following is a best practice for protecting data in transit between a database
and a client application?
A. Use a secure connection protocol, such as TLS.
B. Encrypt the data in transit.
C. Both (A) and (B).
D. None of the above.
Correct Answer : C
Which control structure is used to execute a block of code repeatedly until a certain
condition is met?
A. IF-ELSE
B. CASE
C. LOOP
D. TRANSACTION
Correct Answer : C
Which control structure is used to execute a different block of code depending on the value
of a variable?
A. IF-ELSE
B. CASE
C. LOOP
D. TRANSACTION
Correct Answer : A
Which control structure is used to group a set of statements together and execute them as
a single unit?
A. IF-ELSE
B. CASE
C. BLOCK
D. TRANSACTION
Correct Answer : C
What happens if a subquery returns more than one row and is used with a single-row
comparison operator?
A. SQL error occurs
B. The subquery result is compared with the first row only
C. The subquery result is compared with all the rows, and an error occurs
D. The subquery result is compared with all the rows, and the query executes successfully
if there is a match
Correct Answer : A
Which type of subquery does not depend on the outer query for its values?
A. Correlated Subquery
B. Scalar Subquery
C. Nested Subquery
D. Non-correlated Subquery
Correct Answer : D
In the context of DBMS architecture, what is the purpose of the Buffer Manager?
A. Manages database security
B. Manages storage and retrieval of data pages in memory
C. Optimizes SQL queries
D. Manages database transactions
Correct Answer : B
Which part of DBMS architecture is responsible for ensuring that transactions are executed
in a way that preserves the consistency and integrity of the database?
A. Query Processor
B. Transaction Manager
C. Concurrency Control
D. Database Administrator
Correct Answer : B
Which component of DBMS is responsible for translating DML statements into low-level
instructions for the storage manager?
A. Query Optimizer
B. DDL Interpreter
C. DML Compiler
D. Query Executor
Correct Answer : C
Which type of DBMS architecture allows multiple users to access the database
simultaneously without interfering with each other?
A. Single-tier architecture
B. Two-tier architecture
C. Three-tier architecture
D. Multi-tier architecture
Correct Answer : D
Which type of data independence ensures that application programs are unaffected by
changes in the conceptual schema?
A. Logical Data Independence
B. Physical Data Independence
C. Semantic Data Independence
D. Syntactic Data Independence
Correct Answer : A
When a change in the storage structure does not affect the existing external schemas, it is
an example of:
A. Logical Data Independence
B. Physical Data Independence
C. Semantic Data Independence
D. Structural Data Independence
Correct Answer : A
Q276. Choose the correct option.
Which level of data independence deals with hiding the details of the physical storage
structure from the DBMS users?
A. Logical Data Independence
B. Physical Data Independence
C. Semantic Data Independence
D. Syntactic Data Independence
Correct Answer : B
Which type of integrity constraint ensures that a column in a database table can't have
NULL values?
A. Primary Key Constraint
B. Unique Constraint
C. NOT NULL Constraint
D. Default Constraint
Correct Answer : C
What does the CHECK constraint in a database table allow you to do?
A. Enforce a condition on the values that can be inserted into a column
B. Enforce referential integrity between tables
C. Enforce uniqueness in a column or a combination of columns
D. Enforce that a column cannot have NULL values
Correct Answer : A
Which integrity constraint ensures that each row in a table is uniquely identifiable?
A. Primary Key Constraint
B. Unique Constraint
C. Foreign Key Constraint
D. Check Constraint
Correct Answer : A
Which normal form ensures that there are no repeating groups and all attributes are fully
functionally dependent on the primary key?
A. First Normal Form (1NF)
B. Second Normal Form (2NF)
C. Third Normal Form (3NF)
D. Boyce-Codd Normal Form (BCNF)
Correct Answer : A
What is the purpose of the NEW and OLD pseudo-variables in PL/SQL triggers?
A. It contains no partial dependencies
B. It contains no transitive dependencies
C. It contains no repeating groups
D. It contains no composite attributes
Correct Answer : B
In which normal form is a relation that is free from insertion, update, and deletion
anomalies?
A. First Normal Form (1NF)
B. Second Normal Form (2NF)
C. Third Normal Form (3NF)
D. Boyce-Codd Normal Form (BCNF)
Correct Answer : D
What is the purpose of DDL (Data Definition Language) statements in a database system?
A. To manipulate data stored in the database
B. To perform queries on the database
C. To define, modify, or delete database structures
D. To control access permissions for database users
Correct Answer : C
Which DDL statement is used to remove an existing table from the database?
A. REMOVE TABLE
B. DROP TABLE
C. DELETE TABLE
D. ERASE TABLE
Correct Answer : B
Which DML statement is used to add new records into a table in a database?
A. ADD
B. INSERT
C. CREATE
D. UPDATE
Correct Answer : B
What does the term "SQL Injection" refer to in the context of database security threats?
A. Unauthorized access to a database by exploiting weak passwords
B. Malicious code inserted into SQL statements to gain unauthorized access or manipulate
data
C. Accidental deletion of important records by a database administrator
D. Data corruption due to hardware failure
Correct Answer : B
Q302. Choose the correct option.
In PL/SQL, which parameter mode is used for passing values from a procedure back to the
caller?
A. IN
B. OUT
C. IN OUT
D. RETURN
Correct Answer : B
Which of the following is a benefit of stored procedures regarding security and access
control?
A. Stored procedures can bypass user authentication
B. Stored procedures provide an additional layer of security by restricting direct table
access
C. Stored procedures have unlimited access to all database objects
D. Stored procedures can modify user privileges
Correct Answer : B
Q309. Choose the correct option.
Which type of trigger is automatically fired after an INSERT, UPDATE, or DELETE statement
on a table?
A. BEFORE trigger
B. AFTER trigger
C. DURING trigger
D. INSTEAD OF trigger
Correct Answer : B
What will a subquery return if it does not find any matching rows in the database?
A. NULL
B. 0
C. Error
D. Empty string
Correct Answer : A
Which type of database constraint ensures that a foreign key value matches a primary key
value in another table?
A. Unique constraint
B. Primary key constraint
C. Foreign key constraint
D. Not null constraint
Correct Answer : C)
Which of the following statements is true about First Normal Form (1NF)?
A. It allows for multivalued dependencies.
B. It allows for partial dependencies.
C. It eliminates repeating groups and ensures atomicity of data.
D. It enforces referential integrity constraints.
Correct Answer : C)
Which of the following database languages is used to define the structure and organization
of a database?
A. Data Manipulation Language (DML)
B. Data Definition Language (DDL)
C. Data Control Language (DCL)
D. Data Query Language (DQL)
Correct Answer : B)
Q323. Choose the correct option.
The ANSI-SPARC Architecture is based on the concept of separating the database into three
levels. Which of the following is NOT one of those levels?
A. Physical level
B. Logical level
C. External level
D. Presentation level
Correct Answer : D)
Which normal form requires the elimination of repeating groups and the identification of a
primary key?
A. First Normal Form (1NF)
B. Second Normal Form (2NF)
C. Third Normal Form (3NF)
D. Boyce-Codd Normal Form (BCNF)
Correct Answer : A)
What part of a procedure in a DBMS is responsible for declaring the input and output
variables?
A. Procedure header
B. Procedure specification
C. Procedure body
D. Procedure parameters
Correct Answer : B)
In a DBMS, what is the term for a package that only contains the package specification
without a package body?
A. A minimal package
B. A comprehensive package
C. A bodiless package
D. A complete package
Correct Answer : C)
Q360. Choose the correct option.
What type of trigger is executed automatically before a specific event, such as an INSERT or
UPDATE operation?
A. After Trigger
B. Before Trigger
C. Instead of Trigger
D. Compound Trigger
Correct Answer : B)
Which of the following is a commonly used technique for concurrency control in a DBMS?
A. Optimistic concurrency control
B. Serializability control
C. Slower query performance
D. Increased code duplication
Correct Answer : B)
Which property of a transaction ensures that it either completes in its entirety or has no
effect at all?
A. Atomicity
B. Optimistic concurrency control
C. Slower query performance
D. Data redundancy
Correct Answer : A)
In a multi-user DBMS, what issue can occur without proper concurrency control?
A. Faster query execution
B. Data consistency problems
C. Reduced code duplication
D. Increased code modularity
Correct Answer : B)
Which of the following statements is true about First Normal Form (1NF)?
A. It allows for multivalued dependencies.
B. It allows for partial dependencies.
C. It eliminates repeating groups and ensures atomicity of data.
D. It enforces referential integrity constraints.
Correct Answer : C)
Which database system component is responsible for managing transactions and ensuring
data integrity?
A. Database schema
B. Data dictionary
C. Concurrency control manager
D. Query optimizer
Correct Answer : C)
What is the ACID property that ensures that transactions are performed correctly and
completely?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : A)
Which type of database constraint ensures that a foreign key value matches a primary key
value in another table?
A. Unique constraint
B. Primary key constraint
C. Foreign key constraint
D. Not null constraint
Correct Answer : C)
Which property of a transaction ensures that it does not interfere with other transactions
while executing?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : C)
Which property of a transaction ensures that it does not interfere with other transactions
while executing?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : C)
How can concurrent access to shared data lead to data inconsistency in a DBMS?
A. By preventing data updates
B. By enforcing data integrity rules
C. By allowing simultaneous updates
D. By reducing query performance
Correct Answer : C)
Which of the following database languages is used to define the structure and organization
of a database?
A. Data Manipulation Language (DML)
B. Data Definition Language (DDL)
C. Data Control Language (DCL)
D. Data Query Language (DQL)
Correct Answer : B)
What does the term "transaction isolation" refer to in the context of concurrency control?
A. A transaction's lifespan
B. A transaction's ability to update data
C. A transaction's isolation level
D. A transaction's recovery
Correct Answer : C)
Which property of a transaction ensures that the database remains in a consistent state
after transaction execution?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : B)
What is the role of a "transaction log" in a DBMS with respect to concurrency control?
A. To manage database locks
B. To record transaction history
C. To optimize query performance
D. To create database triggers
Correct Answer : B)
Which ACID property ensures that a transaction's effects on the database are permanent?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : D)
In a multi-user DBMS, what problem can arise when transactions are executed
concurrently without control?
A. Faster data retrieval
B. Enhanced data consistency
C. Reduced code duplication
D. Increased code modularity
Correct Answer : B)
What is the primary purpose of "deadlock detection" mechanisms in a DBMS that uses
locking for concurrency control?
A. To prevent transaction conflicts
B. To optimize query performance
C. To eliminate transactions
D. To create database triggers
Correct Answer : C)
Which database constraint ensures the correspondence of foreign key and primary key
values in different tables?
A. Unique constraint
B. Primary key constraint
C. Foreign key constraint
D. Not null constraint
Correct Answer : C)
Which language among the options is employed to define a database's structure and
organization?
A. Data Manipulation Language (DML)
B. Data Definition Language (DDL)
C. Data Control Language (DCL)
D. Data Query Language (DQL)
Correct Answer : B)
In the ANSI-SPARC Architecture, which level among the options is NOT one of the three
separating database levels?
A. Physical level
B. Logical level
C. External level
D. Presentation level
Correct Answer : D)
Which normal form necessitates the removal of repeating groups and the identification of
a primary key?
A. First Normal Form (1NF)
B. Second Normal Form (2NF)
C. Third Normal Form (3NF)
D. Boyce-Codd Normal Form (BCNF)
Correct Answer : A)
Which part of a DBMS procedure is responsible for defining the operations to be executed?
A. Procedure header
B. Procedure specification
C. Procedure body
D. Procedure parameters
Correct Answer : C)
What is the term for a package in a DBMS that only contains the package specification and
lacks a package body?
A. A package without a body
B. A package with excessive code
C. A package with only triggers
D. A package with minimal documentation
Correct Answer : A)
What type of trigger is automatically executed after the triggering event in a DBMS?
A. After Trigger
B. Before Trigger
C. Instead of Trigger
D. Compound Trigger
Correct Answer : A)
What is the term for a package in a DBMS that only contains the package specification
without a package body?
A. A minimal package
B. A comprehensive package
C. A bodiless package
D. A complete package
Correct Answer : C)
What kind of trigger is automatically executed before specific events like INSERT or
UPDATE operations in a DBMS?
A. After Trigger
B. Before Trigger
C. Instead of Trigger
D. Compound Trigger
Correct Answer : B)
Q460. Choose the correct option.
In the context of a DBMS, what does the term "bodiless" package refer to?
A. A package without a body
B. A package with excessive code
C. A package with only triggers
D. A package with minimal documentation
Correct Answer : A)
Which transaction property ensures that it either completes entirely or has no effect at all?
A. Atomicity
B. Optimistic concurrency control
C. Slower query performance
D. Data redundancy
Correct Answer : A)
What does the concept of "recoverability" signify in the context of concurrency control?
A. The ability to lock data
B. The ability to recover from system failures
C. The ability to perform database recovery
D. The ability to execute queries efficiently
Correct Answer : B)
Which ACID property ensures that transactions are executed accurately and completely?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : A)
What type of database constraint guarantees that a foreign key aligns with a primary key in
another table?
A. Unique constraint
B. Primary key constraint
C. Foreign key constraint
D. Not null constraint
Correct Answer : C)
Which property of a transaction ensures it does not disrupt other transactions during
execution?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : C)
How can simultaneous access to shared data cause data inconsistency in a DBMS?
A. To ensure all transactions recover
B. To prevent data recovery issues
C. To recover from system failures
D. To lock database tables
Correct Answer : C)
What property of a transaction ensures the database remains consistent after execution?
A. A transaction's lifespan
B. A transaction's ability to update data
C. A transaction's isolation level
D. A transaction's recovery
Correct Answer : C)
What role does a "transaction log" play in a DBMS concerning concurrency control?
A. Increased code modularity
B. Slower query performance
C. Risk of transaction conflicts
D. Enhanced data integrity
Correct Answer : C)
Which ACID property guarantees that a transaction's effects on the database are
permanent?
A. To manage database locks
B. To record transaction history
C. To optimize query performance
D. To create database triggers
Correct Answer : B)
In a multi-user DBMS, what issue can arise when transactions are executed concurrently
without control?
A. The ability to recover from system failures
B. The ability to execute transactions concurrently
C. The ability to lock database tables
D. The ability to perform efficient queries
Correct Answer : A)
What is the primary purpose of "deadlock detection" mechanisms in a DBMS that uses
locking for concurrency control?
A. To prevent transaction conflicts
B. To optimize query performance
C. To eliminate transactions
D. To create database triggers
Correct Answer : C)
Q501. Choose the correct option.
In the BORROW_BOOK procedure, where is the information about the borrowed book and
borrower stored?
A. In the Books table.
B. In the Authors table.
C. In the Borrowers table.
D. In the Readers table.
Correct Answer : C
What should the BORROW_BOOK procedure do after successfully borrowing the book?
A. Update the book's publication date.
B. Update the borrower's contact information.
C. Reduce the available copies count in the Books table.
D. Add a new record in the Authors table.
Correct Answer : C
Which SQL statement is correct for updating the available_copies of a book after it's
borrowed using the BORROW_BOOK stored procedure?
A. UPDATE Books SET available_copies = available_copies - 1 WHERE book_id =
<book_id>;
B. MODIFY Books SET available_copies = available_copies - 1 WHERE book_id =
<book_id>;
C. CHANGE Books SET available_copies = available_copies - 1 WHERE book_id =
<book_id>;
D. ALTER Books SET available_copies = available_copies - 1 WHERE book_id = <book_id>;
Correct Answer : A
Which SQL statement is correct for updating the available_copies of a book after it's
borrowed using the BORROW_BOOK stored procedure?
A. UPDATE Books SET available_copies = available_copies - 1 WHERE book_id =
<book_id>;
B. MODIFY Books SET available_copies = available_copies - 1 WHERE book_id =
<book_id>;
C. CHANGE Books SET available_copies = available_copies - 1 WHERE book_id =
<book_id>;
D. ALTER Books SET available_copies = available_copies - 1 WHERE book_id = <book_id>;
Correct Answer : A
Which SQL statement is correct for inserting a new record into the Borrowers table after
borrowing a book using the BORROW_BOOK stored procedure?
A. INSERT INTO Borrowers (book_id, borrower_id, borrow_date) VALUES (<book_id>,
<borrower_id>, SYSDATE);
B. ADD INTO Borrowers (book_id, borrower_id, borrow_date) VALUES (<book_id>,
<borrower_id>, CURRENT_DATE);
C. CREATE INTO Borrowers (book_id, borrower_id, borrow_date) VALUES (<book_id>,
<borrower_id>, NOW());
D. NEW INTO Borrowers (book_id, borrower_id, borrow_date) VALUES (<book_id>,
<borrower_id>, TODAY());
Correct Answer : A
What is the purpose of the SYSDATE function in the context of the BORROW_BOOK stored
procedure?
A. It represents the current date and time when the book was added to the library.
B. It represents the current date and time when the book was borrowed.
C. It represents the date when the book was published.
D. It represents the due date for returning the borrowed book.
Correct Answer : B
Which of the following SQL statements should be used to validate if a book with a specific
book_id exists before borrowing it in the BORROW_BOOK stored procedure?
A. SELECT * FROM Books WHERE book_id = <book_id>;
B. IF EXISTS (SELECT * FROM Books WHERE book_id = <book_id>) THEN ... END IF;
C. CHECK IF (SELECT COUNT(*) FROM Books WHERE book_id = <book_id>) > 0 THEN ...
END IF;
D. IF (SELECT COUNT(*) FROM Books WHERE borrower_id = <book_id>) > 0 THEN ... END
IF;
Correct Answer : B
Which input parameters are required for the RETURN_BOOK stored procedure?
A. book_title and borrower_name
B. book_id and borrower_id
C. book_genre and borrow_date
D. author_id and book_id
Correct Answer : B
Which SQL statement is correct for updating the return_date in the Borrowers table to
mark a book as returned in the RETURN_BOOK procedure?
A. UPDATE Borrowers SET return_date = SYSDATE WHERE book_id = <book_id> AND
borrower_id = <borrower_id>;
B. MODIFY Borrowers SET return_date = NOW() WHERE book_id = <book_id> AND
borrower_id = <borrower_id>;
C. ALTER Borrowers SET return_date = CURRENT_DATE WHERE book_id = <book_id> AND
borrower_id = <borrower_id>;
D. CHANGE Borrowers SET return_date = TODAY() WHERE book_id = <book_id> AND
borrower_id = <borrower_id>;
Correct Answer : A
What action should the RETURN_BOOK procedure perform after updating the return_date
in the Borrowers table?
A. Increase the available copies count in the Books table for the corresponding book.
B. Decrease the available copies count in the Books table for the corresponding book.
C. Check if the book is damaged and needs repair.
D. Notify the borrower about the return status.
Correct Answer : A
In SQL, which type of JOIN returns all rows from the left table, and the matched rows from
the right table?
A. LEFT JOIN
B. INNER JOIN
C. RIGHT JOIN
D. FULL OUTER JOIN
Correct Answer : A
Which SQL statement is used to remove rows from a table based on a specified condition?
A. DELETE FROM
B. SELECT * FROM
C. INSERT INTO
D. UPDATE
Correct Answer : A
Q525. Choose the correct option.
In a PL/SQL package, where are the private variables and cursors declared and defined?
A. Package Header
B. Package Specification
C. Package Body
D. Package Interface
Correct Answer : C
Which type of lock allows a transaction to both read and write data exclusively, blocking all
other transactions?
A. Shared Locks
B. Exclusive Locks
C. Read Locks
D. Write Locks
Correct Answer : B
Which recovery technique involves applying all the changes in the log since the last
checkpoint?
A. Rollforward recovery
B. Rollback recovery
C. Point-in-time recovery
D. Restart recovery
Correct Answer : A
What is the primary difference between a "for" loop and a "while" loop in programming?
A. A "for" loop has a defined number of iterations
B. A "while" loop has a loop counter
C. A "for" loop cannot exit prematurely
D. A "while" loop cannot iterate
Correct Answer : A
In SQL, which clause is used to filter rows in the result set of a SELECT statement based on
a specified condition?
A. WHERE
B. FROM
C. SELECT
D. HAVING
Correct Answer : A
Which part of a PL/SQL package is used for declaring global variables and cursors that can
be used throughout the package?
A. Package Header
B. Package Specification
C. Package Body
D. Package Interface
Correct Answer : A
What does the ACID acronym stand for in the context of database transactions?
A. Atomicity, Consistency, Integrity, Durability
B. Availability, Consistency, Isolation, Durability
C. Atomicity, Consistency, Isolation, Durability
D. Association, Connectivity, Integration, Durability
Correct Answer : C
Which normal form is stronger than 3NF but not as strong as BCNF?
A. 2NF
B. 3NF
C. 4NF
D. 5NF
Correct Answer : C
Q566. Choose the correct option.
Which SQL keyword is used to combine multiple conditions in a WHERE clause with logical
OR?
A. OR
B. AND
C. NOT
D. XOR
Correct Answer : A
What does the SQL statement "ALTER TABLE" allow you to do?
A. Modify the structure of an existing table
B. Create a new table
C. Delete a table
D. Insert data into a table
Correct Answer : A
Which DBMS architecture allows multiple users to access the database concurrently?
A. Client-Server
B. Centralized
C. Hierarchical
D. Flat File
Correct Answer : A
Which data model represents data as a collection of entities, attributes, and relationships?
A. Relational model
B. ER model
C. Object-oriented model
D. Hierarchical model
Correct Answer : B
Q581. Choose the correct option.
Which locking technique allows multiple transactions to read the same data
simultaneously but ensures exclusive access during updates?
A. Shared Locks
B. Exclusive Locks
C. Read Locks
D. Write Locks
Correct Answer : A
Which integrity constraint allows you to specify a condition that must be met for data to
be inserted or updated?
A. Primary Key Constraint
B. Foreign Key Constraint
C. Check Constraint
D. Default Constraint
Correct Answer : C
Which type of error occurs when a user enters incorrect data into the database?
A. System error
B. User error
C. Hardware error
D. Network error
Correct Answer : B
Which model is often used for modeling real-world entities and their relationships in
databases?
A. Hierarchical model
B. Object-oriented model
C. Relational model
D. ER model
Correct Answer : D
Which data model is based on the concept of a tree-like structure with parent-child
relationships?
A. Object-oriented model
B. Relational model
C. Hierarchical model
D. ER model
Correct Answer : C
Q607. Choose the correct option.
In the context of normalization, when is it necessary to consider higher normal forms like
4NF and 5NF?
A. When dealing with complex multi-valued dependencies
B. When optimizing query performance
C. When minimizing data redundancy
D. When enforcing foreign key constraints
Correct Answer : A
Which control structure allows you to make decisions in code based on certain conditions?
A. Conditional statements
B. Iterative control
C. Sequential control
D. Cursors
Correct Answer : A
Which locking technique allows multiple transactions to read the same data and also
allows concurrent writes, resolving conflicts later?
A. Shared Locks
B. Exclusive Locks
C. Read Locks
D. Write Locks
Correct Answer : A
Which part of a package contains the declarations and definitions of the procedures and
functions?
A. Package Header
B. Package Specification
C. Package Body
D. Package Interface
Correct Answer : C
Which of the following statements is true about the SQL "AND" operator in a WHERE
clause?
A. All conditions must be true for the row to be selected
B. At least one condition must be true for the row to be selected
C. The order of conditions does not matter
D. It is equivalent to "OR"
Correct Answer : A
Which type of integrity constraint enforces business rules and domain constraints on data?
A. Primary Key Constraint
B. Foreign Key Constraint
C. Check Constraint
D. Default Constraint
Correct Answer : C
Which model allows for complex objects and inheritance relationships in database design?
A. Object-oriented model
B. Relational model
C. ER model
D. Hierarchical model
Correct Answer : A
Data independence allows changes in the _______ level to be made without affecting the
_______ level
A. Logical, Physical
B. Physical, Logical
C. Conceptual, Logical
D. Logical, Conceptual
Correct Answer : B
Which error type occurs due to problems in the network or communication between
components?
A. System error
B. User error
C. Hardware error
D. Network error
Correct Answer : D
Which statement is used to invoke a procedure from within another procedure or PL/SQL
block?
A. EXECUTE
B. CALL
C. RUN
D. BEGIN
Correct Answer : D
Which property of a transaction ensures that it leaves the database in a consistent state
regardless of failures?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : D
Which error type occurs when a user attempts to access data that they are not authorized
to access?
A. System error
B. User error
C. Hardware error
D. Access error
Correct Answer : D
Which property of transactions ensures that concurrent transactions do not interfere with
each other?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : C
Which locking technique allows multiple transactions to read the same data but prevents
any updates until the first transaction completes?
A. Shared Locks
B. Exclusive Locks
C. Read Locks
D. Write Locks
Correct Answer : C
Which level of data independence deals with the physical storage of data?
A. Physical
B. Logical
C. Conceptual
D. Structural
Correct Answer : A
Which type of lock allows multiple transactions to read data concurrently but prevents any
write operations?
A. Shared Locks
B. Exclusive Locks
C. Read Locks
D. Write Locks
Correct Answer : A
Which type of error occurs due to a hardware malfunction, such as a disk failure?
A. System error
B. User error
C. Hardware error
D. Network error
Correct Answer : C
Which type of data independence ensures that application programs are unaffected by
changes in data storage?
A. Logical Data Independence
B. Physical Data Independence
C. Structural Data Independence
D. None of the above
Correct Answer : A
Which normal form is also known as the "elementary key normal form"?
A. 1NF
B. 2NF
C. 3NF
D. BCNF
Correct Answer : A
Which normal form allows multi-valued dependencies to exist, but not partial or transitive
dependencies?
A. 2NF
B. 3NF
C. BCNF
D. 4NF
Correct Answer : A
Which parameter mode in PL/SQL allows a procedure to return a value to the caller?
A. IN
B. OUT
C. IN OUT
D. None of the above
Correct Answer : B
Which recovery technique involves rolling back a specific transaction that caused an error?
A. Rollforward recovery
B. Rollback recovery
C. Point-in-time recovery
D. Restart recovery
Correct Answer : B
Which recovery technique involves restoring the database to a previous state using a
backup copy?
A. Rollforward recovery
B. Rollback recovery
C. Point-in-time recovery
D. Restart recovery
Correct Answer : C
Which SQL keyword is used to combine multiple conditions in a WHERE clause with logical
AND?
A. AND
B. OR
C. NOT
D. XOR
Correct Answer : A
Which type of control structure is used for repeatedly executing a block of code as long as
a condition is true?
A. Iterative control
B. Sequential control
C. Conditional control
D. Cursor control
Correct Answer : A
Which type of cursor in database programming allows both read and write operations on a
database table?
A. Updatable cursor
B. Read-only cursor
C. Static cursor
D. Dynamic cursor
Correct Answer : A
Q696. Choose the correct option.
Which DBMS architecture stores data in a tabular format with rows and columns?
A. Hierarchical
B. Network
C. Relational
D. Object-Oriented
Correct Answer : C
Which parameter mode in PL/SQL allows you to pass values into a procedure?
A. IN
B. OUT
C. IN OUT
D. None of the above
Correct Answer : A
Q711. Choose the correct option.
In a transaction, which property ensures that it either fully completes or has no effect on
the database?
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Correct Answer : A
Which error type occurs due to a violation of data integrity constraints, such as unique
keys or referential integrity?
A. System error
B. User error
C. Integrity error
D. Security error
Correct Answer : C
In a PL/SQL package, where are the public procedures and functions declared?
A. Package Header
B. Package Specification
C. Package Body
D. Package Interface
Correct Answer : B
Which integrity constraint ensures that a column cannot have NULL values?
A. Primary Key Constraint
B. Foreign Key Constraint
C. Check Constraint
D. Default Constraint
Correct Answer : A
Which parameter mode in PL/SQL allows a procedure to modify the value of the parameter
passed to it?
A. IN
B. OUT
C. IN OUT
D. None of the above
Correct Answer : C
In a programming context, what does the "else" part of an "if-else" statement do?
A. It provides an alternative code block to execute if the condition is false
B. It repeats a loop
C. It declares a variable
D. It defines a function
Correct Answer : A
Which error type occurs when the database management system itself fails or crashes?
A. System error
B. User error
C. Hardware error
D. Network error
Correct Answer : A
Which data model is suitable for representing hierarchical structures like organization
charts?
A. Object-oriented model
B. Relational model
C. ER model
D. Hierarchical model
Correct Answer : D
Which type of data independence deals with the logical structure of the data?
A. Physical
B. Logical
C. Conceptual
D. Structural
Correct Answer : B
Q741. Choose the correct option.
Which type of DBMS architecture is known for its flexibility and scalability?
A. Distributed
B. Centralized
C. Hierarchical
D. Relational
Correct Answer : A
Which normal form deals with atomic (indivisible) values in each column of a table?
A. 1NF
B. 2NF
C. 3NF
D. BCNF
Correct Answer : A
What type of SQL JOIN returns only the rows that have matching values in both tables
being joined?
A. INNER JOIN
B. LEFT JOIN
C. RIGHT JOIN
D. FULL OUTER JOIN
Correct Answer : A
Which DBMS architecture is suitable for small-scale applications with low data volume?
A. Client-Server
B. Distributed
C. Centralized
D. Hierarchical
Correct Answer : C
Retrieve the names of authors who have written books with more available copies than
the average available copies of all books in the library.
A. SELECT author_name FROM Authors WHERE author_id = (SELECT author_id FROM
Books WHERE available_copies > (SELECT AVG(available_copies) FROM Books))
B. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE available_copies > (SELECT AVG(available_copies) FROM Books))
C. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE available_copies >= (SELECT AVG(available_copies) FROM Books))
D. SELECT author_name FROM Authors WHERE author_id = (SELECT author_id FROM
Books WHERE available_copies >= (SELECT AVG(available_copies) FROM Books))
Correct Answer : B
Find the titles of books that were borrowed before any book by a specific author.
A. SELECT title FROM Books WHERE book_id = (SELECT book_id FROM Borrowers WHERE
borrow_date < ALL (SELECT borrow_date FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id])))
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrow_date < ALL (SELECT borrow_date FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id])))
C. SELECT title FROM Books WHERE book_id = (SELECT book_id FROM Borrowers WHERE
borrow_date < ANY (SELECT borrow_date FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id])))
D. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrow_date < ANY (SELECT borrow_date FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id])))
Correct Answer : B
List the authors who have written books that were never borrowed.
A. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books)
B. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Borrowers WHERE book_id IN (SELECT book_id FROM Books))
C. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Borrowers WHERE book_id NOT IN (SELECT book_id FROM Books))
D. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers))
Correct Answer : B
Find the titles of books borrowed by a borrower named 'John' on the same day they were
borrowed.
A. SELECT title FROM Books WHERE book_id = (SELECT book_id FROM Borrowers WHERE
borrower_id = (SELECT borrower_id FROM Borrowers WHERE borrower_name = 'John')
AND borrow_date = return_date)
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_id = (SELECT borrower_id FROM Borrowers WHERE borrower_name = 'John')
AND borrow_date = return_date)
C. SELECT title FROM Books WHERE book_id = (SELECT book_id FROM Borrowers WHERE
borrower_id = (SELECT borrower_id FROM Borrowers WHERE borrower_name = 'John')
AND borrow_date = borrow_date)
D. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_id = (SELECT borrower_id FROM Borrowers WHERE borrower_name = 'John')
AND borrow_date = borrow_date)
Correct Answer : B
Get the titles of books borrowed by a borrower whose name contains 'Smith'.
A. SELECT B.title FROM Books AS B JOIN Borrowers AS Br ON B.book_id = Br.book_id
WHERE Br.borrower_name = 'Smith'
B. SELECT B.title FROM Books AS B JOIN Borrowers AS Br ON B.book_id = Br.book_id
WHERE Br.borrower_name LIKE '%Smith%'
C. SELECT B.title FROM Books AS B JOIN Borrowers AS Br ON B.book_id = Br.book_id
WHERE Br.borrower_name = '%Smith%'
D. SELECT B.title FROM Books AS B JOIN Borrowers AS Br ON B.book_id = Br.book_id
WHERE Br.borrower_name = 'Smith%'
Correct Answer : B
List the borrowers who borrowed books and include the author's name for each borrowed
book.
A. SELECT Br.borrower_name, B.title, A.author_name FROM Borrowers AS Br JOIN Books
AS B ON Br.book_id = B.book_id LEFT JOIN Authors AS A ON B.author_id = A.author_id
B. SELECT Br.borrower_name, B.title, A.author_name FROM Borrowers AS Br JOIN Books
AS B ON Br.book_id = B.book_id
C. SELECT Br.borrower_name, B.title, A.author_name FROM Borrowers AS Br LEFT JOIN
Books AS B ON Br.book_id = B.book_id JOIN Authors AS A ON B.author_id = A.author_id
D. SELECT Br.borrower_name, B.title, A.author_name FROM Borrowers AS Br FULL JOIN
Books AS B ON Br.book_id = B.book_id JOIN Authors AS A ON B.author_id = A.author_id
Correct Answer : A
Retrieve the authors and the total number of copies of their books available in the library.
A. SELECT A.author_name, COUNT(B.available_copies) AS total_available_copies FROM
Authors AS A JOIN Books AS B ON A.author_id = B.author_id GROUP BY A.author_name
B. SELECT A.author_name, SUM(B.available_copies) AS total_available_copies FROM
Authors AS A JOIN Books AS B ON A.author_id = B.author_id GROUP BY A.author_name
C. SELECT A.author_name, AVG(B.available_copies) AS total_available_copies FROM
Authors AS A JOIN Books AS B ON A.author_id = B.author_id GROUP BY A.author_name
D. SELECT A.author_name, MAX(B.available_copies) AS total_available_copies FROM
Authors AS A JOIN Books AS B ON A.author_id = B.author_id GROUP BY A.author_name
Correct Answer : B
List the borrowers who have borrowed multiple books, along with the titles of those
books.
A. SELECT Br.borrower_name, B.title FROM Borrowers AS Br JOIN Books AS B ON
Br.book_id = B.book_id GROUP BY Br.borrower_name, B.title HAVING COUNT(B.book_id)
=1
B. SELECT Br.borrower_name, B.title FROM Borrowers AS Br JOIN Books AS B ON
Br.book_id = B.book_id GROUP BY Br.borrower_name, B.title HAVING COUNT(B.book_id)
>1
C. SELECT Br.borrower_name, B.title FROM Borrowers AS Br JOIN Books AS B ON
Br.book_id = B.book_id GROUP BY Br.borrower_name, B.title
D. SELECT Br.borrower_name, B.title FROM Borrowers AS Br JOIN Books AS B ON
Br.book_id = B.book_id GROUP BY Br.borrower_name HAVING COUNT(B.book_id) > 1
Correct Answer : B
Retrieve the authors who have books available in the library and books that have been
borrowed.
A. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT
B.author_id FROM Books AS B)
B. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT
B.author_id FROM Borrowers AS Br JOIN Books AS B ON Br.book_id = B.book_id)
C. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT
B.author_id FROM Books AS B) AND A.author_id IN (SELECT B.author_id FROM Borrowers
AS Br JOIN Books AS B ON Br.book_id = B.book_id)
D. SELECT A.author_name FROM Authors AS A WHERE A.author_id NOT IN (SELECT
B.author_id FROM Books AS B) AND A.author_id NOT IN (SELECT B.author_id FROM
Borrowers AS Br JOIN Books AS B ON Br.book_id = B.book_id)
Correct Answer : C
Get the titles of books that were borrowed by more than one borrower.
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(borrower_id) = 1)
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(borrower_id) > 1)
C. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(*) = 1)
D. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(*) > 1)
Correct Answer : B
Find the names of borrowers who have borrowed books written by specific authors.
A. SELECT DISTINCT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN
(SELECT book_id FROM Books WHERE author_id = [author_id])
B. SELECT DISTINCT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN
(SELECT book_id FROM Books WHERE author_id = [author_id]) AND Br.book_id IN
(SELECT book_id FROM Borrowers WHERE return_date IS NOT NULL)
C. SELECT DISTINCT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN
(SELECT book_id FROM Books WHERE author_id = [author_id]) OR Br.book_id IN (SELECT
book_id FROM Borrowers WHERE return_date IS NULL)
D. SELECT DISTINCT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN
(SELECT book_id FROM Books WHERE author_id = [author_id]) OR Br.borrower_name IN
(SELECT DISTINCT borrower_name FROM Borrowers WHERE return_date IS NULL)
Correct Answer : A
List the books that are either available in the library or were borrowed by a borrower
named 'Alice.'
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Alice') OR book_id IN (SELECT book_id FROM Books)
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Alice') AND book_id IN (SELECT book_id FROM Books)
C. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name <> 'Alice') OR book_id IN (SELECT book_id FROM Books)
D. SELECT title FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers
WHERE borrower_name = 'Alice') OR book_id NOT IN (SELECT book_id FROM Books)
Correct Answer : A
Get the titles of books that were borrowed and returned, or have more available copies
than the average.
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
return_date IS NULL) OR available_copies > (SELECT AVG(available_copies) FROM Books)
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
return_date IS NOT NULL) AND available_copies > (SELECT AVG(available_copies) FROM
Books)
C. SELECT title FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers
WHERE return_date IS NULL) OR available_copies > (SELECT AVG(available_copies) FROM
Books)
D. SELECT title FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers
WHERE return_date IS NOT NULL) AND available_copies > (SELECT AVG(available_copies)
FROM Books)
Correct Answer : A
Q776. Consider the Library Database with Following tables
Books (book_id: Numeric PK, title: String, author_id: Numeric FK to Authors, available_copies:
Numeric)
Authors (author_id: Numeric PK, author_name: String)
Borrowers (borrower_id: Numeric PK, borrower_
List the borrowers who borrowed books but have not yet returned them and were not
written by a specific author.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id <> [author_id]) AND Br.book_id NOT IN (SELECT
book_id FROM Borrowers WHERE return_date IS NOT NULL)
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE author_id = [author_id]) AND Br.borrower_name NOT IN
(SELECT DISTINCT borrower_name FROM Borrowers WHERE return_date IS NOT NULL)
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id]) AND Br.borrower_name NOT IN
(SELECT DISTINCT borrower_name FROM Borrowers WHERE return_date IS NOT NULL)
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE author_id <> [author_id]) OR Br.book_id IN (SELECT
book_id FROM Borrowers WHERE return_date IS NOT NULL)
Correct Answer : A
Retrieve the authors who have never written a book with more than 10 available copies in
the library.
A. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE available_copies > 10)
B. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE available_copies > 10)
C. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE available_copies <= 10)
D. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE available_copies <= 10)
Correct Answer : B
Find the titles of books that have been borrowed by the same borrower more than once on
different dates.
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_id HAVING COUNT(borrower_id) > 1)
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_id HAVING COUNT(DISTINCT borrow_date) > 1)
C. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(DISTINCT borrower_id) > 1)
D. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_id HAVING COUNT(borrow_date) > 1)
Correct Answer : B
List the authors who have written books that were borrowed by more than one borrower,
and the total number of borrowers for each book.
A. SELECT A.author_name, B.title, COUNT(DISTINCT Br.borrower_id) AS total_borrowers
FROM Authors AS A JOIN Books AS B ON A.author_id = B.author_id JOIN Borrowers AS Br
ON B.book_id = Br.book_id GROUP BY A.author_name, B.title HAVING COUNT(DISTINCT
Br.borrow
B. SELECT A.author_name, B.title, COUNT(DISTINCT Br.borrower_id) AS total_borrowers
FROM Authors AS A JOIN Books AS B ON A.author_id = B.author_id JOIN Borrowers AS Br
ON B.book_id = Br.book_id GROUP BY A.author_name, B.title HAVING COUNT(DISTINCT
Br.borrow
C. SELECT A.author_name, B.title, COUNT(DISTINCT Br.borrower_id) AS total_borrowers
FROM Authors AS A JOIN Books AS B ON A.author_id = B.author_id JOIN Borrowers AS Br
ON B.book_id = Br.book_id GROUP BY A.author_name, B.title
D. SELECT A.author_name, B.title, COUNT(DISTINCT Br.borrower_id) AS total_borrowers
FROM Authors AS A JOIN Books AS B ON A.author_id = B.author_id JOIN Borrowers AS Br
ON B.book_id = Br.book_id GROUP BY A.author_name, B.title HAVING COUNT(DISTINCT
Br.borrow
Correct Answer : A
Find the titles of books that were borrowed by more than one borrower with the same
name.
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_name HAVING COUNT(borrower_name) > 1)
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_name HAVING COUNT(borrower_name) = 1)
C. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_name HAVING COUNT(DISTINCT borrower_id) > 1)
D. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id, borrower_name HAVING COUNT(DISTINCT borrower_id) = 1)
Correct Answer : A
Retrieve the names of authors who have written books borrowed by a borrower named
'Alice' but not by a borrower named 'Bob.'
A. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE borrower_name =
'Alice')) AND author_id NOT IN (SELECT author_id FROM Books WHERE book_id IN
(SELECT book_id FROM Borrow
B. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE borrower_name =
'Alice')) AND author_id IN (SELECT author_id FROM Books WHERE book_id IN (SELECT
book_id FROM Borrowers
C. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Alice')) AND author_id NOT IN (SELECT author_id FROM Books WHERE
book_id IN (SELECT book_id FROM Bo
D. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE borrower_name =
'Alice')) OR author_id IN (SELECT author_id FROM Books WHERE book_id IN (SELECT
book_id FROM Borrowers W
Correct Answer : A
List the borrowers who borrowed books that have more available copies than the average
available copies of books written by their corresponding authors.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE available_copies > (SELECT AVG(B1.available_copies) FROM
Books AS B1 WHERE B1.author_id = (SELECT author_id FROM Books WHERE book_id =
Br.book_id)))
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE available_copies > (SELECT AVG(available_copies) FROM
Books))
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE available_copies > (SELECT AVG(B1.available_copies) FROM
Books AS B1 WHERE B1.author_id = (SELECT author_id FROM Books WHERE book_id =
Br.book_id)))
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE available_copies > (SELECT AVG(available_copies) FROM
Books))
Correct Answer : A
Retrieve the names of borrowers who have borrowed the same book more than once with
a different return date.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Borrowers WHERE borrower_id = Br.borrower_id GROUP BY book_id
HAVING COUNT(DISTINCT return_date) > 1)
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Borrowers WHERE borrower_id = Br.borrower_id GROUP BY book_id
HAVING COUNT(return_date) > 1)
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Borrowers WHERE borrower_id = Br.borrower_id GROUP BY book_id
HAVING COUNT(DISTINCT return_date) > 1)
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Borrowers WHERE borrower_id = Br.borrower_id GROUP BY book_id
HAVING COUNT(return_date) > 1)
Correct Answer : A
List the authors who have written books that have never been borrowed by a borrower
with the name 'David.'
A. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers WHERE borrower_name
= 'David'))
B. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'David'))
C. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE borrower_name =
'David'))
D. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'David'))
Correct Answer : A
Find the names of borrowers who have borrowed books on a date that is earlier than the
date any book was published by a specific author.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.borrow_date < (SELECT
MIN(publish_date) FROM Books WHERE author_id = [author_id])
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.borrow_date < (SELECT
MAX(publish_date) FROM Books WHERE author_id = [author_id])
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.borrow_date < (SELECT
AVG(publish_date) FROM Books WHERE author_id = [author_id])
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.borrow_date < (SELECT
publish_date FROM Books WHERE author_id = [author_id] LIMIT 1)
Correct Answer : A
Get the names of borrowers who have borrowed more books than the average number of
books borrowed by all borrowers.
A. SELECT Br.borrower_name FROM Borrowers AS Br GROUP BY Br.borrower_name
HAVING COUNT(Br.book_id) > (SELECT AVG(book_count) FROM (SELECT COUNT(book_id)
AS book_count FROM Borrowers GROUP BY borrower_name) AS AvgCount)
B. SELECT Br.borrower_name FROM Borrowers AS Br GROUP BY Br.borrower_name
HAVING COUNT(Br.book_id) < (SELECT AVG(book_count) FROM (SELECT COUNT(book_id)
AS book_count FROM Borrowers GROUP BY borrower_name) AS AvgCount)
C. SELECT Br.borrower_name FROM Borrowers AS Br GROUP BY Br.borrower_name
HAVING COUNT(Br.book_id) = (SELECT AVG(book_count) FROM (SELECT COUNT(book_id)
AS book_count FROM Borrowers GROUP BY borrower_name) AS AvgCount)
D. SELECT Br.borrower_name FROM Borrowers AS Br GROUP BY Br.borrower_name
HAVING COUNT(Br.book_id) > (SELECT AVG(book_count) FROM (SELECT COUNT(book_id)
AS book_count FROM Borrowers GROUP BY borrower_name) AS AvgCount)
Correct Answer : A
Retrieve the titles of books that have been borrowed and returned more than once, along
with the total number of times they were borrowed and returned.
A. SELECT title, COUNT(Br.book_id) AS total_borrow_return FROM Books AS B JOIN
Borrowers AS Br ON B.book_id = Br.book_id WHERE Br.return_date IS NOT NULL GROUP
BY B.title HAVING COUNT(Br.book_id) > 1
B. SELECT title, COUNT(Br.book_id) AS total_borrow_return FROM Books AS B JOIN
Borrowers AS Br ON B.book_id = Br.book_id WHERE Br.return_date IS NOT NULL GROUP
BY B.title HAVING COUNT(Br.book_id) = 1
C. SELECT title, COUNT(Br.book_id) AS total_borrow_return FROM Books AS B JOIN
Borrowers AS Br ON B.book_id = Br.book_id WHERE Br.return_date IS NOT NULL GROUP
BY B.title
D. SELECT title, COUNT(Br.book_id) AS total_borrow_return FROM Books AS B JOIN
Borrowers AS Br ON B.book_id = Br.book_id WHERE Br.return_date IS NULL GROUP BY
B.title HAVING COUNT(Br.book_id) > 1
Correct Answer : A
List the authors who have not written any books that have been borrowed by borrowers
with the name 'Mary' on the same day.
A. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT author_id
FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Mary' AND borrow_date = [specific_date]))
B. SELECT A.author_name FROM Authors AS A WHERE A.author_id NOT IN (SELECT
author_id FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Mary' AND borrow_date = [specific_date]))
C. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Mary' AND borrow_date = [specific_date]))
D. SELECT A.author_name FROM Authors AS A WHERE A.author_id NOT IN (SELECT
author_id FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers
WHERE borrower_name = 'Mary' AND borrow_date = [specific_date]))
Correct Answer : A
Find the authors who have written books borrowed by borrowers with names that contain
the letter 'Z,' and display the titles of those books.
A. SELECT A.author_name, B.title FROM Authors AS A JOIN Books AS B ON A.author_id =
B.author_id WHERE B.book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name LIKE '%Z%')
B. SELECT A.author_name, B.title FROM Authors AS A JOIN Books AS B ON A.author_id =
B.author_id WHERE B.book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Z')
C. SELECT A.author_name, B.title FROM Authors AS A JOIN Books AS B ON A.author_id =
B.author_id WHERE B.book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name LIKE 'Z')
D. SELECT A.author_name, B.title FROM Authors AS A JOIN Books AS B ON A.author_id =
B.author_id WHERE B.book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'Z')
Correct Answer : A
Retrieve the titles of books that have been borrowed by borrowers who have also
borrowed books by a specific author.
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_id IN (SELECT borrower_id FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id])))
B. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_id IN (SELECT borrower_id FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id <> [author_id])))
C. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_id NOT IN (SELECT borrower_id FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id = [author_id])))
D. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_id NOT IN (SELECT borrower_id FROM Borrowers WHERE book_id IN (SELECT
book_id FROM Books WHERE author_id <> [author_id])))
Correct Answer : A
Q791. Consider the Library Database with Following tables
Books (book_id: Numeric PK, title: String, author_id: Numeric FK to Authors, available_copies:
Numeric)
Authors (author_id: Numeric PK, author_name: String)
Borrowers (borrower_id: Numeric PK, borrower_
List the borrowers who have borrowed books from authors who have not written any
books with more than 5 available copies.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id NOT IN (SELECT author_id FROM Books WHERE
available_copies > 5))
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id NOT IN (SELECT author_id FROM Books WHERE
available_copies <= 5))
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE author_id NOT IN (SELECT author_id FROM Books WHERE
available_copies > 5))
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE author_id NOT IN (SELECT author_id FROM Books WHERE
available_copies <= 5))
Correct Answer : A
Retrieve the names of borrowers who have borrowed books with titles that contain the
word 'Database' and were published in the same year as a book written by a specific author.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE title LIKE '%Database%' AND EXTRACT(YEAR FROM
publish_date) = (SELECT EXTRACT(YEAR FROM publish_date) FROM Books WHERE
author_id = [author_id]))
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE title LIKE '%Database%' AND EXTRACT(YEAR FROM
publish_date) = (SELECT EXTRACT(YEAR FROM publish_date) FROM Books WHERE
author_id <> [author_id]))
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE title LIKE '%Database%' AND EXTRACT(YEAR FROM
publish_date) = (SELECT EXTRACT(YEAR FROM publish_date) FROM Books WHERE
author_id = [author_id]))
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id NOT IN (SELECT
book_id FROM Books WHERE title LIKE '%Database%' AND EXTRACT(YEAR FROM
publish_date) = (SELECT EXTRACT(YEAR FROM publish_date) FROM Books WHERE
author_id <> [author_id]))
Correct Answer : A
Find the authors who have written books that have never been borrowed by any borrower.
A. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers))
B. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers))
C. SELECT author_name FROM Authors WHERE author_id IN (SELECT author_id FROM
Books WHERE book_id IN (SELECT book_id FROM Borrowers))
D. SELECT author_name FROM Authors WHERE author_id NOT IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers))
Correct Answer : A
Retrieve the titles of books that have been borrowed by all borrowers.
A. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(DISTINCT borrower_id) = (SELECT COUNT(DISTINCT
borrower_id) FROM Borrowers))
B. SELECT title FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers)
C. SELECT title FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers GROUP
BY book_id HAVING COUNT(DISTINCT borrower_id) > 1)
D. SELECT title FROM Books WHERE book_id NOT IN (SELECT book_id FROM Borrowers
GROUP BY book_id HAVING COUNT(DISTINCT borrower_id) = (SELECT COUNT(DISTINCT
borrower_id) FROM Borrowers))
Correct Answer : A
List the authors who have written books borrowed by borrowers named 'John' and 'Jane,'
but not borrowed by 'Alice' or 'Bob.'
A. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'John')) AND A.author_id IN (SELECT author_id FROM Books WHERE
book_id IN (SELECT book_id FROM
B. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'John')) AND A.author_id IN (SELECT author_id FROM Books WHERE
book_id IN (SELECT book_id FROM
C. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'John')) OR A.author_id IN (SELECT author_id FROM Books WHERE
book_id IN (SELECT book_id FROM B
D. SELECT A.author_name FROM Authors AS A WHERE A.author_id IN (SELECT author_id
FROM Books WHERE book_id IN (SELECT book_id FROM Borrowers WHERE
borrower_name = 'John')) OR A.author_id IN (SELECT author_id FROM Books WHERE
book_id IN (SELECT book_id FROM B
Correct Answer : A
Q796. Consider the Library Database with Following tables
Books (book_id: Numeric PK, title: String, author_id: Numeric FK to Authors, available_copies:
Numeric)
Authors (author_id: Numeric PK, author_name: String)
Borrowers (borrower_id: Numeric PK, borrower_
Retrieve the names of borrowers who have borrowed books by an author who has never
written a book with more than 3 available copies in the library.
A. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id IN (SELECT author_id FROM Books WHERE
author_id NOT IN (SELECT author_id FROM Books WHERE available_copies > 3)))
B. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id IN (SELECT author_id FROM Books WHERE
author_id IN (SELECT author_id FROM Books WHERE available_copies <= 3)))
C. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id IN (SELECT author_id FROM Books WHERE
author_id NOT IN (SELECT author_id FROM Books WHERE available_copies > 3)))
D. SELECT Br.borrower_name FROM Borrowers AS Br WHERE Br.book_id IN (SELECT
book_id FROM Books WHERE author_id IN (SELECT author_id FROM Books WHERE
author_id NOT IN (SELECT author_id FROM Books WHERE available_copies <= 3)))
Correct Answer : A
You are developing an e-commerce application. A customer adds items to their shopping
cart, and you want to ensure that their cart data is consistent throughout the shopping process.
Which SQL transaction isolation level should you use to prevent other u
A. READ UNCOMMITTED
B. READ COMMITTED
C. SERIALIZABLE
D. REPEATABLE READ
Correct Answer : C
You are working on an inventory management system. A user is trying to update the
quantity of a product in the database while another user is simultaneously trying to delete the
same product. What transaction isolation level can prevent this scenario?
A. READ UNCOMMITTED
B. READ COMMITTED
C. SERIALIZABLE
D. REPEATABLE READ
Correct Answer : C
A database system uses the Two-Phase Commit (2PC) protocol to manage distributed
transactions. What is the purpose of the first phase in 2PC?
A. To obtain locks on the participating data
B. To prepare all participants to commit the transaction
C. To roll back the transaction if any participant cannot commit
D. To release locks and finalize the transaction
Correct Answer : B
In a banking application, a user is transferring money from their account to another user's
account. During the transaction, you want to ensure that either both the debit and credit
operations succeed or both fail. Which SQL transaction command should be
A. COMMIT
B. ROLLBACK
C. SAVEPOINT
D. BEGIN TRANSACTION
Correct Answer : B
In a reservation system, a user is booking tickets for an event, and you want to ensure that
no other user can book the same seats while this transaction is in progress. What SQL command
should you use to lock the selected seats?
A. LOCK TABLE
B. BEGIN TRANSACTION
C. SET TRANSACTION ISOLATION LEVEL
D. SELECT ... FOR UPDATE
Correct Answer : D
In a forum application, users are posting comments on a thread. You want to ensure that
comments posted by one user are displayed together and don't interleave with comments from
other users. What SQL transaction isolation level should you use in this ca
A. READ UNCOMMITTED
B. READ COMMITTED
C. SERIALIZABLE
D. REPEATABLE READ
Correct Answer : A
A user is submitting a purchase order in an e-commerce system. You want to ensure that
the order is processed entirely, including payment, and that nothing is left in an inconsistent state.
What SQL transaction command should you use?
A. BEGIN TRANSACTION
B. LOCK TABLE
C. SAVEPOINT
D. CHECKPOINT
Correct Answer : A
You are developing a real-time messaging application. When a user sends a message, you
want to ensure that it appears immediately to the recipient but remains invisible to others until
the transaction is complete. What SQL transaction isolation level sho
A. READ UNCOMMITTED
B. READ COMMITTED
C. SERIALIZABLE
D. REPEATABLE READ
Correct Answer : B
In a library management system, a user is borrowing multiple books. You want to ensure
that all books are successfully borrowed or none at all. What SQL transaction command should be
used to achieve this?
A. COMMIT
B. ROLLBACK
C. SAVEPOINT
D. BEGIN TRANSACTION
Correct Answer : D
A user is trying to update their profile information in a CRM system. You want to ensure
that the user's information remains consistent and locked during the update. What SQL
transaction isolation level should be used for this operation?
A. READ UNCOMMITTED
B. READ COMMITTED
C. SERIALIZABLE
D. REPEATABLE READ
Correct Answer : C
Q808. Choose the Correct Option
You are implementing a point-of-sale system for a retail store. During a sales transaction,
you need to ensure that both the deduction from the inventory and the charging of the customer's
account occur successfully. What SQL transaction command should y
A. COMMIT
B. ROLLBACK
C. SAVEPOINT
D. BEGIN TRANSACTION
Correct Answer : B
You are developing a reservation system for booking airline tickets. During the reservation
process, you want to ensure that the seats being reserved are locked and unavailable for other
users. What SQL command should you use to achieve this?
A. LOCK TABLE
B. BEGIN TRANSACTION
C. SET TRANSACTION ISOLATION LEVEL
D. SELECT ... FOR UPDATE
Correct Answer : D
In a stock trading system, a user is placing an order to buy a certain number of shares at a
specific price. You want to ensure that no other user can execute an order for the same shares
simultaneously. What kind of lock or constraint should be used in
A. Shared lock
B. Exclusive lock
C. Unique constraint
D. Check constraint
Correct Answer : B
After a system crash, a database needs to be restored to its previous state using
transaction logs. What is the term for this process?
A. Backup
B. Rollback
C. Recovery
D. Replication
Correct Answer : C
In database recovery, what does the term Point-in-Time Recovery refer to?
A. Recovering to the current time
B. Recovering to the last backup
C. Recovering to a specific time in the past
D. Recovering without logs
Correct Answer : C
During a recovery process, a database administrator needs to identify the transactions that
were in progress when a failure occurred. What is this step called?
A. Rollback
B. Redo
C. Undo
D. Checkpoint
Correct Answer : B
When restoring a database, what does the term Full Recovery Model mean in the context
of Microsoft SQL Server?
A. Only full backups are used for recovery
B. All transaction logs are retained for recovery
C. Only specific tables are recovered
D. No recovery options are available
Correct Answer : B
A database system uses a physical backup of the database files for recovery. What is the
term for this type of backup?
A. Logical backup
B. Differential backup
C. Incremental backup
D. Full backup
Correct Answer : D
After a power outage, a database needs to be restored to its previous state. What type of
recovery is typically required in this scenario?
A. Point-in-Time Recovery
B. Full Recovery
C. Crash Recovery
D. Partial Recovery
Correct Answer : C
During database recovery, what is the purpose of the redo log or roll-forward phase?
A. To undo transactions that were incomplete
B. To apply committed transactions to restore the database
C. To roll back the database to a previous state
D. To validate user privileges
Correct Answer : B
Q822. Choose the Correct Option
In a database recovery process, what is the primary role of a shadow copy or snapshot?
A. To create a physical backup
B. To provide a read-only copy of the database
C. To store transaction logs
D. To recover to a specific point in time
Correct Answer : B
What recovery method would you use if you need to restore a database to a specific date
and time in the past?
A. Full Recovery
B. Crash Recovery
C. Point-in-Time Recovery
D. Rollback Recovery
Correct Answer : C
In the context of database recovery, what is the purpose of a redo log or transaction log?
A. To track user logins and logouts
B. To store the current state of the database
C. To record all committed changes made to the database
D. To recover lost data from backups
Correct Answer : C
During database recovery, what is the undo log or rollback phase used for?
A. To recover the database to a specific point in time
B. To apply committed transactions to restore the database
C. To undo incomplete transactions and restore the previous state
D. To make the database read-only
Correct Answer : C
What is the primary goal of a recovery plan in the context of database recovery?
A. To prevent data loss
B. To create backups
C. To improve database performance
D. To create new tables
Correct Answer : A
After a database failure, which type of recovery process is needed when you have a full
backup and all transaction logs since the backup?
A. Point-in-Time Recovery
B. Full Recovery
C. Crash Recovery
D. Rollback Recovery
Correct Answer : B
A company wants to secure its sensitive customer data. Which of the following
mechanisms is most appropriate for data encryption at rest in a relational database?
A. TLS/SSL
B. Data masking
C. Transparent Data Encryption (TDE)
D. Row-level security
Correct Answer : C
An organization needs to ensure that only authorized users can access the database. Which
of the following authentication methods provides the highest level of security?
A. Using weak passwords
B. Multi-factor authentication (MFA)
C. No authentication
D. Single sign-on (SSO)
Correct Answer : B
A database stores credit card information, and the organization must comply with PCI DSS
(Payment Card Industry Data Security Standard). What is the best practice for handling credit card
data in the database?
A. Store full credit card numbers with no encryption
B. Avoid storing credit card data entirely
C. Store hashed or tokenized credit card data
D. Share credit card data openly within the organization
Correct Answer : C
In a scenario where a company has a disaster recovery site for its database, what type of
security mechanism ensures that data is secure during replication and transfer between sites?
A. Firewalls
B. Virtual Private Networks (VPNs)
C. Secure Socket Layer (SSL)
D. Data encryption in transit
Correct Answer : D
What will be the correct syntax for the `RETURN_BOOK` stored procedure to update the
`return_date` and increase the `available_copies` count in the Books table?**
A. BEGIN
UPDATE Borrowers
SET return_date = SYSDATE;
UPDATE Books
SET available_copies = available_copies + 1;
END;
```
B. FUNCTION RETURN_BOOK (borrower_id IN NUMBER, book_id IN NUMBER) IS
BEGIN
UPDATE Borrowers
SET return_date = SYSDATE
WHERE borrower_id = borrower_id
AND book_id = book_id;
UPDATE Books
SET available_copies = available_copies + 1
UPDATE Books
SET available_copies = available_copies + 1
UPDATE Books
SET available_copies = available_copies + 1
Correct Answer : C
What will be the effect of the following code snippet in the `RETURN_BOOK` stored
procedure?**
```sql
DECLARE
v_borrow_count NUMBER;
BEGIN
SELECT COUNT(*) INTO v_borrow_count
FROM Borrowers
WHERE borrower_id = borrower_id
AND book_id
A. It will always mark the book as returned, regardless of its borrow status.
B. It will only mark the book as returned if it is currently borrowed by the specified
borrower.
C. It will mark the book as returned for all borrowers.
D. It will cause a syntax error due to incorrect variable usage.
Correct Answer : B
D. IF v_book_id = 0 THEN
dbms_output.put_line('Book not found in the library.');
END IF;
```
Correct Answer : A
Which PL/SQL construct ensures that the `RETURN_BOOK` procedure updates the
`return_date` and increases the `available_copies` count atomically without interference from
other transactions?**
A. Transaction Control Statements (COMMIT and ROLLBACK).
B. Triggers.
C. Autonomous Transactions.
D. Exception Handling.
Correct Answer : A
Which SQL clause should be used to filter borrowers who have overdue books in the
NOTIFY_OVERDUE_BORROWERS procedure?
A. WHERE
B. HAVING
C. FROM
D. SELECT
Correct Answer : A
What is the correct SQL query to find borrowers with overdue books in the
NOTIFY_OVERDUE_BORROWERS procedure?
A. SELECT borrower_name
FROM Borrowers
WHERE return_date < SYSDATE;
B. SELECT borrower_name
FROM Borrowers
WHERE return_date > SYSDATE;
C. SELECT borrower_name
FROM Borrowers
WHERE return_date <= SYSDATE;
D. SELECT borrower_name
FROM Borrowers
WHERE return_date >= SYSDATE;
Correct Answer : A
Which PL/SQL loop construct is suitable for iterating through the list of borrowers with
overdue books in the NOTIFY_OVERDUE_BORROWERS procedure?
A. FOR loop
B. WHILE loop
C. REPEAT loop
D. CURSOR loop
Correct Answer : A
Which keyword is used to refer to the old column value inside a trigger in PL/SQL?
A. OLD
B. PREVIOUS
C. PRIOR
D. ORIGINAL
Correct Answer : A
Which system event does the statement-level trigger fire in response to?
A. AFTER DELETE
B. AFTER LOGON
C. AFTER SERVERERROR
D. AFTER ROLLBACK
Correct Answer : B
In PL/SQL triggers, which package provides a way to store diagnostic information about
executed statements and errors?
A. DBMS_OUTPUT
B. DBMS_ALERT
C. DBMS_TRACE
D. DBMS_UTILITY
Correct Answer : C
Q898. Choose the Correct Option
Which type of trigger is fired automatically before or after each row affected by an INSERT,
UPDATE, DELETE, or MERGE statement?
A. DDL Trigger
B. Compound Trigger
C. Row-Level Trigger
D. Statement-Level Trigger
Correct Answer : C
Which clause is used to specify the timing of a trigger (BEFORE or AFTER) in Oracle PL/SQL?
A. FOR EACH ROW
B. WHEN
C. ON EVENT
D. BEFORE / AFTER
Correct Answer : D
Which system event does the database-level trigger fire in response to?
A. AFTER SERVERERROR
B. AFTER STARTUP
C. AFTER LOGOFF
D. AFTER SCHEMA
Correct Answer : B
What does the FOR EACH ROW clause in a trigger definition indicate?
A. The trigger fires for each row affected by the triggering statement.
B. The trigger fires only once, regardless of the number of rows affected by the triggering
statement.
C. The trigger fires for each table in the database.
D. The trigger fires for each row in the database.
Correct Answer : A
What does the BEFORE INSERT OR UPDATE ON table_name FOR EACH ROW syntax define
in a trigger?
A. A row-level trigger that fires before an INSERT or UPDATE operation on the specified
table.
B. A statement-level trigger that fires before an INSERT or UPDATE operation on the
specified table.
C. A trigger that fires after an INSERT or UPDATE operation on the specified table.
D. A trigger that fires before any data manipulation operation on the specified table.
Correct Answer : A
Which PL/SQL construct should be used to prevent the mutating table error in a trigger?
A. Autonomous Transaction
B. Compound Trigger
C. PRAGMA AUTONOMOUS_TRANSACTION
D. Row-Level Trigger
Correct Answer : B
Which keyword is used to refer to the public components of a package from outside the
package?
A. PUBLIC
B. EXTERNAL
C. PACKAGE
D. PACKAGE_NAME
Correct Answer : A
Which keyword is used to specify the visibility of a package component within the package
body?
A. PRIVATE
B. PUBLIC
C. INTERNAL
D. PACKAGE
Correct Answer : A
What happens if two or more packages contain a procedure or function with the same
name?
A. The PL/SQL compiler generates an error.
B. The packages cannot be compiled.
C. The package with the most recent modification is used.
D. The package with the higher access privilege is used.
Correct Answer : A
What does the "I" stand for in the ACID properties of transactions?
A. Integrity
B. Isolation
C. Insertion
D. Induction
Correct Answer : B
Which isolation level ensures that transactions do not interfere with each other at all?
A. READ UNCOMMITTED
B. READ COMMITTED
C. REPEATABLE READ
D. SERIALIZABLE
Correct Answer : D
What does the "C" stand for in the ACID properties of transactions?
A. Consistency
B. Concurrency
C. Commitment
D. Conformance
Correct Answer : A
```sql
account_holder VARCHAR2(100),
balance NUMBER(10, 2)
);
```plsql
DECLARE
v_balance NUMBER;
BEGIN
SELECT balance
INTO v_balance
FROM Bank
```
2. What is the data type of the "balance" column in the "Bank" table?
a) String
b) Date
c) Number
d) Boolean
Answer: c) Number
a) INSERT
b) DELETE
c) SELECT
d) UPDATE
Answer: c) SELECT
d) To define a cursor
```plsql
DECLARE
v_employee_count NUMBER;
BEGIN
FROM Employees;
END;
```
MCQs:
2. In the code snippet, what is the value stored in the `v_employee_count` variable?
a) Employee names
b) Employee IDs
d) Employee salaries
a) INSERT
b) DELETE
c) SELECT
d) UPDATE
Answer: c) SELECT
d) To define a cursor
a) TRY-CATCH
b) EXCEPTION
c) ERROR-HANDLER
d) ON-ERROR
Answer: b) EXCEPTION
a) To define variables
c) To declare procedures
d) To manage transactions
8. What is the expected output of the code snippet if there are 100 employees in the "Employees"
table?
b) Total Employees: 0
c) Total Employees: 1
d) Total Employees: 99
a) String
b) Date
c) Number
d) Boolean
Answer: c) Number
c) Using an IN parameter
Here's a PL/SQL package with a "College" table and some basic code snippets :
```sql
student_name VARCHAR2(50),
major VARCHAR2(50)
);
+------------+--------------+-------------------+
+------------+--------------+-------------------+
+------------+--------------+-------------------+
```plsql
END College_Package;
/
biology_count NUMBER;
BEGIN
biology_count := getStudentCountByMajor('Biology');
RETURN biology_count;
END;
END College_Package;
```
MCQ 1: Which column is used to uniquely identify students?
A) student_id
B) student_name
C) major
Answer: A) student_id
A) 1
B) 2
C) 3
D) 0
Answer: A) 1
MCQ 3: What is the data type of the "student_name" column in the College table?
A) NUMBER
B) VARCHAR2
C) DATE
D) BOOLEAN
Answer: B) VARCHAR2
MCQ 4: Which PL/SQL construct is used to loop through records in a result set?
A) FOR loop
B) IF statement
C) WHILE loop
D) CASE statement
A) 1
B) 2
C) 3
D) 0
Answer: A) 1
A) DEFINE
B) DECLARE
C) VARIABLE
D) SET
Answer: B) DECLARE
```plsql
DECLARE
total_students NUMBER;
BEGIN
END;
```
A) RAISE
B) THROW
C) EXCEPTION
D) ERROR
Answer: A) RAISE
MCQ 9: What is the purpose of the PRIMARY KEY constraint in the College table?
MCQ 10: Which PL/SQL construct is used to handle exceptions in a controlled manner?
A) TRY...CATCH block
B) EXCEPTION block
C) ERROR block
D) HANDLE block
Here's a PL/SQL code snippet for a hypothetical "hospital" table, along with 10 multiple-choice
questions (MCQs)
Let's create a PL/SQL trigger for the "hospital" table. This trigger updates the "patient_count" column
in a separate "hospital_stats" table whenever a new patient is inserted into the "hospital" table.
```sql
total_patients NUMBER
);
patient_name VARCHAR2(50),
admission_date DATE,
discharge_date DATE
);
BEGIN
UPDATE hospital_stats
END;
```
b) To update the total count of patients in the "hospital_stats" table when a new patient is inserted.
Correct Answer: b
Correct Answer: d
Correct Answer: c
c) To store statistics related to the hospital, such as the total number of patients.
Correct Answer: c
Correct Answer: b
6. What happens if you attempt to insert a new patient record without specifying values for
"patient_name," "admission_date," and "discharge_date"?
Correct Answer: b
a) WHEN
b) BEFORE
c) AFTER
d) TRIGGER
Correct Answer: c
8. What is the primary purpose of the `UPDATE hospital_stats SET total_patients = total_patients +
1;` statement in the trigger?
Correct Answer: c
9. Can you have multiple triggers with the same timing (e.g., AFTER INSERT) on the same table?
10. What does the `CREATE SEQUENCE patient_id_seq START WITH 1;` statement do in the code
snippet?
Correct Answer: c
A PL/SQL procedure that takes two numbers as input parameters, adds them together, and then
displays the result using dbms_output:
```sql
p_num1 IN NUMBER,
p_num2 IN NUMBER
) AS
v_result NUMBER;
BEGIN
END add_numbers;
```
```sql
DECLARE
BEGIN
add_numbers(num1, num2);
END;
```
This will call the `add_numbers` procedure with `num1` and `num2` as arguments and display the
sum.
1. What is the purpose of the PL/SQL procedure mentioned in the code snippet?
Answer: B
A. None
B. One
C. Two
D. Three
Answer: C
3. What data type are the input parameters `p_num1` and `p_num2` in the `add_numbers`
procedure?
A. VARCHAR2
B. DATE
C. NUMBER
D. BOOLEAN
Answer: C
Answer: B
Answer: C
6. What should you do to call the `add_numbers` procedure with specific numbers as arguments?
Answer: C
7. In the example provided for calling the procedure, what are the values of `num1` and `num2`?
Answer: C
8. What is the result of calling the `add_numbers` procedure with `num1` and `num2` as arguments
in the example?
A. 10
B. 20
Answer: C
A. CREATE PROCEDURE
B. DECLARE PROCEDURE
C. EXECUTE PROCEDURE
D. CALL PROCEDURE
Answer: A
D. To declare a function.
Answer: C
A) Data storage
B) Data retrieval
C) Data backup
D) Data restoration
3. Which of the following is NOT a type of error that can lead to the need for database recovery?
A) Human errors
B) Software errors
C) Hardware failures
4. What type of error occurs when a user accidentally deletes important data from a database?
A) Human error
B) Software error
C) Hardware failure
D) Network error
A) Incremental backup
B) Full backup
C) Partial backup
D) Log-based recovery
6. Which recovery technique involves capturing changes made to the database since the last backup
and applying those changes to restore the database?
A) Incremental backup
B) Full backup
C) Partial backup
D) Rollback recovery
7. What is a common method used to track changes to a database and support recovery?
A) Version control
B) Transaction logs
C) Database normalization
D) Data encryption
8. Which recovery technique involves undoing incomplete transactions to bring the database back to
a consistent state?
A) Incremental backup
B) Rollback recovery
C) Full backup
D) Point-in-time recovery
C) To mark a point in time when all committed transactions are safely stored on disk
Answer: C) To mark a point in time when all committed transactions are safely stored on disk
10. Which recovery technique allows for recovering the database to a specific point in time, rather
than just the last backup?
A) Incremental backup
B) Rollback recovery
C) Point-in-time recovery
D) Full backup
Q1. Which data model allows data to be represented as interconnected nodes, forming a web-like
structure?
a) Relational model
b) Hierarchical model
c) Network model
d) Graph model
Q2. What does a dashed line between two entities in an ER diagram represent?
b) SQL queries
c) Dependency diagrams
d) Dependency matrices
Q5. Which SQL clause is used to group rows based on a specific column in a SELECT statement?
a) SELECT
b) FROM
c) WHERE
d) GROUP BY
Q6. Which SQL aggregate function is used to calculate the average value of a column?
a) COUNT
b) SUM
c) AVG
d) MAX
Q7. Which SQL aggregate function is used to calculate the total number of rows in a result set?
a) COUNT
b) SUM
c) AVG
d) MAX
Q8. Which SQL join type returns only the rows that have matching values in both tables?
a) INNER JOIN
b) LEFT JOIN
c) RIGHT JOIN
d) FULL OUTER JOIN
Q9. Which SQL join type returns all the rows from the left table and the matching rows from the right
table?
a) INNER JOIN
b) LEFT JOIN
c) RIGHT JOIN
Q10. Which SQL clause is used to filter rows based on a set of multiple conditions?
a) AND
b) OR
c) NOT
d) XOR
Section - B
(Q 11 to 25: Each question carries 2 marks)
Q11. Which SQL query is used to retrieve all records from a table named "Employees"?
d) SELECT Employees;
Q12. Which SQL query is used to retrieve records from two tables named "Orders" and "Customers"
based on a common column "CustomerID"?
Q14. Which of the following statements are TRUE about an SQL query?
P: An SQL query can contain a HAVING clause even if it does not a GROUP BY clause
Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R: All attributes used in the GROUP BY clause must appear in the SELECT clause
S: Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
(A) P and R
(B) P and S
(C) Q and R
(D) Q and S
Q15. Given the basic ER and relational models, which of the following is INCORRECT?
(C) In a row of a relational table, an attribute can have more than one value
(D) In a row of a relational table, an attribute can have exactly one value or a NULL value
Q16.
`flights` table:
`passengers` table:
Which SQL query retrieves the names of passengers who are on a flight departing from New York and
arriving in Los Angeles?
A. `SELECT passenger_name FROM passengers WHERE flight_id IN (SELECT flight_id FROM flights
WHERE departure_city = 'New York' AND arrival_city = 'Los Angeles');`
B. `SELECT passenger_name FROM passengers WHERE flight_id = (SELECT flight_id FROM flights
WHERE departure_city = 'New York' AND arrival_city = 'Los Angeles');`
C. `SELECT passenger_name FROM passengers WHERE flight_id = (SELECT flight_id FROM flights
WHERE departure_city = 'New York') AND flight_id = (SELECT flight_id FROM flights WHERE
arrival_city = 'Los Angeles');`
D. `SELECT passenger_name FROM passengers WHERE flight_id IN (SELECT flight_id FROM flights
WHERE departure_city = 'Los Angeles' AND arrival_city = 'New York');
Q17.
Q18.
`accounts` table:
`transactions` table:
Which SQL query returns the account numbers and balances of accounts that have never been
involved in a withdrawal transaction?
A.
FROM accounts a
WHERE a.account_id NOT IN (SELECT DISTINCT account_id FROM transactions WHERE
transaction_type = 'Withdrawal');
B.
FROM accounts a
WHERE NOT EXISTS (SELECT 1 FROM transactions WHERE account_id = a.account_id AND
transaction_type = 'Withdrawal');
C.
FROM accounts a
D.
FROM accounts a
Given this schema of a student Database give answers to the following query:
first_name VARCHAR(50),
last_name VARCHAR(50),
date_of_birth DATE,
email VARCHAR(100),
phone_number VARCHAR(20),
address VARCHAR(100)
);
course_name VARCHAR(100),
course_description VARCHAR(255),
credits INT
);
student_id INT,
course_id INT,
enrollment_date DATE,
grade VARCHAR(2),
);
Gives multiple-choice questions (MCQs) answer based on queries that can be performed on the given
database schema->
Q19.
Which query would you use to retrieve the names of all students who are enrolled in the course
with course_id 101?
FROM Courses
GROUP BY course_name;
A) Retrieves a list of all courses along with the count of enrolled students in each course.
B) Retrieves a list of all courses along with the count of distinct course IDs.
C) Retrieves a list of all students along with the courses they are enrolled in.
D) Retrieves a list of all students along with their grades in each course.
Q21. Which query would you use to find the average number of credits for all courses?
FROM Students
B) Retrieves the names of students along with their enrolled courses, regardless of the grade.
C) Retrieves the names of students who are enrolled in courses with the name 'A'.
D) Retrieves the names of students who have not received any grades.
Given this schema of a Database to manage multiple restaurants give answers to the following
queries:
name VARCHAR(100),
address VARCHAR(100),
phone_number VARCHAR(20),
opening_time TIME,
closing_time TIME
);
restaurant_id INT,
name VARCHAR(100),
description VARCHAR(255),
);
restaurant_id INT,
table_number INT,
order_date DATE,
);
Order Items Table to track the items ordered within each order:
order_id INT,
item_id INT,
quantity INT,
);
Gives multiple-choice questions (MCQs) answers based on queries that can be performed on the
given restaurant database schema->
Q23. What type of relationship is defined between the "Restaurants" and "MenuItems" tables?
A) One-to-one
B) One-to-many
C) Many-to-one
D) Many-to-many
Q24. Which query would you use to update the price of a menu item with item_id 501 to $15.99?
FROM MenuItems
A) Retrieves the maximum price of all menu items in restaurant with ID 601.
B) Retrieves the minimum price of all menu items in restaurant with ID 601.
C) Retrieves the average price of all menu items in restaurant with ID 601.
D) Retrieves the total price of all menu items in restaurant with ID 601.
Q1. Which SQL clause is used to sort the result set in ascending or descending order?
a) SELECT
b) ORDER BY
c) GROUP BY
d) SORT BY
Q2. Which SQL clause is used to combine rows from two or more tables based on a related column
between them?
a) SELECT
b) FROM
c) WHERE
d) JOIN
Q3. Which SQL aggregate function is used to calculate the average value of a column?
a) COUNT
b) SUM
c) AVG
d) MAX
Q4. Which SQL join type returns all the rows from the left table and the matching rows from the right
table?
a) INNER JOIN
b) LEFT JOIN
c) RIGHT JOIN
Q5. Which SQL function is used to retrieve the current date and time?
a) GETDATE()
b) SYSDATE()
c) NOW()
d) CURRENT_TIMESTAMP()
a) UNIQUE
b) INDEX
c) PRIMARY KEY
d) CONSTRAINT
Q7. Which SQL clause is used to filter rows based on a set of multiple conditions?
a) AND
b) OR
c) NOT
d) XOR
Section - B
(Q 11 to 25: Each question carries 2 marks)
Q11. Which SQL query is used to retrieve records from two tables named "Orders" and "Customers"
based on a common column "CustomerID"?
Q12. Which SQL query is used to calculate the average value of a column named "Salary" from a
table named "Employees"?
Q13. Which SQL query is used to delete all records from a table named "Products" where the
"Category" column is 'Electronics'?
Q14. Which SQL query is used to count the number of records in a table named "Orders"?
Q15. Given the basic ER and relational models, which of the following is INCORRECT?
(C) In a row of a relational table, an attribute can have more than one value
(D) In a row of a relational table, an attribute can have exactly one value or a NULL value
Q16.
Consider the `flights` table:
Which SQL query calculates the average duration (in hours) of flights departing from New York?
Q17.
Which SQL query lists the flight names and the number of passengers on each flight for flights
departing from New York?
Q18.
`accounts` table:
`transactions` table:
Which SQL query returns the account numbers and balances of accounts that have never been
involved in a withdrawal transaction?
A.
FROM accounts a
B.
SELECT a.account_number, a.balance
FROM accounts a
WHERE NOT EXISTS (SELECT 1 FROM transactions WHERE account_id = a.account_id AND
transaction_type = 'Withdrawal');
C.
FROM accounts a
D.
FROM accounts a
Q19.
`customers` table:
`accounts` table:
Which SQL query retrieves the customer names and the total balance (sum of account balances) for
customers aged 30 or older?
A.
FROM customers c
GROUP BY c.customer_name;
B.
FROM customers
GROUP BY customer_name;
C.
FROM customers
GROUP BY customer_name;
D.
FROM customers c
LEFT JOIN accounts a ON c.customer_id = a.customer_id
GROUP BY c.customer_name;
Given this schema of a Database to manage multiple restaurants give answers to the following
queries:
name VARCHAR(100),
address VARCHAR(100),
phone_number VARCHAR(20),
opening_time TIME,
closing_time TIME
);
restaurant_id INT,
name VARCHAR(100),
description VARCHAR(255),
restaurant_id INT,
table_number INT,
order_date DATE,
);
Order Items Table to track the items ordered within each order:
order_id INT,
item_id INT,
quantity INT,
);
Gives multiple-choice questions (MCQs) answers based on queries that can be performed on the
given restaurant database schema, ->
Q20.
Which table contains information about the opening and closing times of restaurants?
A) Restaurants
B) MenuItems
C) Orders
D) OrderItems
Q21. Which query would you use to calculate the total revenue generated by a restaurant with
restaurant_id 201?
Q22.
FROM Orders
Q23.
Which query would you use to retrieve the names of menu items that were ordered in the order
with order_id 401?
FROM OrderItems
GROUP BY order_id
A) Retrieves the count of all menu items in each order with more than three items.
B) Retrieves the count of all orders with more than three menu items.
C) Retrieves the count of all menu items with more than three orders.
D) Retrieves the count of all orders and menu items combined, grouped by order_id.
Q25.
Which query would you use to update the price of a menu item with item_id 501 to $15.99?