DEV Community

Botánica Andina
Botánica Andina

Posted on

I Built a JSON Schema for Complex Relationship Data

I Built a JSON Schema for Complex Relationship Data

I've been working on a database with 592+ interconnected entries, and I wanted to share how I structured the JSON schema to handle complex relationships efficiently.

The Data Problem

Relationship data has multiple dimensions:

  • Entity A + Entity B → Severity level
  • Evidence type (clinical, case study, theoretical)
  • Mechanism of action
  • Reference citations

A flat list doesn't scale. Here's the schema I ended up with.

Schema Design

Key Design Decisions

1. Separate Entities

Each entity and relationship is a separate object. This allows flexible querying.

2. Evidence Levels

I used a simple enum: clinical_trial, case_report, theoretical.

3. Severity Codes

  • major, moderate, minor, unknown

4. Reference Linking

Each relationship has a references array for verification.

Open Source

The schema is available as open source. Feel free to fork, extend, or use it in your projects.

What database schemas have you designed for complex relationship data?

Top comments (0)