Friday, October 16, 2009

Record; Record Structures, Representation in Memory and Record with Variable Lengths

Record: A record is typically is used when a data file is organized into a table structure. In such organization of data, a record belongs to a hierarchy of fields, records and files. We can define record as a structured data type made up of a finite collection of not necessarily homogenous (of same type) but related data elements. The related data elements bound together in a record structure are called fields or attributes. A file is a collection of similar records. Each data item itself may be a group item composed of sub items; those items which are indecomposable are called elementary items or atoms. Fields in a record are named and used as identifiers.

Record and array structures have some similar and some different properties as described below.

Similarities are:

a) Like arrays, records are accessed directly through the use of field selectors, also called identifiers. In case of arrays, an element is accessed by an index number.

b) A record, like an array, occupies a consecutive block of cells in memory. The record’s accessing function calculates the location or address from a named field selector, called identifier.

A record differs from a linear array in the following ways:

a) A record may be a collection of non-homogenous data i.e; the data items in a record may have different data types. In case of arrays, data elements are homogenous.

b) The data items in a record are indexed by attribute names, so there may not be a natural ordering of its elements. In arrays, data items are in natural order as they are sequenced by indices.

Uses of Record Structure :

1. Records are useful for modeling objects that have a number of characteristics. The record data type allows to collect various types of data about an object and to refer to the whole object by a single name. Different attributes or fields are also referred by name.

2. Records are also useful for defining other data structures, allowing programmers to combine information describing characteristics of the structure with the storage of the elements.

Note: Data files comprising of records and fields as hierarchical components are usually organized on randomized or hashed tables. These tables are implemented in arrays. In this sense, every data element of an array is a record defined as C/C++ structure.

No comments:

Post a Comment