13.07.2015 Views

13.1 through 13.5, 13.10 and 13.11

13.1 through 13.5, 13.10 and 13.11

13.1 through 13.5, 13.10 and 13.11

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13 Disk Storage, Basic File Structures, <strong>and</strong> HashingConsider an EMPLOYEE tile with fields Name, Ssn, Salary, Job_code, <strong>and</strong> Department.A simple selection condition may involve an equality comparison on some t-ieldvalue-fbr example, (Ssn = '123456789') or (Department = 'Reserrrch'). More complexconditions can involve other types of comparison operators, such as I e1 ); anexample is (Salary > 30000). The general case is to h:rve an arbitrary Boolean expressionon the flelds of the tlle as the selection conditiorl.Search operations on files are generally based on simple selection conditions. Acomplex condition must be decomposed by the DBMS (or the programmer) toextract a simple condition that can be used to locate the recorcls on disk. EachIocated record is then checked to deterrnine whether it satisfies the full selectioncondition. For exanrple, we may extract the simple condition (Department ='Research') from the complex condition ((Salary > 30000) AND (Department ='Research')); each record satisSzing (Department ='Research') is located <strong>and</strong> ther-rtested to see if it also satisfies (Salary > 30000).When several file records satisfy a search condition, the/irst record-with respectothe phvsical sequence of file records-is initially located <strong>and</strong> desigrrated the currentrecord. Subsequent search operations commence from this record <strong>and</strong> locate thenext record in the fiie that satisfies the condition.Actual oprerertions for locirting <strong>and</strong> accessing file records vary from s,vstem to systeln.Below, \ ,e present a set of representative operations. Typically, high-level progritms,such as DBMS software programs, trccess records by using these comm<strong>and</strong>s, so wesometimes refer to program variables in the following descriptions:,;, Open. Prepares the file for reading or writing. Allocates apprropriate buff-ers(typicaiiy at least two) to hold t-ile blocks fiom disk, <strong>and</strong> retrieves the fileheader. Sets the file pointer to the beginning of the file.r! [sss[. Sets the file pointer of an open file to the beginning of the file.,,l, Fi.d (or Locate). Searches for the first record that satisfies a search conclition.Transfers tl-re block containing that record into a main mernory buf'fer(if it is not alreirdy there). The file pointer points to the record in the bufferar"rd it becomes Ihe current record. Sometirr-res, different verbs are usecJ toindicate whether the located record is to be retrieved or updated.!,:, Read (or Get). Copies the current record from the buffer to a Program vilriablein the useL program. This comnr<strong>and</strong> r.nay also trdvance the currentrecord pointer to the next record in the frle, which n-ray necessitate readingti-re next file block from disk.',,' FindNext. Searches for the next record in the file that satisfies the searchcondition. Transf-ers the block containing thart record into zr rttain memor!'buffer (if it is not alread,v tl-rere). The record is located in the buff'er;rndbc'comes the current record.,, Delete. Deletes the current record <strong>and</strong> (eventually) update's the file on diskto reflect the deletion.Modify. Modifies some field vzrlues for the current record <strong>and</strong> (eventr.rally)updates the f-ile on disk to ref'lecthe modification.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!