Standardize notebook table-relationship documentation cells

This commit is contained in:
2026-05-22 14:21:51 -07:00
parent c95f22fcdb
commit 03239ad007
9 changed files with 147 additions and 191 deletions

View File

@@ -1676,36 +1676,20 @@
"source": [
"## Tables Created by This Notebook and Their Relationships\n",
"\n",
"This notebook creates and/or maintains the following PostGIS/PostgreSQL tables:\n",
"\n",
"### Tables Created / Maintained\n",
"1. `public.rdh_precinct_vote_layers`\n",
"- One row per RDH precinct-election layer ingested.\n",
"- Key columns: `layer_id` (PK), `state_code`, `title`, `format`, file/source metadata, `loaded_at`.\n",
"- One row per ingested precinct-election layer.\n",
"\n",
"2. `public.rdh_precinct_vote_features`\n",
"- One row per precinct polygon feature from a loaded layer.\n",
"- Key columns: `feature_id` (PK), `layer_id` (FK), `state_code`, `source_row`, `properties` (JSONB), `geom` (MultiPolygon).\n",
"- Relationship: many features belong to one layer.\n",
"- One row per precinct geometry feature with source properties JSON.\n",
"\n",
"3. `public.data_center_rdh_precinct_vote_matches`\n",
"- Spatial match table linking data centers to precinct features.\n",
"- Key columns: `master_id` (FK), `feature_id` (FK), `layer_id` (FK), `state_code`, `join_method`, `match_distance_m`, `matched_at`.\n",
"- Primary key: (`master_id`, `feature_id`).\n",
"- Relationship: many-to-many bridge between data centers and precinct features (with match metadata).\n",
"- Bridge table linking data centers to matched precinct features.\n",
"\n",
"4. `public.data_center_election_context`\n",
"- Final standardized, one-row-per-data-center election context used by downstream mapping/analysis.\n",
"- Key columns: `master_id` (PK, FK), `name`, `city`, `state`, `rdh_layer_title`,\n",
" `precinct_identifier_name`, `election_year`, `office`, `democratic_votes`, `republican_votes`,\n",
" `total_votes`, `turnout_or_vote_share`, `updated_at`.\n",
"- Relationship: one row per `master_id` in `public.master_data_centers` (left-joined so all master rows can be retained, even if election fields are null).\n",
"\n",
"### Relationship Summary\n",
"\n",
"- `public.master_data_centers (master_id)`\n",
" - 1-to-many -> `public.data_center_rdh_precinct_vote_matches (master_id)`\n",
" - 1-to-1 (effective in this notebook) -> `public.data_center_election_context (master_id)`\n",
"- Standardized, one-row-per-data-center election context for downstream analysis/mapping.\n",
"\n",
"### Key Relationships\n",
"- `public.rdh_precinct_vote_layers (layer_id)`\n",
" - 1-to-many -> `public.rdh_precinct_vote_features (layer_id)`\n",
" - 1-to-many -> `public.data_center_rdh_precinct_vote_matches (layer_id)`\n",
@@ -1713,7 +1697,13 @@
"- `public.rdh_precinct_vote_features (feature_id)`\n",
" - 1-to-many -> `public.data_center_rdh_precinct_vote_matches (feature_id)`\n",
"\n",
"In short: **layers -> features -> matches**, then matches are standardized into **one election-context row per data center**."
"- `public.master_data_centers (master_id)`\n",
" - 1-to-many -> `public.data_center_rdh_precinct_vote_matches (master_id)`\n",
" - 1-to-1 (effective) -> `public.data_center_election_context (master_id)`\n",
"\n",
"### Rerun Notes\n",
"- Safe to rerun as new RDH layers and/or data centers are added.\n",
"- Reruns refresh matching outputs and regenerate standardized election context rows."
]
}
],