Database Principles and Applications Chapter 10 Homework

1. Multiple choice questions (20 questions in total, 80 points)

  1. (Single-choice question, 4 points) The purpose of the transaction log is ( )
    A. Transaction processing
    B. Realize the security of the database
    C. Perform database recovery or concurrent operations
    D. Enabling data sharing

  2. (Single-choice question, 4 points) Which of the following statements about database mirroring is incorrect ( )
    A. It can be realized through disk mirroring
    B. It can be realized through cluster technology
    C. Mirroring is only for security, it will not increase the speed (it will also reduce the speed)
    D. Mirroring improves both security and speed

  3. (Single-choice question, 4 points) Which of the following is not the method used for database recovery ().
    A. Create a checkpoint
    B. Create a replica
    C. Create a log file
    D. to build an index

  4. (Single-choice question, 4 points) Regarding log-based recovery, which one is correct? ()
    A. UNDO can be performed by using the value before update in the update log record, and REDO can be performed by using the value before update in the update log record
    B. Use the pre-update value in the update log record to perform UNDO, and use the updated value in the update log record to perform REDO
    C. UNDO can be performed by using the updated value in the update log record, and REDO can be performed by using the value before the update in the update log record D. UNDO can be performed by
    using the updated value in the update log record, and use the updated value in the update log record value can be REDO

  5. (Multiple choice, 4 points) The key question of the recovery mechanism is ().
    A. Log file
    B. Data dump
    C. Create redundant data
    D. Data Mirroring

[Analysis] The key problem of database recovery mechanism is to establish redundant data. The main ways to establish redundant data are data dump and log file creation. When the standby database fails, use redundant data to restore.

  1. (Multiple choice, 4 points) For database recovery, the following description is correct ().
    A. The recovery of media failure does not require the participation of the DBA, and is automatically completed by the DBMS.
    B. The log files are recorded in strict order of transaction request time
    C. When recovering from a transaction failure, it is necessary to reverse scan the log and perform an UNDO operation on the incomplete transaction
    D. The database at the time of the checkpoint must be in a consistent state

Answer analysis: media failure can be hard disk damage, database physical file damage, DBA needs to update and load the backup, so option A is wrong; after the transaction request, the transaction scheduling subsystem of the DBMS arranges the response and concurrent execution scheduling, and the log is based on During the execution of each transaction, the order of data update time is recorded, which is not directly related to the request time, so option B is wrong; the checkpoint is set to improve the efficiency of fault recovery, and the recovery is based on the state of the database at this point. Recover to the time of failure, instead of recovering backward to the start time of the log in advance, setting a checkpoint allows the transaction to proceed, so the database is generally not required to be in a consistent state at this time, so option D is also wrong; when a transaction fails, the system must undo this For the update operation that has been performed by the transaction, the method is to scan the log in reverse, and perform UNDO on the update operation that has been performed by the transaction, so option C is correct.

  1. (Single-choice question, 4 points) For the recovery of transaction failure, the following description is correct ( ).
    A. The recovery of a transaction failure does not require access to the log file
    . B. The transaction that has been submitted by REDO is required for recovery of a transaction failure.
    C. The forward scan of the log is required for the recovery of a transaction failure, and the UNDO operation is performed on the transaction.
    D. When recovering from a transaction failure, it is necessary to reverse scan the log and perform an UNDO operation on the transaction

Answer analysis: [Analysis] This question examines the understanding of fault and recovery technology. Transaction failure refers to the inconsistency of the database caused by the failure to reach the expected end point (COMMIT or displayed ROLLBACK) during the operation process due to unexpected reasons during the operation of the transaction program. The recovery of a transaction failure means that the modification to the database that has been completed by the transaction that caused the failure needs to be undone. The modification content of the transaction to the database is recorded in the log in strict accordance with the order of execution time. By scanning the log file in reverse, the operation of the faulty transaction on the database can be restored (UNDO) one by one until the transaction starts. Execute the same, that is, the recovery is complete.

  1. (Multiple choice, 4 points) Which of the following statements about log-based recovery of database systems is correct ( ).
    A. UNDO can be performed by using the previous value in the update log record, and REDO can be performed by using the previous value in the update log record
    B. UNDO can be performed by using the pre-modified value in the update log record, and REDO can be performed by using the post-modified value in the update log record
    C. UNDO can be performed by using the changed value in the update log record, and REDO can be performed by using the changed value in the update log record. D.
    UNDO can be performed by using the changed value in the update log record. value can be REDO

