Field group design: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
 
<div class="toclimit-3">__TOC __</div>
<p><var class="product">Model&nbsp;204</var> supports non-relational, de-normalized data structures. Many <var class="product">Model&nbsp;204</var> sites have enjoyed significant cost and performance benefits from efficiently processing multiply occurring fields. This concept has been enhanced to introduce repeated field groups that let you view and process groups of fields as a logical entity.</p>
<p><var class="product">Model&nbsp;204</var> supports non-relational, de-normalized data structures. Many <var class="product">Model&nbsp;204</var> sites have enjoyed significant cost and performance benefits from efficiently processing multiply occurring fields. This concept has been enhanced to introduce repeated field groups that let you view and process groups of fields as a logical entity.</p>


Line 32: Line 32:
As of Model 204 V7R5, there is a third option, you can define these fields as part of a [[Repeating Field Group (File Architecture)|Repeating Field Group]] (RFG). This option natively treats the fields as a single entity for retrieving and updating.
As of Model 204 V7R5, there is a third option, you can define these fields as part of a [[Repeating Field Group (File Architecture)|Repeating Field Group]] (RFG). This option natively treats the fields as a single entity for retrieving and updating.


This option is only available by setting [[FILEORG parameter|FILEORG]] = X'100'
This option is only available by setting the <var>[[FILEORG parameter|FILEORG]]</var> parameter to <code>X'100'</code>.


This enhancement changes both the file DDL (as follows) and the User Language DML.
This enhancement changes both the file DDL (as follows) and the User Language DML.
Line 40: Line 40:
<p>Every record in a FILEORG=X'100' file contains the 4-byte highest allocated field group ID. Every occurrence of a field group has a unique binary ID that occupies from two to five bytes, thus supporting up to four gigabytes of field group IDs.  
<p>Every record in a FILEORG=X'100' file contains the 4-byte highest allocated field group ID. Every occurrence of a field group has a unique binary ID that occupies from two to five bytes, thus supporting up to four gigabytes of field group IDs.  


