Record (File architecture): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
<p>Each record is variable in length and need contain only the fields (some or all of those contained in the [[#Table A (File Architecture) Internal File Dictionary|Internal File Dictionary in Table A]]) that pertain to it. The limit of the number of field value pairs in a record is in the tens of millions.</p>
<p>Each record is variable in length and need contain only the fields (some or all of those contained in the [[#Table A (File Architecture) Internal File Dictionary|Internal File Dictionary in Table A]]) that pertain to it. The limit of the number of field value pairs in a record is in the tens of millions.</p>


<p>There is only a limited fixed format for data within a record (pre-allocated fields). Almost any number of fields can appear almost any number of times in almost any order. Each record is automatically assigned a unique internal record number that is used by the system to build index entries for the record.</p>  
<p>There is only a limited fixed format for data within a record (pre-allocated fields). Almost any number of fields can appear almost any number of times in almost any order. Each record is automatically assigned a unique (but temporary... it will likely change when the file is reorganized) internal record number (IRN) that is used by the system to build index entries for the record.</p>  


<p>For example, the following code:</p>
<p>For example, the following code:</p>
Line 28: Line 28:


=== the Record as a  container ===
=== the Record as a  container ===


=== <div id="Base Records">Base Records</div> ===
=== <div id="Base Records">Base Records</div> ===
<p>The base record is the first (and, often, only) part of the record. It is assigned a slot in Table B, and its internal record number is how Model 204 identifies the record for indexing peuporses as well as in record sets and lists.</p>


=== <div id="Extension Records">Extension Records</div> ===
=== <div id="Extension Records">Extension Records</div> ===
<p>When a full record is not able to fit on a particular page (either, it itself may be more than 6140 bytes, or other records on the page do not leave sufficient space for the record) one or more extension records are stored.</p>
<p>If [[Table X (File Architecture)|Table X]] is enables, all such extensions are stored there, otherwise the extension(s) are stored in Table B.</p> 




Line 75: Line 83:
==== [[Preallocated Fields (File Architecture)|Preallocated Fields]] ====
==== [[Preallocated Fields (File Architecture)|Preallocated Fields]] ====


 
<p>All records stored in a Model204 file will contain all of the preallocated fields (if any) for that file. These are stored based on the [[Table D (File Architecture)#Record Map of Preallocated Fields|Record Map of preallocated fields]] stored in Table D.</p>


==== [[Field Value Pairs (File Architecture)|Field Value Pairs]] ====
==== [[Field Value Pairs (File Architecture)|Field Value Pairs]] ====


Field Value Pairs, or, perhaps more precisely, ''Field Name 'Equals' Value Pairs'' are the most common way data is held in a Model 204 Record. (Even the Repeating Field Group structure is a set of Field Value Pairs which occur in tandem).
Field Value Pairs, or, perhaps more precisely, ''Field Name 'Equals' Value Pairs'' are the most common way data is held in a Model 204 Record. (Even the Repeating Field Group structure is a set of Field Value Pairs which occur in tandem).</p>




Line 88: Line 96:
==== Large Objects ====
==== Large Objects ====


===== [[BLOBs and CLOBs (File Architecture|Native Large Objects]] =====
<p>There are two ways that large objects (data longer than 255 bytes) may be handled in a Model 204 record.</p>
 
===== [[Table E (File Architecture)|Native Large Objects in Table E]] =====
 
<p>
 
 


===== Large Objects Without Table E =====
===== Large Objects Without Table E =====
Line 94: Line 108:
<p>If [[Table E (File Architecture)|Table E]] is not enabled, and the File Manager still wishes to store data which is more than 255 bytes long, it must be done by the application code. </p>
<p>If [[Table E (File Architecture)|Table E]] is not enabled, and the File Manager still wishes to store data which is more than 255 bytes long, it must be done by the application code. </p>


<p>The technique is to store the data as a series of repeating fields, each containing (up to) 255 bytes. The   
<p>The technique is to store the data as a series of repeating fields, each containing (up to) 255 bytes.</p>
 
<p>The application would need to parse the input data into 255 byte chunks to store it, and then again, string it together to read it.</p>
 
<p>Rocket Software recommends that, where large objects need to be stored that, for efficiency reasons, Tabel E be enables.</p>  





Revision as of 23:01, 9 May 2013

Overview

A Model 204 Record is a collection of fields (either individually; in Repeating Field Groups (RFGs); or any mixture of these) containing a set of data about a thing. Admittedly, this is a very vague description, because the flexibility of Model 204 permits the File Manager to create files whose records are best suited to the required purpose, whatever it may be.

Each record is variable in length and need contain only the fields (some or all of those contained in the Internal File Dictionary in Table A) that pertain to it. The limit of the number of field value pairs in a record is in the tens of millions.

There is only a limited fixed format for data within a record (pre-allocated fields). Almost any number of fields can appear almost any number of times in almost any order. Each record is automatically assigned a unique (but temporary... it will likely change when the file is reorganized) internal record number (IRN) that is used by the system to build index entries for the record.

For example, the following code:

IN filename STORE RECORD END STORE

Does, in fact, physically store a record. It has been assigned an Internal Record Number and would contain the pre-allocated field structure (if any), but no data.


Records. Base Records and Extension Records

The term 'record' is actually used three ways:

  • the record as a full collection of all of the data about a 'thing'
  • base records: the initial portion of that data
  • extension records: a (possible) string of additional portions of the data

These are discussed below:

the Record as a container

Base Records

The base record is the first (and, often, only) part of the record. It is assigned a slot in Table B, and its internal record number is how Model 204 identifies the record for indexing peuporses as well as in record sets and lists.

Extension Records

When a full record is not able to fit on a particular page (either, it itself may be more than 6140 bytes, or other records on the page do not leave sufficient space for the record) one or more extension records are stored.

If Table X is enables, all such extensions are stored there, otherwise the extension(s) are stored in Table B.


The Internal Record Number (IRN)

The internal record number (IRN) is the base record number (or slot) assigned when the record is first stored. While, once assigned, it can be passed around inside a program as an easy way to refer back to the set of data (see the FOR RECORD NUMBER statement) it is not a permanent identifier: when the file is reorganized the position where a record is reloaded may be quite different than where it was before.

The IRN (represented by a single bit) is used as a target for Model 204 indexing (both hashed and B-tree indexing). See Bit Maps for more information.


The Structure of a Model 204 Record

As shown in Table B, Model 204 records grow from the end toward the beginning of the page it is stored upon. So, a proper representation of the record shows it as:



In any discussion of the record, the 'beginning' of the record is to the left, and the growth (represented by the blue arrow) is toward the right.


Extension Pointer

Every 'portion' of every Model 204 record (base or one of perhaps many extensions) begins with an extension record pointer.

For files without a Table X, this pointer is 3 bytes in length.

For files with Table X enables, this pointer is 4 bytes in length (to handle the larger number of slots in Table X).

Regardless of the length, this pointer links this portion of the record to its next portion. Where that location is, of course, dependent on whether Table X is enabled.


Data

If there are any preallocated fields in a file (see the OCCURS attribute) every record in that file will begin with the set of such fields, immediately after the extension pointer. The structure of the fields is held in the Record Map in Table D.

Note: For the Sort or Hash key (for such files), if it is preallocated (and it should be unless it is wildly variable in size) it will be the first field in the record map. If it is not preallocated, it will be the first 'field value pair' in the record.

After the preallocated fields, is the rest of the data; a series of: field value pairs; repeating field groups; and / or pointers to large objects. These will be physically positioned in: either the order they were ADDed (which always adds the entity at the end of the record); or positioned by an INSERT statement. Hence, the application code controls the relative order of the data in the record, once past the preallocated fields.

Each of the four is briefly described below, but refer to the specific topic for each for further detail:

Preallocated Fields

All records stored in a Model204 file will contain all of the preallocated fields (if any) for that file. These are stored based on the Record Map of preallocated fields stored in Table D.

Field Value Pairs

Field Value Pairs, or, perhaps more precisely, Field Name 'Equals' Value Pairs are the most common way data is held in a Model 204 Record. (Even the Repeating Field Group structure is a set of Field Value Pairs which occur in tandem).



Repeating Field Groups

Large Objects

There are two ways that large objects (data longer than 255 bytes) may be handled in a Model 204 record.

Native Large Objects in Table E

Large Objects Without Table E

If Table E is not enabled, and the File Manager still wishes to store data which is more than 255 bytes long, it must be done by the application code.

The technique is to store the data as a series of repeating fields, each containing (up to) 255 bytes.

The application would need to parse the input data into 255 byte chunks to store it, and then again, string it together to read it.

Rocket Software recommends that, where large objects need to be stored that, for efficiency reasons, Tabel E be enables.