Field group design: Difference between revisions
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
==Overview== | ==Overview== | ||
<p> | <p> | ||
<var class="product">Model 204</var> supports non-relational, de-normalized data structures. Many <var class="product">Model 204</var> sites have enjoyed significant cost and performance benefits from efficiently processing multiply occurring fields. This concept has been enhanced to introduce physical field groups | <var class="product">Model 204</var> supports non-relational, de-normalized data structures. Many <var class="product">Model 204</var> sites have enjoyed significant cost and performance benefits from efficiently processing multiply occurring fields. This concept has been enhanced to introduce <b>physical field groups</b>, which let you view and process a group of fields as a single logical entity.</p> | ||
This feature is available | This feature is available as of Model 204 version 7.5. | ||
===Traditional approaches to multiply occurring fields=== | ===Traditional approaches to multiply occurring fields=== | ||
Line 30: | Line 30: | ||
:POSTAL_CODE | :POSTAL_CODE | ||
However, if you add historical data (the customer might move during his lifetime, and you may want to track this history), maintaining these sets of fields becomes problematic. And as the records grow, there might also be performance issues: although the application treats them as a group, it still must update and retrieve the fields individually. | However, if you add historical data (the customer might move during his lifetime, and you may want to track this history), maintaining these sets of fields becomes problematic. And as the records grow, there might also be performance issues: although the application treats them as a logical group, it still must update and retrieve the fields individually. | ||
===Field group approach to multiply occurring fields=== | ===Field group approach to multiply occurring fields=== | ||
Line 53: | Line 53: | ||
<b>Syntax</b> | <b>Syntax</b> | ||
<p> | <p> | ||
The | The <var>[[DEFINE FIELDGROUP command|DEFINE FIELDGROUP]]</var> command is used to define a field group:</p> | ||
<p class="syntax">DEFINE FIELDGROUP <span class="term">fieldGroupName</span> | <p class="syntax">DEFINE FIELDGROUP <span class="term">fieldGroupName</span> | ||
</p> | </p> | ||
<p> | <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 | 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#Field naming|fields]]. </p> | ||
==Defining a field inside a field group== | ==Defining a field inside a field group== | ||
Line 77: | Line 77: | ||
<li><var class="term">attribute1 attribute2 </var>... specifies other field attributes. | <li><var class="term">attribute1 attribute2 </var>... specifies other field attributes. | ||
<p> | <p> | ||
Of the [[Field design#AT-MOST-ONE, REPEATABLE, and EXACTLY-ONE attributes|occurrence attributes]] (<var>AT-MOST-ONE</var>, <var>EXACTLY-ONE</var>, and <var>REPEATABLE</var>), <var>EXACTLY-ONE</var> is the default for a field defined within a field group. </p> | |||
<p class="note"><b>Note:</b> The <var>OCCURS</var> attribute may not be specified for a | <p class="note"><b>Note:</b> The <var>OCCURS</var> attribute may not be specified for a | ||
field group field. </p></li> | field group field. </p></li> | ||
Line 170: | Line 170: | ||
<li>[[Field group (File architecture)]]</li> | <li>[[Field group (File architecture)]]</li> | ||
<li>[[ | <li>[[Processing multiply occurring fields and field groups]] </li> | ||
<li>[[Data_maintenance#Updating_field_groups|Updating field groups]]</li> | |||
</ul> | </ul> | ||
[[Category: | [[Category:Model 204 files]] |
Latest revision as of 18:22, 15 February 2019
Overview
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 physical field groups, which let you view and process a group of fields as a single logical entity.
This feature is available as of Model 204 version 7.5.
Traditional approaches to multiply occurring fields
Consider the following approaches to the same data. A customer might have a number of different addresses (for example, home and postal) with the same data (house number, street, city, state, and postal code) for each.
You might define these 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, by identifying an address type for each address, you might define the following fields, and have your application code maintain the occurrences of the repeatable fields as sets:
- ADDRESS_TYPE
- HOUSE_NUMBER
- STREET
- CITY
- STATE
- POSTAL_CODE
However, if you add historical data (the customer might move during his lifetime, and you may want to track this history), maintaining these sets of fields becomes problematic. And as the records grow, there might also be performance issues: although the application treats them as a logical group, it still must update and retrieve the fields individually.
Field group approach to multiply occurring fields
As of Model 204 version 7.5, there is a third approach to multiply occurring fields: you can define these fields as part of a field group. This option natively treats the fields as a single entity for retrieving and updating.
The effect of this is that you can define a Model 204 record as a container for different relational tables, with the advantages of having them pre-joined (in the one physical record) and being able to maintain them in whatever relative order the application requires.
Note: This option is only available by setting the FILEORG parameter to X'100'
.
This enhancement changes both the file DDL (as follows) and the SOUL 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) is 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.
Syntax
The DEFINE FIELDGROUP command is used to define a field group:
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:
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.FG is a synonym for FIELDGROUP.
If fieldGroupName is indicated with an asterisk (*), the field is included in all field groups defined for this file.
- attribute1 attribute2 ... specifies other field attributes.
Of the occurrence attributes (AT-MOST-ONE, EXACTLY-ONE, and REPEATABLE), EXACTLY-ONE is the default for a field defined within a field group.
Note: The OCCURS attribute may not be specified for a field group field.
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 FG 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.
FIELDGROUP (FG) attribute
The FIELDGROUP attribute specifies the name of the field group with which a defined field is associated (contained in). For example, DEFINE FIELD MEMBER WITH FG INNER
. 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.
Other attributes to consider
The default attribute for frequency of occurrence for fields in a field group is EXACTLY-ONE (instead of REPEATABLE, the default for individually defined fields). The options REPEATABLE and AT-MOST-ONE can also be used.
Because field groups contain sets of data, the Default Value (DV), Store Default (SD), and Store Null (SN) settings can overcome (for field types other than REPEATABLE) the added space overhead described above.
Displaying field group definitions
Field groups can be displayed in alphabetical order as follows:
IN POLICIES DISPLAY FIELDGROUP ALL
This command produces output like the following:
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
This command produces output like the following:
*** 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)