Answer analysis: Log files play a very important role in database recovery, and they can well support the recovery of transaction failures and system failures. Use the pre-modification value in the update log record to perform UNDO, undo the modification operation, and restore the data item to the old value before the modification; use the post-modification value in the update log record to perform REDO, redo the completed operation , set the data item to the modified new value.

  1. (Single-choice question, 4 points) The database system of a shopping mall management system suddenly experienced a soft failure during operation, and the database administrator restarted the database after discovering the problem. After restarting, the system services are normal. The following operations may be performed during the restart of the device:
    Ⅰ. Redo committed transactions using log files
    Ⅱ. Roll back uncommitted transactions
    Ⅲ, use RAID technology to restore data
    Ⅳ. Use mirror database to restore data
    V. Use database backup to restore data
    In order to ensure data consistency, the possible operation of the system is ( ).
    A. Only Ⅰ
    B. Only I and II
    C. Only I, II and V
    D. All of the above

Answer analysis: System failure is also called soft failure. Such failures affect all running transactions. To eliminate the impact of these transactions on the database and ensure the consistency of data in the database, the method is to roll back the results of all unfinished transactions that may have been written in the database after the computer system is restarted. , to ensure the consistency of data in the database; for the result that some or all of the completed transactions may remain in the buffer, all committed transactions need to be redone to truly restore the database to a consistent state.

  1. (Single-choice question, 4 points) The principle of writing the log first is the principle that must be followed to maintain the database ( ) after a failure occurs
    A. Atomicity and persistence
    B. Consistency and durability
    C. Atomicity and consistency
    D. Atomicity and isolation

Answer analysis: For safety, you must write the log file first, that is, first write the log records to the log file, and then write the modification of the database. This is called the principle of writing the log first. This is done to keep the database atomic and durable after a failure.

  1. (Single-choice question, 4 points) If the system stops running due to some reason during the operation of the system, causing the transaction to terminate abnormally during execution, the information in the memory will be lost and stored in the external memory The data of is not affected, this situation is called ( )
    A. Transaction failure
    B. System failure
    C. Media failure
    D. Operation failure

  2. (Multiple choice, 4 points) The basis of database recovery is to use dumped redundant data. The redundant data of these dumps refers to ( )
    A. Data dictionary, application, audit archive, database backup copy
    B. Data dictionary, application, log file, audit archive
    C. Log files, database backup copies
    D. Data Dictionary, Application, Database Backup Copies

  3. (Single-choice question, 4 points) If the system is running due to some kind of hardware failure, resulting in partial or total loss of storage on the external memory, this situation is called ( ) A. Transaction failure B.
    System
    failure
    C. Media failure
    D. Malfunction

  4. (Multiple choice, 4 points) The process of making a backup copy is called ( )
    A. Data Dump
    B. Log file
    C. Transaction
    D. Incremental dump

  5. (Single-choice question, 4 points) The purpose of the transaction log is ( )
    A. Transaction processing
    B. Realize the security of the database
    C. Perform database recovery or concurrent operations
    D. Enabling data sharing

  6. (Single-choice question, 4 points) Which of the following statements about database mirroring is incorrect ()
    A. In a database mirroring session, the principal server and the mirror server communicate and cooperate as partners
    B. When the database is running normally, database mirroring can be used for Concurrent operation
    C. In the event of a media failure, the mirror database can continue to be used without shutting down the system and reinstalling the database copy
    D. Whenever the database is updated, the DBMS cannot automatically guarantee the consistency of the mirrored data and the primary data

Answer resolution: [Resolution] Database mirroring involves redoing every insert, update, and delete operation performed on the principal database into the mirror database as quickly as possible by applying each active transaction log record sequentially to the mirror database, so that , whenever the database is updated, the DBMS will automatically ensure the consistency of the mirrored data and the primary data.

  1. (Multiple choice, 4 points) Database mirroring can be used for ( ).
    A. To ensure the integrity of the database
    B. To achieve database security
    C. Perform database recovery or concurrent operations
    D. Enabling data sharing

