File Organization

17
FILES ORGANIZATION PRESENTED BY : KU MAN YI B031210161 MOHAMMAD SAFAR A/L SHARIFF MOHAMED B031210227 ADAM RIDHWAN BIN SUKIMAN B031210083 SOO BOON JIAN B031210199 MUHAMMAD ZULKHAIRI BIN ZAINI B031210140

description

 

Transcript of File Organization

Page 1: File Organization

FILES ORGANIZATION

PRESENTED BY :

KU MAN YI B031210161MOHAMMAD SAFAR A/L SHARIFF MOHAMED B031210227ADAM RIDHWAN BIN SUKIMAN B031210083SOO BOON JIAN B031210199MUHAMMAD ZULKHAIRI BIN ZAINI B031210140 

Page 2: File Organization

FILE ORGANIZATION

For understanding File/Table

Record/Row

Field/Column/Attribute

Page 3: File Organization

THE PILE

A form of file organization where data are collected in the same order they arrived

This organization simply accumulate mass of data and save it

Each field is self-describing, includes a field name and a value. Length of each field is determined as shown Implicitly indicated by delimiters Explicitly included as subfield or Done by default for that particular field type

Records may have different fields and there is no visible structure. Hence, record access is through exhaustive search where all record or the entire file is examined

This type of file uses space efficiently and is updated easily. However, retrieval of a single record could be tedious

Page 4: File Organization

THE PILE ORGANIZATION

Variable-length records Delimiter

Delimiter

Delimiter

Delimiter

Delimiter

Delimiter

Variable-length records

Variable-length records

Variable-length records

Variable-length records

Page 5: File Organization

THE SEQUENTIAL FILE

Most common form of file structure Fixed format are used for records and records are

of the same length Field names and lengths are attributes of the file One particular field (usually first field) is referred

to as the key field :- Uniquely identifies the record Records are stored in key sequence

Alphabetical order or numerical order depending on the key field

It is the simplest structure and easy to implement in any device. However, in the worst case scenario, accessing a single record takes a long time.

Page 6: File Organization

THE SEQUENTIAL FILE ORGANIZATION

1

2

…….

n-1

n

Key Field Attributes

Page 7: File Organization

THE SEQUENTIAL FILE ORGANIZATION

To enable a sequential form of records, new records are placed in a log file or transaction file. Then, a batch update is performed to merge the log file with the master file to produce a new file with the correct key sequence

1 2 n-1 n…

Record Terminators

Page 8: File Organization

THE INDEXED SEQUENTIAL FILE

A file management system that allows records to be accessed either sequentially (in the order they were entered) or randomly (with an index)

A secondary set of hash tables known as indexes is created that contains pointers to the main file

In indexed sequential file, records are organized in sequence based on key fields

Each file has an index to support random search

Overflow file is added such as each record in overflow file is located by following a pointer from its predecessor record in main file

Page 9: File Organization

DESCRIPTION

As an example:- Firstly, a single level of indexing is used.

Hence, the index is a simple sequential file. Each record in the index file consists of:-

Key field(same as key field in the main file) Pointer to the main file

To find a specific field, the index file is searched for matching key values

Then, the pointer indicates the record having the matching key values as depicted by figure below

This reduces the average search length

Page 10: File Organization
Page 11: File Organization

There is an addition to the organization where each record in the main file contains an additional field which is a pointer to the overflow file

When a new record is added, it is added into the overflow file. The record in main file which is immediately before the new record in a logical sequence to be inserted is updated to contain a pointer to the new record in the overflow file

However, if the record before the new record in logical sequence is itself in the overflow file, then the pointer in that record is updated

The processing of entire file sequentially involves processing of records of main files sequentially until the pointer to the overflow file is found, then accessing is continued in the overflow file until a null pointer is encountered

Secondly, we visualize the organization using multiple levels of indexes

The lowest level of index points to the main file, whereas the index files sitting on the level above points to the index file below it

Hence, the efficiency in access is greatly increased and average length of search is greatly reduced as conveyed in figure below

Page 12: File Organization
Page 13: File Organization

THE INDEXED FILE

Uses multiple indexes for different key fields which may be the subject of a search

Record accessibility are through their indexes May contain an exhaustive index that

contains one entry for every record in the main file. The index itself is organized in the sequential form for ease of searching

May contain a partial index. It contains entries to records where the desired field exists

Page 14: File Organization

THE INDEXED FILE ORGANIZATION

Primary file

Exhaustive PartialExhaustive

Index AttributesPointer

Indicator

Page 15: File Organization

THE DIRECT/HASHED FILE This file management system that access directly

any block of a known address. A key field is required for each record. Uses hashing on the key value. No concept of sequential ordering implemented. Such examples are:-

Directories Pricing table Schedules Name lists

It is used where rapid access is required, where fixed-length records are used and where records are accessed one-at-a-time.

The concept of hashing can be shown as below.

Page 16: File Organization

THE DIRECT/HASHED FILE IMPLEMENTATION

Page 17: File Organization

HASHING METHODS Direct method

The key is the address a key value might be between 1-100. The address of a certain

records will be the same as the key. Subtraction method

Subtract certain amount of numbers from the key a key value might start with 1001 and ends with 1100. A simple

hashing function could subtract 1000 from the key to determine the address.

Modulo-division method Key value is divided by the size of records. the remainder becomes the address of the key.

Digit-extraction method Selected digits are extracted from the key As an example:- a field has 10 digits. The hashing function only

extracts the first 2 digits and the last digit and use them as address.