Unit 5 - Practice Quiz

INT306 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which of the following statements about Stored Procedures is FALSE?

A. They are precompiled and stored in the database.
B. They can return multiple values using OUT parameters.
C. They must always return a value using the RETURN clause.
D. They reduce network traffic by executing on the server side.

2 In PL/SQL or T-SQL, which control structure is used to select one of many code blocks to execute based on a specific value?

A. WHILE loop
B. CASE statement
C. FOR loop
D. LOOP...EXIT

3 What is a Cursor in the context of database programming?

A. A lock held on a table during a transaction.
B. A pointer to a memory area that stores the result set of a query.
C. A type of trigger that fires before an update.
D. A function that returns a boolean value.

4 Which of the following states the correct order of operations for using an Explicit Cursor?

A. OPEN, DECLARE, FETCH, CLOSE
B. DECLARE, FETCH, OPEN, CLOSE
C. DECLARE, OPEN, FETCH, CLOSE
D. OPEN, FETCH, CLOSE, DEALLOCATE

5 Which cursor attribute returns the number of rows fetched so far?

A. %FOUND
B. %NOTFOUND
C. %ISOPEN
D. %ROWCOUNT

6 What distinguishes a Row-Level Trigger from a Statement-Level Trigger?

A. Row-level triggers fire once per transaction, Statement-level fire once per row.
B. Row-level triggers fire for each row affected by the operation, Statement-level fire once per SQL statement.
C. Row-level triggers cannot access OLD and NEW values.
D. Statement-level triggers are used only for SELECT statements.

7 In a trigger, what do the qualifiers :OLD and :NEW refer to?

A. The previous and next transaction IDs.
B. The values of columns before and after the data modification.
C. The timestamp of the previous and current login.
D. The old and new schema definitions.

8 Which block is used to handle runtime errors in PL/SQL?

A. CATCH block
B. EXCEPTION block
C. ERROR block
D. HANDLER block

9 What is the primary purpose of the RAISE statement in exception handling?

A. To increase the salary in a table.
B. To promote a transaction to a higher priority.
C. To explicitly generate a user-defined or standard exception.
D. To restart the database server.

10 Which of the following is NOT a property of a database Transaction (ACID)?

A. Atomicity
B. Concurrency
C. Isolation
D. Durability

11 The property of Atomicity guarantees that:

A. Transactions are executed in isolation.
B. The database remains consistent before and after execution.
C. All operations of the transaction are reflected in the database, or none are.
D. Updates persist even after a system crash.

12 Which state does a transaction enter immediately after it starts execution?

A. Active
B. Partially Committed
C. Committed
D. Failed

13 A transaction reaches the Committed state when:

A. The first instruction is executed.
B. The final statement has been executed, but not written to disk.
C. All operations are successfully completed and changes are permanently saved.
D. A hardware failure occurs.

14 What is the Consistency property in ACID?

A. Transactions must happen sequentially.
B. Execution of a transaction must take the database from one consistent state to another.
C. Changes must be written to the log immediately.
D. Transactions must not be interrupted by OS interrupts.

15 Consider two transactions and . If is updating a row and reads that row before commits, which isolation problem might occur?

A. Dirty Read
B. Phantom Read
C. Unrepeatable Read
D. Lost Update

16 What is a Schedule in the context of transaction management?

A. A timetable for database backups.
B. A sequence of instructions that specify the chronological order in which instructions of concurrent transactions are executed.
C. The list of users allowed to access the database.
D. The priority list of processes in the CPU.

17 A schedule is called Serial if:

A. Transactions are executed concurrently (interleaved).
B. Transactions are executed one after another, with no interleaving.
C. It contains a cycle in the precedence graph.
D. It results in a database inconsistency.

18 Two operations in a schedule are said to be in Conflict if:

A. They belong to the same transaction.
B. They access different data items.
C. They belong to different transactions, access the same data item, and at least one is a write operation.
D. They are both read operations.

19 A schedule is Conflict Serializable if:

A. It is view equivalent to a serial schedule.
B. It is conflict equivalent to a serial schedule.
C. It contains blind writes.
D. It provides higher throughput than any serial schedule.

20 In a Precedence Graph (Serialization Graph), a cycle indicates that:

A. The schedule is Conflict Serializable.
B. The schedule is NOT Conflict Serializable.
C. The system is in a deadlock.
D. The schedule is recoverable.

21 Which of the following is a condition for View Serializability but not necessarily Conflict Serializability?

A. Handling Blind Writes.
B. Ensuring no cascading rollbacks.
C. Ensuring ACID properties.
D. Locking all data items.

22 What is a Cascading Rollback?

A. When the database crashes and restarts.
B. When a single transaction failure leads to the rollback of a series of dependent transactions.
C. When a transaction is rolled back due to a deadlock.
D. When the log file fills up.

23 A schedule is Recoverable if:

A. For every pair of transactions and , if reads a data item written by , then commits before commits.
B. No deadlocks occur.
C. The precedence graph is acyclic.
D. It is conflict serializable.

24 What is a Shared Lock (S-Lock)?

A. A lock that allows both reading and writing.
B. A lock that allows only writing.
C. A lock that allows read access but prevents write access by other transactions.
D. A lock that prevents both read and write access.

25 In Two-Phase Locking (2PL) protocol, what happens in the Growing Phase?

