Перейти к содержанию

ER diagram — context bridge (cross-context FKs only)🔗

Generated from the live PostgreSQL schema (queried via pg_constraint). This isolates the edges the bounded-context split would otherwise hide: every foreign key that crosses from the SocialScan context into the legacy spine. Nothing else is drawn.

The spine is two legacy tables — candidates (the political actor) and fetch_runs (one ingestion run). SocialScan never re-implements them; it points back at them:

  • ss_snapshots.source_run_id → fetch_runs.id — a SocialScan pull is anchored to an ingestion run. This is the only SocialScan→fetch_runs edge; ss_snapshots is the entry point of the context.
  • <leaf>.candidate_id → candidates.id — every per-actor SocialScan table (12 of them) carries the candidate directly, so analytics can group by actor without walking back through ss_snapshots.
erDiagram

"radar.candidates" {
  bigint id PK
}
"radar.fetch_runs" {
  bigint id PK
}

"radar.ss_ai_reports" }o--|| "radar.candidates" : candidate_id
"radar.ss_district_summaries" }o--|| "radar.candidates" : candidate_id
"radar.ss_judge_results" }o--|| "radar.candidates" : candidate_id
"radar.ss_mention_relevance" }o--|| "radar.candidates" : candidate_id
"radar.ss_own_posts" }o--|| "radar.candidates" : candidate_id
"radar.ss_post_classifications" }o--|| "radar.candidates" : candidate_id
"radar.ss_post_tonality" }o--|| "radar.candidates" : candidate_id
"radar.ss_posts" }o--o| "radar.candidates" : candidate_id
"radar.ss_recommendations" }o--|| "radar.candidates" : candidate_id
"radar.ss_snapshots" }o--o| "radar.fetch_runs" : source_run_id
"radar.ss_themes" }o--|| "radar.candidates" : candidate_id
"radar.ss_trends" }o--|| "radar.candidates" : candidate_id
"radar.ss_trends_daily" }o--|| "radar.candidates" : candidate_id

Reading it. candidates is the heavily-shared hub: 12 SocialScan tables reference it. fetch_runs is touched from SocialScan only via ss_snapshots. Note the live column is source_run_id (not fetch_run_id) and ss_snapshots itself carries no candidate_id — it reaches actors transitively through its leaf tables. (These specifics were confirmed against the live schema, correcting earlier assumptions.)


Regenerate: query pg_constraint for FKs whose child is ss_* and parent is candidates/fetch_runs. Full per-context detail: legacy.md, socialscan.md.