Page 191 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 191

Database Management Systems/Managing Database




                    Notes          or more blocks. This assumption is realistic for most data-processing applications, such as our
                                   banking example.
                                   Transactions input information from the disk to main memory, and then output the information
                                   back onto the disk. The input and output operations are done in block units. The blocks residing
                                   on the disk are referred to as physical blocks; the blocks residing temporarily in main memory
                                   are referred to as buffer blocks. The area of memory where blocks reside temporarily is called
                                   the disk buffer.

                                   Block movements  between disk  and main memory are initiated through the following  two
                                   operations:
                                   1.  input(B) transfers the physical block B to main memory.

                                   2.  output(B) transfers the buffer block B to the disk, and replaces the appropriate physical
                                       block  there.
                                   Each transaction T  has a private work area in which copies of all the data items accessed and
                                                  i
                                   updated by T  are kept. The system creates this work area when the transaction is initiated; the
                                             i
                                   system removes it when the transaction either commits or aborts. Each data item X kept in the
                                   work area of transaction T  is denoted by X . Transaction T  interacts with the database system by
                                                       i            i            i
                                   transferring data to and from its work area to the system buffer. We transfer data by these two
                                   operations:
                                   1.  read(X) assigns the value of data item X to the local variable X . It executes this operation
                                                                                          i
                                       as follows:
                                       (a)  If block B x on which X resides is not in main memory, it issues input(B x).
                                       (b)  It assigns to X  the value of X from the buffer block.
                                                        i
                                   2.  write(X) assigns the value of local variable X  to data item X in the buffer block. It executes
                                                                           i
                                       this operation as follows:
                                       (a)  If block B x on which X resides is not in main memory, it issues input(Bx)
                                       (b)  It assigns the value of X  to X in buffer B x.
                                                               i




                                     Notes  Both operations may require the transfer of a block from disk to main memory.
                                     They do not, however, specifically require the transfer of a block from main memory to
                                     disk.

                                   A buffer block is eventually written out to the disk either because the buffer manager needs the
                                   memory space for other purposes or because the database system wishes to reflect the change to
                                   B on the disk. We shall say that the database system performs a force-output of buffer B if it
                                   issues an output(B).
                                   When a transaction needs to access a data item X for the first time, it must execute read (X). The
                                   system then performs all updates to X on X . After the transaction accesses X for the final time, it
                                                                     i
                                   must execute write(X) to reflect the change to X in the database itself.
                                   The output(B x) operation for the buffer block B x on which X resides ,does not need to take effect
                                   immediately after write(X) is executed, since the block Bx may contain other data items that are
                                   still being accessed. Thus, the actual output may take place later. Notice that,  if the system
                                   crashes after the write(X) operation was executed but before output(Bx) was executed, the new
                                   value of X is never written to disk and, thus, is lost.





          184                               LOVELY PROFESSIONAL UNIVERSITY
   186   187   188   189   190   191   192   193   194   195   196