Answer analysis: [Analysis] Regularly copying or dumping the entire database can realize database recovery. Dumping is a basic technique commonly used in database recovery. It refers to the process of DBA copying the database to another disk, which can be divided into static dump and dynamic dump.

  1. (Single-choice question, 4 points) Database mirroring has many advantages, but not including ().
    A. Provide complete or nearly complete data allowance to improve data reliability
    B. When the main database system fails, database mirroring can be quickly enabled to provide services
    C. Reduce the construction cost of the database storage system
    D. Improve the availability of the primary database system during the upgrade

Answer analysis: Analysis] Database mirroring has the following advantages: database mirroring provides complete or near-complete data redundancy and enhances data protection; when a disaster occurs, database mirroring can quickly enable the standby copy of the database to provide services, so that data will not be lost. Increases database availability; increases mirrored database availability during upgrades. Database mirroring is to copy the entire database or its key data to another disk, and its construction cost will only increase.

  1. (Single choice, 4 points) Which of the following statements is incorrect about recovery techniques with checkpoints? () A.
    Checkpoints minimize the portion of the log that must be performed when the database is fully recovered
    B. Using checkpoint methods can improve recovery efficiency
    C. Regardless of whether the transaction is committed before or after the checkpoint, the REDO operation needs to be performed
    D. The complex subsystem can establish checkpoints periodically, or according to certain rules

Answer analysis: [Analysis] When a transaction is committed before a checkpoint, all modifications made to the database must have been written to the database, and the write time is before or when the checkpoint is established. At this time There is no need to perform REDO operations on the transaction.

  1. (Single-choice question, 4 points) Regarding the checkpoint recovery technology, which of the following statements is wrong ()
    A. The use of checkpoints can reduce the workload of log searches in the recovery subsystem in the DBMS
    B. Checkpoints can be established at a predetermined time interval , can also be established according to some rules
    C. Checkpoint records are generally not saved in the log file, but are written separately in the checkpoint record file
    D. Before establishing a checkpoint, all logs in the system log buffer need to be written to the disk log file

Answer analysis: Correct answer: C Analysis: Checkpoints minimize the log part that must be executed when the database is fully restored; checkpoints can be established at a predetermined time interval, or according to certain rules; checkpoint records are written into the log file instead of being written separately in the checkpoint log file.

2. Short answer questions (2 questions in total, 20 points)

  1. (Short answer question, 10 points) What types of failures may occur during the operation of the database?

Correct answer:
(1) Transaction failure: Due to various reasons during the operation of the transaction, such as input data errors, operation overflow, violation of certain integrity restrictions, certain application errors, and deadlocks in parallel transactions, etc., The transaction fails to run to the normal point before being undone, this situation is called 'transaction failure'. (2) System failure: System applause refers to that during the operation of the system, due to some reasons, such as OS and DBMS code errors, operators operate transactions. Specific types of hardware errors (CPU failures), sudden power outages, etc. cause the system to stop running, causing transactions to be pointed out in an uncontrolled manner during execution. At this time. The information in the memory is lost, but the data stored on the external storage is not affected. This situation is called a 'system failure. (3) Media failure: During the operation of the system, due to some kind of hardware failure, such as disk damage, head collision, or some potential error of the OS. Instantaneous strong magnetic field interference causes partial or total loss of data stored in the external memory, which is called 'medium failure. (4) Computer virus: A computer virus is a kind of man-made failure and destruction. It is a computer program that can multiply and spread rapidly by reading and writing programs and data in a computer system infected with a virus, endangering computer systems and database.

  1. (Short answer question, 10 points) Try to describe the concept of affairs and the four characteristics of affairs.

Correct answer:
A transaction is a sequence of database operations defined by the user. These operations are either done or not done. It is an indivisible unit of work.
Transactions have four characteristics: Atomicity, Consistency, Isolation, and Durability. These four properties are also referred to as ACID properties.
Atomicity: A transaction is a logical unit of work for a database, and all operations included in a transaction are either performed or not performed.
Consistency: The result of transaction execution must be to change the database from one consistent state to another.
Isolation: The execution of a transaction cannot be interfered with by other transactions. That is, the operations and data used within a transaction are isolated from other concurrent transactions, and the concurrently executed transactions cannot interfere with each other.
Persistence: Persistence, also known as Permanence, means that once a transaction is committed, its changes to the data in the database should be permanent.

Guess you like

Origin blog.csdn.net/qq_46373141/article/details/131246650