A. The transaction releases locks but cannot acquire new ones.
B. The transaction acquires all necessary locks but cannot release any.
C. The transaction performs rollback operations.
D. The transaction writes to the log file.

26 The primary disadvantage of basic Two-Phase Locking (2PL) is:

A. It does not ensure serializability.
B. It can lead to Deadlocks.
C. It allows Dirty Reads.
D. It consumes too much memory.

27 Which concurrency control protocol uses system time or a logical counter to order transactions?

A. Two-Phase Locking
B. Timestamp Ordering Protocol
C. Graph-Based Protocol
D. Validation-Based Protocol

28 In the Wait-Die scheme for deadlock prevention (based on timestamps):

A. If an older transaction requests a resource held by a younger one, it waits. If younger requests from older, it dies.
B. If an older transaction requests a resource held by a younger one, the younger one is killed.
C. All transactions wait indefinitely.
D. Deadlocks are detected using a Wait-For Graph.

29 What is the Wound-Wait scheme?

A. A preemptive deadlock prevention scheme where older transactions force younger ones to abort (wound).
B. A scheme where all transactions wait for locks.
C. A scheme where younger transactions wait for older ones, and older ones die.
D. A method to handle log recovery.

30 The Phantom Read problem occurs when:

A. A transaction reads a value that is later updated by another transaction.
B. A transaction reads a row that has been deleted by another transaction.
C. A transaction executes a query returning a set of rows, and a concurrent transaction inserts a new row that matches the query criteria.
D. A transaction updates a row that was never read.

31 Which of the following is true about Strict Two-Phase Locking (Strict 2PL)?

A. It releases shared locks in the shrinking phase but holds exclusive locks until commit.
B. It holds all locks (shared and exclusive) until the transaction commits.
C. It does not guarantee recoverability.
D. It allows cascading rollbacks.

32 The Lost Update problem occurs when:

A. Two transactions read the same data and update it based on the read value, overwriting each other's changes.
B. A system crash deletes the log file.
C. An update is made to a temporary table.
D. A transaction reads uncommitted data.

33 What is the Thomas Write Rule used for?

A. To prevent deadlocks in 2PL.
B. To modify Timestamp Ordering to allow ignoring obsolete write operations.
C. To enforce strict serializability.
D. To manage cursor memory allocation.

34 A Casacadeless Schedule ensures that:

A. No transaction reads data written by an uncommitted transaction.
B. Transactions never abort.
C. Throughput is maximized.
D. Deadlocks are impossible.

35 Which parameter mode in a stored procedure allows a value to be passed in and an updated value to be returned?

A. IN
B. OUT
C. IN OUT
D. RETURN

36 In the context of database recovery, what is WAL?

A. Write-After-Log
B. Write-Ahead Logging
C. Wait-And-Lock
D. Write-Access-Level

37 Which PL/SQL loop structure is guaranteed to execute at least once?

A. WHILE loop
B. FOR loop
C. REPEAT...UNTIL (or basic LOOP with exit at bottom)
D. None of the above

38 What is the function of the INSTEAD OF trigger?

A. It runs after the standard action.
B. It is used primarily on Views to handle updates/inserts that are not inherently supported.
C. It is used to replace the database engine.
D. It runs before the transaction starts.

39 Which of the following creates a user-defined function?

A. CREATE PROCEDURE
B. CREATE TRIGGER
C. CREATE FUNCTION
D. DECLARE FUNCTION

40 Consider the precedence graph with nodes . If edges exist: and and , then:

A. The schedule is serializable.
B. The schedule is not conflict serializable.
C. must run first.
D. There are no conflicts.

41 Which level of isolation offers the highest data consistency but the lowest concurrency?

A. Read Uncommitted
B. Read Committed
C. Repeatable Read
D. Serializable

42 The Read Committed isolation level prevents:

A. Dirty Reads
B. Non-repeatable Reads
C. Phantom Reads
D. All of the above

43 In a cursor FOR loop (PL/SQL), which actions are performed automatically?

A. Only Fetching.
B. Only Opening and Closing.
C. Open, Fetch, and Close.
D. None, everything must be manual.

44 What is Granularity in the context of locking?

A. The size of the data item being locked (e.g., row, page, table).
B. The duration of the lock.
C. The number of locks a transaction can hold.
D. The strength of the encryption.

45 Which logic is used to detect a deadlock in a system using locks?

A. Wait-For Graph
B. Precedence Graph
C. Dependency Graph
D. ER Diagram

46 If a transaction fails, the process of undoing its actions is called:

A. Commit
B. Rollback
C. Redo
D. Savepoint

47 A Savepoint allows:

A. Rolling back the entire transaction only.
B. Committing the transaction partially.
C. Rolling back part of a transaction to a specific marker.
D. Saving the transaction to a separate file.

48 Which concurrency control problem is described by: ?

A. Dirty Read
B. Unrepeatable Read
C. Overwriting Uncommitted Data
D. Blind Write

49 In PL/SQL, what does the %TYPE attribute do?

A. Defines a new data type.
B. Declares a variable with the same data type as a database column or another variable.
C. Checks the type of a variable at runtime.
D. Converts a string to a number.

50 Which statement regarding Implicit Cursors is true?

A. They must be explicitly declared by the user.
B. They are created automatically by the database engine for DML statements (INSERT, UPDATE, DELETE).
C. They are used for queries returning multiple rows.
D. They require an OPEN and CLOSE statement.