As is true of all [[FILEORG parameter|FILEORG]] = X'100' files, the field name representation (as held in [[Table A (File Architecture)|Table A]] and thus in the record, are three bytes in length. Depending on the definitions of the fields within the group, this may be offset by the physical absence of fields defined as part of the group.</p>
As is true of all FILEORG=X'100' files, the field name representation (as held in [[Table A (File Architecture)|Table A]] and thus in the record, are three bytes in length. Depending on the definitions of the fields within the group, this may be offset by the physical absence of fields defined as part of the group.</p>


==Defining a field group ==
==Defining a field group ==
<p>You must define a field group before you define the fields that it contains. As you define them, keep track of the names you assign, because both field groups and fields are stored in Table A of the <var class="product">Model&nbsp;204</var> file, so each name must be unique. </p>
<p>You must define a field group before you define the fields that it contains. As you define them, keep track of the names you assign, because both field groups and fields are stored in Table A of the <var class="product">Model&nbsp;204</var> file, so each name must be unique. </p>
<p>The following syntax is used to define a field group.</p>
<p>The following syntax is used to define a field group:</p>
<b>Syntax</b>
<h4>Syntax</h4>
<p class="code">[[DEFINE FIELDGROUP command|DEFINE FIELDGROUP]] FieldGroupName
<p class="syntax">DEFINE FIELDGROUP <span class="term">fieldGroupName</span>
</p>
</p>
<p>Where FieldGroupName specifies the name of the field group you are defining. The rules for the FieldGroupName are the same as for [[Field Design (File Management)#Field Naming|fields]].
<p>Where <var class="term">fieldGroupName</var> specifies the name of the field group you are defining. The rules for the field group name are the same as for [[Field Design (File Management)#Field Naming|fields]]. </p>


== Defining a field inside a field group ==
== Defining a field inside a field group ==
<p>Use the following syntax to define the field(s) for a field group.</p>
<p>Use the following syntax to define the field(s) for a field group:</p>
<b>Syntax</b>
<b>Syntax</b>
<p class="code">DEFINE FIELD FieldName
<p class="syntax">DEFINE FIELD <span class="term">fieldName</span>
 
   WITH FIELDGROUP fieldGroupName [AND
   WITH FIELDGROUP FieldGroupName [AND
   [(<span class="term">attribute1 attribute2</span> ...)]]
 
   [(attribute1 attribute2 ...)]]
</p>
</p>
<p>Where:</p>
<p>Where:</p>
<ul>
<ul>
<li>FieldName specifies a unique name for a field.</li>
<li><var class="term">fieldName</var> specifies a unique name for a field.</li>
<li>The WITH FIELDGROUP FieldGroupName clause identifies the containing field group. When FieldGroupName is indicated as an asterisk (*), it means that the field is included into all field groups defined for this file.</li>
<li>The <code>WITH FIELDGROUP fieldGroupName</code> clause identifies the containing field group. When <var class="term">fieldGroupName</var> is indicated as an asterisk (*), it means that the field is included into all field groups defined for this file.</li>
<li>Attribute1 attribute2... specifies other field attributes.</li>
<li><var class="term">attribute1 attribute2 </var>... specifies other field attributes.</li>
</ul>
</ul>
<b>Example</b>
<b>Example</b>
<p>To define a field group MAKEMODEL with fields MAKE and MODEL in it, you would write the following definition.</p>
<p>
To define a field group <code>MAKEMODEL</code> with fields <code>MAKE</code> and <code>MODEL</code> in it, you would write the following definition:</p>
<p class="code">DEFINE FIELDGROUP MAKEMODEL
<p class="code">DEFINE FIELDGROUP MAKEMODEL
DEFINE FIELD MAKE WITH FIELDGROUP MAKEMODEL AND ORDERED - CHARACTER
DEFINE FIELD MAKE WITH FIELDGROUP MAKEMODEL AND ORDERED CHARACTER
DEFINE FIELD MODEL WITH FIELDGROUP MAKEMODEL
DEFINE FIELD MODEL WITH FIELDGROUP MAKEMODEL
</p>
</p>
Line 75: Line 74:
<p class="code">DEFINE FIELD MPG WITH FIELDGROUP MAKEMODEL
<p class="code">DEFINE FIELD MPG WITH FIELDGROUP MAKEMODEL
</p>
</p>
<p>The keyword AND on field definitions means that a field group name can contain blanks, just like a field name. You must use the AND keyword to separate the field group name from subsequent attributes:</p>
<p>The keyword <var>AND</var> on field definitions means that a field group name can contain blanks, just like a field name. You must use the <var>AND</var> keyword to separate the field group name from subsequent attributes:</p>
<p class="code">DEFINE FIELD COLOR WITH FIELDGROUP MAKEMODEL AND ORDERED - CHARACTER
<p class="code">DEFINE FIELD COLOR WITH FIELDGROUP MAKEMODEL AND ORDERED CHARACTER
</p>
</p>
<p>The AND is unnecessary, if the FIELDGROUP FieldGroupName clause is the last field attribute:</p>
<p>The <var>AND</var> is unnecessary, if the <code>FIELDGROUP fieldGroupName</code> clause is the last field attribute:</p>
<p class="code">DEFINE FIELD COLOR WITH ORDERED CHARACTER FIELDGROUP -
<p class="code">DEFINE FIELD COLOR WITH ORDERED CHARACTER FIELDGROUP MAKEMODEL
MAKEMODEL
</p>
</p>
<p class="note"><b>Note:</b> The MAKEMODEL field group must be defined before defining the field(s) and/or field group(s) that belong with it.</p>
<p class="note"><b>Note:</b> The <code>MAKEMODEL</code> field group must be defined before defining the field(s) and/or field group(s) that belong with it.</p>
<p>The default attribute for frequency of occurrence for fields in a field group is EXACTLY-ONE, whereas the default for individually defined fields is REPEATABLE. Of course, you can declare a field inside a field group as REPEATABLE, as well as AT-MOST-ONE.</p>
<p>The default attribute for frequency of occurrence for fields in a field group is <var>EXACTLY-ONE</var>, whereas the default for individually defined fields is <var>REPEATABLE</var>. Of course, you can declare a field inside a field group as <var>REPEATABLE</var>, as well as <var>AT-MOST-ONE</var>.</p>
 
==FIELDGROUP (FG) attribute==
==FIELDGROUP (FG) attribute==
<p>The FIELDGROUP attribute specifies the name of the field group that the defined field is associated with (contained in). Once you define a FIELDGROUP value for a field, you cannot redefine the FIELDGROUP value.</p>
<p>The <var>FIELDGROUP</var> attribute specifies the name of the field group that the defined field is associated with (contained in). Once you define a <var>FIELDGROUP</var> value for a field, you cannot redefine the <var>FIELDGROUP</var> value.</p>
<b>Syntax</b>
<b>Syntax</b>
<p class="code">FIELDGROUP [fieldgroupname | *]
<p class="syntax">FIELDGROUP [fieldgroupname | *]
</p>
</p>
<p>The FIELDGROUP attribute does not allow:</p>
<p>The <var>FIELDGROUP</var> attribute does not allow:</p>
<ul>
<ul>
<li>Record security</li>
<li>Record security</li>
<li>Use for SORT or HASH file</li>
<li>Use for <var>SORT</var> or <var>HASH</var> file</li>
<li>1NF file model</li>
<li><var>1NF</var> file model</li>
</ul>
</ul>
<p>The FIELDGROUP attribute can be used with the STORE-NULL LITERAL attribute.</p>
<p>The <var>FIELDGROUP</var> attribute can be used with the <var>STORE-NULL LITERAL</var> attribute.</p>
<b>Using FIELDGROUP*</b>
<b>Using FIELDGROUP*</b>
<p>The FIELDGROUP * attribute means that the field will be included into all field groups.</p>
<p>The <var>FIELDGROUP *</var> attribute means that the field will be included into all field groups.</p>
<p>The EXACTLY-ONE attribute conflicts with the FIELDGROUP * attribute.</p>
<p>The <var>EXACTLY-ONE</var> attribute conflicts with the <var>FIELDGROUP *</var> attribute.</p>
 
==Displaying field group definitions ==
==Displaying field group definitions ==
<p>Field groups may be displayed in alphabetical order as follows:</p>
<p>Field groups may be displayed in alphabetical order as follows:</p>
Line 109: Line 109:
   ()
   ()
</p>
</p>
<p>Because the "container group" must be specified before its members, the previous command's output cannot be fed back into <var class="product">Model&nbsp;204</var> to define the field groups in an empty file. Instead, use the DDL option with the display command:</p>
<p>
Because the "container group" must be specified before its members, the previous command's output cannot be fed back into <var class="product">Model&nbsp;204</var> to define the field groups in an empty file. Instead, use the <var>DDL</var> option with the display command:</p>
<p class="code">IN POLICIES D FIELDGROUP (DDL) ALL
<p class="code">IN POLICIES D FIELDGROUP (DDL) ALL
<b></b>*** DDL FOR FILE POLICIES
<b></b>*** DDL FOR FILE POLICIES

Revision as of 15:49, 25 March 2013

__TOC __

Model 204 supports non-relational, de-normalized data structures. Many Model 204 sites have enjoyed significant cost and performance benefits from efficiently processing multiply occurring fields. This concept has been enhanced to introduce repeated field groups that let you view and process groups of fields as a logical entity.

Take the following approaches to the same data. A customer may have a number of different addresses (for example: home and postal); with the same data: house number; street; city; state; country; and postal code for each.

So, you could define the following fields:

HOME_HOUSE_NUMBER
HOME_STREET
HOME_CITY
HOME_STATE
HOME_POSTAL_CODE
POST_HOUSE_NUMBER
POST_STREET
POST_CITY
POST_STATE
POST_POSTAL_CODE

Or you could define the following fields

ADDRESS_TYPE
HOUSE_NUMBER
STREET
CITY
STATE
POSTAL_CODE

and have your application code maintain the occurrences of the repeatable fields so that they could be read as sets. Add historical data to this (as the customer might move during his lifetime, you may want to track this history) maintaining these sets becomes problematic.

As the records grow, there may also be performance issues as, although the application treats them as a group, it still must update and retrieve the fields individually.

As of Model 204 V7R5, there is a third option, you can define these fields as part of a Repeating Field Group (RFG). This option natively treats the fields as a single entity for retrieving and updating.

This option is only available by setting the FILEORG parameter to X'100'.

This enhancement changes both the file DDL (as follows) and the User Language DML.


Field groups and Table B storage considerations

Every record in a FILEORG=X'100' file contains the 4-byte highest allocated field group ID. Every occurrence of a field group has a unique binary ID that occupies from two to five bytes, thus supporting up to four gigabytes of field group IDs. As is true of all FILEORG=X'100' files, the field name representation (as held in Table A and thus in the record, are three bytes in length. Depending on the definitions of the fields within the group, this may be offset by the physical absence of fields defined as part of the group.

Defining a field group

You must define a field group before you define the fields that it contains. As you define them, keep track of the names you assign, because both field groups and fields are stored in Table A of the Model 204 file, so each name must be unique.

The following syntax is used to define a field group:

Syntax

DEFINE FIELDGROUP fieldGroupName

Where fieldGroupName specifies the name of the field group you are defining. The rules for the field group name are the same as for fields.

Defining a field inside a field group

Use the following syntax to define the field(s) for a field group:

Syntax

DEFINE FIELD fieldName WITH FIELDGROUP fieldGroupName [AND [(attribute1 attribute2 ...)]]

Where:

  • fieldName specifies a unique name for a field.
  • The WITH FIELDGROUP fieldGroupName clause identifies the containing field group. When fieldGroupName is indicated as an asterisk (*), it means that the field is included into all field groups defined for this file.
  • attribute1 attribute2 ... specifies other field attributes.

Example

To define a field group MAKEMODEL with fields MAKE and MODEL in it, you would write the following definition:

DEFINE FIELDGROUP MAKEMODEL DEFINE FIELD MAKE WITH FIELDGROUP MAKEMODEL AND ORDERED CHARACTER DEFINE FIELD MODEL WITH FIELDGROUP MAKEMODEL

Usage

Defining fields after defining the containing field group makes it possible to later add fields to an already defined field group, for example:

DEFINE FIELD MPG WITH FIELDGROUP MAKEMODEL

The keyword AND on field definitions means that a field group name can contain blanks, just like a field name. You must use the AND keyword to separate the field group name from subsequent attributes:

DEFINE FIELD COLOR WITH FIELDGROUP MAKEMODEL AND ORDERED CHARACTER

The AND is unnecessary, if the FIELDGROUP fieldGroupName clause is the last field attribute:

DEFINE FIELD COLOR WITH ORDERED CHARACTER FIELDGROUP MAKEMODEL

Note: The MAKEMODEL field group must be defined before defining the field(s) and/or field group(s) that belong with it.

The default attribute for frequency of occurrence for fields in a field group is EXACTLY-ONE, whereas the default for individually defined fields is REPEATABLE. Of course, you can declare a field inside a field group as REPEATABLE, as well as AT-MOST-ONE.

FIELDGROUP (FG) attribute

The FIELDGROUP attribute specifies the name of the field group that the defined field is associated with (contained in). Once you define a FIELDGROUP value for a field, you cannot redefine the FIELDGROUP value.

Syntax

FIELDGROUP [fieldgroupname | *]

The FIELDGROUP attribute does not allow:

  • Record security
  • Use for SORT or HASH file
  • 1NF file model

The FIELDGROUP attribute can be used with the STORE-NULL LITERAL attribute.

Using FIELDGROUP*

The FIELDGROUP * attribute means that the field will be included into all field groups.

The EXACTLY-ONE attribute conflicts with the FIELDGROUP * attribute.

Displaying field group definitions

Field groups may be displayed in alphabetical order as follows:

IN POLICIES DISPLAY FIELDGROUP ALL CLAIM (FIELDGROUP VEHICLE) DRIVER () VEHICLE ()

Because the "container group" must be specified before its members, the previous command's output cannot be fed back into Model 204 to define the field groups in an empty file. Instead, use the DDL option with the display command:

IN POLICIES D FIELDGROUP (DDL) ALL *** DDL FOR FILE POLICIES *** DDL REQUEST DATE/TIME: 10.102 APR 12 12.34.01 DEFINE FIELDGROUP DRIVER - () DEFINE FIELDGROUP VEHICLE - () DEFINE FIELDGROUP CLAIM - (FIELDGROUP VEHICLE)