【正文】
.NET程序設(shè)計(jì).北京:清華大學(xué),北方交通大學(xué)出版社,2004:P6859[3] 王昊亮、李剛等.Visual C程序設(shè)計(jì)教程.北京:清華大學(xué)出版社,2003:P4325[4] 張海藩.軟件工程導(dǎo)論.第四版.北京:清華大學(xué)出版社,2004:P 6592[5] Inmon W.?dāng)?shù)據(jù)庫(kù)管理.第二版.北京:電子工業(yè)出版社,2000:P 6610[6] Imhoff C.?dāng)?shù)據(jù)庫(kù)設(shè)計(jì).第四版.北京:機(jī)械工業(yè)出版社,2004:P 171197附錄 附錄清單AData ManagementWhy Data Management? We have already considered hardware and software in some detail. In this chapter, we turn our attention to a third basic puter resource, Data. Many puter applications require that data be stored for subsequent processing. Simply storing the data is not enough, however. A typical puter system, even a small one, can have dozens of disks and tapes, each holding data for dozens of different applications. For any given application, one and only one set of data will do. We must be able to store, locate, and retrieve the specific data needed by a given program. That is the concern of data management.Accessing DataImagine a single diskette containing several programs. For a particular application, only one of those programs will do. How is a given program selected, loaded, and executed? In chapter 6, we learned that the operating system, responding to a user39。s index, searches it for the requested program name, extracts the program39。 we must be able to distinguish the individual data elements, too.Data Structures The key to retrieving data is remembering where they are stored. If the data elements are stored according to a consistent and well understood structure, it is possible to retrieve them by remembering that structure. The simplest data structure is a list. For example, data for a program that putes an average might be stored as a series of numbers separated by mas . The mas distinguish the individual data elements. Most programming languages support a more plex data structure called an array . Each array element can hold one data value. Each element is assigned a unique identifying number of numbers, and individual data elements can be inserted, extracted, or manipulated by referencing those an array has been filled, it can be written to disk, tape, or any other secondary medium, and later read back into memory for processing. Consider a program that generates name and address labels. For each label, we need a name, a street address, a city, a state, and a zip code. If we needed only a few labels we might store the data in a list, but separating the elements would soon bee tedious. An option is to set up an array of names and addresses, with each row holding the data for a single label. The only problem is that the entire array must be in main memory before the individual elements can be accessed, and main memory space is limited. even with an array, we could generate relatively few labels. A better solution is to organize the data as a file . All puter data begin as patterns of bits. On a file, the bits are grouped to form characters. Groups of characters, in turn, form meaningful data elements called fields. A group of related fields is a record。s name is a field. Each record holds a plete set of data for a single individual (a name, a street address, and so on). The file consists of all the records. The data in a file are processed record by record. Normally, the file is stored on a secondary medium such as disk. Programs are written to read a record, process its fields, generate the appropriate output, and then read and process another record. Because only one record is in main memory at a time, very little memory is needed. Because many records can be stored on a single disk, a great deal of data can be processed in this limited space. Locating Files Imagine a file stored on disk. The first step in accessing its data is finding the rile. The task is much like finding a program, but there are differences. Following a mand such as LOAD or RUN, programs are loaded by the operating system. Data, on the other hand, are processed by application programs, in the context of a program39。 the open logic reads the disk index, searches it by name, and finds the address of the first record in the file. Locating Records Once a file has been located, the process of accessing its records can begin. When a program needs input data, it reads a record。s examine the data accessing process more closely. A programmer views data logically, requesting the next record, or the name and address for a particular customer. The data are stored on a secondary medium such as disk. To access a record physically, the disk drive must be given a set of primitive mands: seeks, reads, and writes. The programmer thinks in terms of logical I/O. The external device stores and retrieves physical sectors。s logical requests to the appropriate physical mands. On small puters, much of the logic is found in the operation system39。 on larger machines, access methods are used. Increasingly, the programmer39。s position relative to the first record in the file. The file39。 its second record is at start of file plus 1, and do on. Now, store the records on disk 。ll store one per sector. Number the sectors relative to the start of the file0,1,2, and so on. Note that the relative record number, a logical concept, and the relative sector number, it is possible to pute a relative sector number. Give a relative sector number it is possible to pute a physical address on disk. Assume a file begins at track 30, sector 0, and that one logical record s stored in each sector. As Fig. shows, relative record 0 is stored at track 30, sector0。 and so on. Where is relative record 10? It must be stored at track 30, sector 10. In our example, the relative record number indicates how many sectors away from the beginning of the file the record is stored. Thus, we can pute the physical location of any record by adding its relative record number to the startoffile address (which, remember, was extracted from the disk39。t discuss the details, in either case it is still possible to develop a simple algorithm to pute a recor