Chapter 4 · Part I — The application model

Connect records without losing their boundaries

A calibration names an instrument because the measurement has meaning only for that instrument. Storing instrumentId gives us a reference value. Declaring the relationship tells the application model what that value refers to and gives tools a navigable connection.

The complete example uses this fragment:

relationships:
  instrument:
    type: belongsTo
    target: Instrument
    foreignKey: instrumentId

The relationship name, target resource, and backing field have different jobs. instrument is how the connection is named in the model. Instrument is the resource at its far end. instrumentId is the local value that identifies the related record. Consistent names make these jobs easier to see; the names themselves do not establish integrity.

The example also declares an index on instrumentId for lookups by instrument. That index supports access to the relationship; it does not make the pair of instrument and revision unique. Add a separate, tested uniqueness constraint if the application requires that stronger rule.

Ask what protects the connection

A relationship may support generated navigation, schema metadata, query expansion, and reference validation. Storage constraints are another part of the story. Inspect the generated schema and exercise deletion before assuming that every relationship is backed by the same database foreign-key behavior.

Cross-domain references require particular care because their targets can live behind different ownership, loading, or storage boundaries. An address that resolves during authoring does not by itself create a distributed transaction or a database constraint across stores. ADL 12 describes the relevant forms and limits.

Our lab creates the instrument first and uses the identifier returned by the service. That order avoids a dangling reference in the successful path. It does not prove that every invalid reference or deletion is refused. Those are additional cases to add when the application’s assurance claim includes them.

Decide where ownership belongs

The owner of an instrument need not be the submitter of every calibration. A laboratory may own the instrument while many technicians use it. An inspector’s right to review a calibration is also distinct from ownership of the instrument.

Do not overload one field with all three meanings. Separate identity relationships when the rules differ. A model that uses one ownerId for inventory responsibility, edit permission, and independent review will eventually face a request for which those meanings conflict.

The handbook therefore uses the instrument relationship for subject identity and a protected submittedBy field for event provenance. The independent-review guard compares the reviewer with that submission event, not with whoever currently owns the instrument.

A suite is an authoring boundary

As an application grows, it may separate inventory, calibration, personnel, and reporting into domains within a suite. A suite organizes definitions and dependencies. A site identifies a deployment. Reusing a suite at two sites does not imply shared users, records, or trust configuration.

Start by separating domains where responsibility and change cadence justify the boundary. Splitting every resource into its own domain can make ordinary changes harder to reason about. Keeping unrelated business units in one domain can conceal authority that should be independent. The important question is which changes and permissions should travel together.

Reuse mechanisms introduce another identity: the exact definition being reused. An import name is insufficient when two environments can resolve it to different contents. Pin the package, retain the resolved artifact or digest, and record the dependencies used for validation. ADL 8 owns those authoring rules.

Design deletion as a business operation

The example declares delete: [] for instruments and calibration records. The workshop wants reviewed records to remain addressable, and the teaching application does not need a deletion flow. This is an operation permission, where an empty list denies; Chapter 6 explains why the same syntax at a field rule has different consequences.

A real instrument may be retired without being erased. A retirement state preserves the historical subject of older calibrations. If erasure is required, design the resulting references and evidence explicitly. Cascading deletion can satisfy a database constraint while destroying the records the organization intended to retain.

Workshop

Add a separate TechnicianProfile resource in a working copy. Decide whether a calibration refers to the profile, the authentication identity, or both. Explain which value should remain stable if the technician changes their display name or leaves the organization.