Skip to main content

ADR-004 - Bidirectional Strategy for Asset Relationships

  • Status: Accepted
  • Decision Date: 2026-03-24
  • Deciders: PIES Design Team
  • Category: Ontology, Data Model

Context​

PIES must represent relationships between assets and records in ways that serve different business and technical query patterns. Some use cases benefit from viewing assets grouped together, while others require explicit pairwise linkages between records. Without a unified strategy, the data model risks either redundancy or inflexibility, making it difficult to query relationships efficiently from multiple perspectives.

Decision​

Support both Group First and Linkage First strategies within the data model using isometric and bijective design. This allows multiple compatible and lossless representations of the same relationships, where one view can be mathematically derived from the other without data loss.

Rationale​

Dual representation eliminates the false choice between grouping and linking as the primary storage mechanism. By designing the representations as isometric (structurally equivalent) and bijective (invertible), we ensure that either representation can serve as the canonical source while database views or recursive CTEs provide efficient access to the alternative view. This approach reduces data duplication, preserves query flexibility, and maintains a single source of truth.

Assumptions​

  • Database views or recursive CTEs can efficiently translate between Group and Linkage representations.
  • Query patterns will benefit from having multiple valid entry points into relationship data.
  • Maintaining mathematical equivalence between representations is feasible within the chosen database technology.

Options Considered​

  • Group First only: All relationships stored as groups. Linkage queries require exploding the group set.
    • Rejected due to inefficiency for pairwise relationship queries.
  • Linkage First only: All relationships stored as pairwise linkages.
    • Group queries require aggregation and can become complex. Rejected due to inefficiency for group-based queries.
  • Dual representation with isometric design (chosen): Support both via views and CTEs.
    • Maintains flexibility while reducing redundancy through mathematical equivalence between representations.

Consequences​

Positive​

  • Supports multiple valid query patterns without forcing clients into a single perspective.
  • Single canonical source of truth eliminates data synchronization risk.
  • View-based translation keeps storage efficient while maintaining logical equivalence.

Negative​

  • Database schema and query logic become more complex.
  • Requires careful design of views or CTEs to ensure they remain efficient at scale.
  • Developers must understand the relationship between Group and Linkage representations.

References​

  • Related discussion: PADS-646 Outcomes
  • See ADR-005 and ADR-006 for related decisions on API structure and asset type definition.