«« ( Date ) »» // «« ( Thread ) »» // nastava - 2003

Re: evo roka iz baza

by Damjan S. Vujnovic
četvrtak, 20. februar 2003 - 01:47.

Bejah srećan i bezbrižan devetogodišnjak kada davne '87, gospoda Henry F. Korth i Abraham Silberschatz, u svom kapitalnom delu Database System Concepts (iliti "Kako Mali Perica Zamišlja Sisteme Za Upravljanje Bazama Podataka") rekoše (citat):

"The database system resides in nonvolatile storage (usually a disk). The database is partitioned into fixed-length storage units called blocks which are the unit of both storage allocation and data transfer. Programs executing the various database applications read information from the disk to main memory and then write the information out back onto the disk. The read and write operations are done in block units. The blocks residing on the disk are referred to as physical blocks, while the blocks residing temporarily in main memory are referred to as buffer blocks.
Block movements between the disk and main memory are initiated through the following two operations:
a.. input(X), which transfers the physical block in which data item X resides to main memory.
b.. output(X), which transfers the buffer block on which X resides to the disk and replaces the appropriate physical block there.
Application programs interact with the database system through the following two operations:
a.. read(X,xi), which assigns the value of data item X to the local variable xi. This operation is executed as follows:
1. If the block on which X resides is not in main memory, then issue input(X).
2. Assign to xi the value of X from the buffer block.
b.. write(X,xi), which assigns the value of local variable xi to data item X in the buffer block. This operation is executed as follows:
1. If the block on which X resides is not in main memory, then issue input(X).
2. Assign the value of xi to X in the buffer block for X.
Note that both operations may require the transfer of a block from disk to main memory. They do not, however, 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 database system wishes to reflect the change to X on the disk. We shall say that the database system force outputs the buffer block of X if it issues an output(X).
When a program needs to access a data item X for the first time, it must execute read(X,xi). All updates to X are then performed on xi. After the program accesses X for the last time, it must execute write(X,xi) in order to reflect the change to X in the database itself.
The output(X) operation need not take effect immediately after the write(X,xi) is executed, since the block on which X resides may contain other data items that are still being accessed. Thus, the actual output takes place later. Notice that if the system crashes after the write(X,xi) operation was executed but before output(X) was executed, the new value of X is never written to disk and, thus, is lost."

Prvo da usaglasimo sintaksu. Ono što naš cenjeni profesor označava sa X:=X+1 gospoda označavaju sa xi:=xi+1 (menja se samo lokalna kopija), dok je Write(X) ekvivalentno sa Write(X,xi) (upisuje se u deljenu memoriju). I sada ide ključni deo (onaj podvučeni). Gospoda kažu da je ideja cele priče da se u okviru jedne transakcije operacija Write(X,xi) može pojaviti najviše jednom (što je i logično jer nema mnogo smisla u deljenu memoriju upisivati više od jedanput). Milanu: jel' vidiš sada mane tvoje definicije "čitanje pre upisa" (vidi moj prethodni post)?

Toliko,
Damjan S. Vujnović

P.S. Izvinjavam se svima koji nemaju .html enabled browser-e.