Relations
Relations on views define how the view connects to other tables or views. They serve the same purposes as table relations — enabling automatic joins in forms, lookups, and queries, and documenting the referential structure of the data model. The key difference is that view relations are defined on a read-only object, so delete actions are not applicable.
A view relation consists of the AxViewRelation object and one or more constraints that define the join conditions. Constraints come in three types, plus a foreign-key variant of the relation itself.
Constraint Types
Field Constraint (AxViewRelationConstraintField)
Joins a field on the view to a field on the related table. This is the most common constraint type — equivalent to ViewField = RelatedTable.RelatedField.
Fixed Constraint (AxViewRelationConstraintFixed)
Constrains a field on the current view to a fixed integer value. Used when the relationship is valid only for a specific enum value or status. Equivalent to ViewField = <literal>.
Related Fixed Constraint (AxViewRelationConstraintRelatedFixed)
Constrains a field on the related table to a fixed integer value. Equivalent to RelatedTable.RelatedField = <literal>.
Foreign Key Relation (AxViewRelationForeignKey)
A specialised relation variant that references an index on the related table to define the join. Instead of listing individual field constraints, it points to the index, and the constraint fields are derived from the index key columns.
Relationship Types
The RelationshipType property classifies the nature of the connection:
| Type | Value | Description |
|---|---|---|
| NotSpecified | 0 | No classification. Avoid — always set a specific type. |
| Association | 1 | A general reference. The related table exists independently. |
| Composition | 2 | The child cannot exist without the parent. |
| Link | 3 | A navigational relationship for form linking. |
| Specialization | 4 | The current view is a specialised form of the related table. |
| Aggregation | 5 | Similar to composition but the child can logically exist independently. |
Cardinality
Two properties define the multiplicity:
- Cardinality — how many records on the view side participate.
- RelatedTableCardinality — how many records on the related table side.
Cardinality Values
| Value | Name | Meaning |
|---|---|---|
| 0 | NotSpecified | Not set. |
| 1 | ZeroOne | Zero or one record. |
| 2 | ExactlyOne | Exactly one record (mandatory). |
| 3 | ZeroMore | Zero or more records. |
| 4 | OneMore | One or more records. |
RelatedTableCardinality Values
| Value | Name | Meaning |
|---|---|---|
| 0 | NotSpecified | Not set. |
| 1 | ZeroOne | The related record may or may not exist. |
| 2 | ExactlyOne | The related record must exist. |
Properties
| Property | Display Name | Type | Description |
|---|---|---|---|
| RelationAxViewRelation | |||
| Name | Name | String | The name of the relation. |
| Tags | Tags | String | Tags for this element separated by semicolon. |
| RelatedTable | Related Table | String | Name of the related table or view. |
| RelatedTableCardinality | Related Table Cardinality | RelatedTableCardinality | Cardinality on the related table side. Values: NotSpecified (0), ZeroOne (1), ExactlyOne (2). |
| Cardinality | Cardinality | Cardinality | Cardinality on the view side. Values: NotSpecified (0), ZeroOne (1), ExactlyOne (2), ZeroMore (3), OneMore (4). |
| RelationshipType | Relationship Type | RelationshipType | Type of relationship. Values: NotSpecified (0), Association (1), Composition (2), Link (3), Specialization (4), Aggregation (5). |
| UseDefaultRoleNames | Use Default Role Names | NoYes | Whether to auto-generate role names from the table names. Values: No (0), Yes (1). |
| RelatedTableRole | Related Table Role | String | Role name for the related table in the relationship. |
| Role | Role | String | Role name for the current view in the relationship. |
| Foreign Key RelationAxViewRelationForeignKey | |||
| Index | Index | String | The index on the related table that defines the foreign key. |
| ConstraintAxViewRelationConstraint | |||
| Name | Name | String | The name of the constraint. |
| Tags | Tags | String | Tags for this element separated by semicolon. |
| Field ConstraintAxViewRelationConstraintField | |||
| Field | Field | String | Field on the current view used in the join. |
| RelatedField | Related Field | String | Field on the related table used in the join. |
| Fixed ConstraintAxViewRelationConstraintFixed | |||
| Field | Field | String | Field on the current view constrained to a fixed value. |
| Value | Value | Int32 | The fixed integer value for the constraint. |
| Related Fixed ConstraintAxViewRelationConstraintRelatedFixed | |||
| RelatedField | Related Field | String | Field on the related table constrained to a fixed value. |
| Value | Value | Int32 | The fixed integer value for the constraint. |