← Back to CMS

CMS

Model Content Relationships Explicitly Not With Raw ID Strings

Relationships between content items should be modeled with typed references, not free-text ID fields that bypass validation.

Rule

Content relationships must be explicitly typed and validated at write time.

Why

Raw ID strings that reference nothing cause silent content holes and broken pages.

Must

  • Define relationship fields as typed references to a specific content type.
  • Validate referenced IDs exist before saving.
  • Support one-to-one, one-to-many, and many-to-many relationship types.
  • Cascade delete or nullify orphaned references on content deletion.

Should

  • Provide a picker UI for relationship fields, not raw ID input.
  • Show reference counts before allowing deletion of referenced content.

Anti-patterns

  • Storing "related post IDs" as a comma-separated text field.
  • No validation that a referenced ID resolves to real content.

Test Cases

  • Saving a reference to a non-existent item is rejected.
  • Deleting referenced content triggers reference cleanup.

Telemetry

  • broken_reference_detected
  • relationship_field_updated