Digital twin · anomaly detection · data architecture · planned
Tables, keys and rules.
Every table on the lineage picture, with what one row stands for, how it is keyed, how many columns it has, how its files are split, how long it is kept and under whose key. Then the joins that hold it together and the rules that keep it clean. The column lists themselves live on the picture: hover a table, or hold Shift for the entity-relationship view.
Every table.
Grain, partitioning and retention are decision 56, proposed; the columns of the regional tables are decision 57, proposed. Retention figures already in a contract or a cost model are kept as they stand.
| Table | Layer | Shape | Grain: one row is | Keys | Columns | Split by | Kept | Whose key |
|---|---|---|---|---|---|---|---|---|
| AVL stop times the sample files | Source | vendor CSV, ;-delimited, UTF-8 BOM | one row per trip per stop | CALENDAR_ID, TRIP_ID, ROUTE_ABBR, GEO_NODE_ABBR, GEO_NAME prefix | 26 | one file a month | the agency's rule | agency |
| APC counters the sample files | Source | vendor CSV, ;-delimited, UTF-8 BOM; first two columns in the opposite order to AVL | one row per trip per stop; a visit may have several | CALENDAR_ID, TRIP_ID, ROUTE_ABBR, STOP_NUMBER, PATTERN_STOP_SEQUENCE | 18 | one file a month | the agency's rule | agency |
| Raw AVL export the sample files | Bronze | as received, plus file and landing time | as received | none imposed | 28 | by file and service day | the agency's rule; never leaves | agency |
| Raw APC export the sample files | Bronze | as received, plus file and landing time | as received | none imposed | 20 | by file and service day | the agency's rule; never leaves | agency |
| TIDES stop_visits tested on the sample | Silver | TIDES stop_visits (AVL skeleton, APC counts merged) | service day × trip × stop sequence | service_date, trip_id_performed, trip_stop_sequence; stop_id = GTFS stop | 17 | by service day | the agency's rule; the region never reads it | agency |
| TIDES trips_performed planned | Silver | TIDES trips_performed | service day × trip | service_date, trip_id_performed; trip_id_scheduled = GTFS trip_id through the trip map | 17 | by service day | the agency's rule; never leaves | agency |
| 5-minute loads replayed on the sample | Gold | TIDES passenger_events, summed; five extras named in the contract (decision 60) | route × direction × stop × 5-minute window | service_date, route_id, direction_id, stop_id, window_start | 9 | sent every 5 minutes, within 2 | 24 hours on the lane | region, on arrival |
| GTFS timetables already standard | Source | GTFS zip, as published | one row per trip per stop (stop_times) | trip_id, stop_id, stop_sequence; service_id carries the board period | 39 | by party and feed version | every version the archive still covers | none, open |
| GTFS-Realtime feeds already standard | Source | GTFS-Realtime protobuf, as each party publishes it | one position per vehicle every 10 s; one trip update per trip | party, vehicle id, trip id, timestamp | 39 | polled every 10 s | not stored as such; see the live lane | none, open |
| Live lane planned | Bronze | records as received (Kinesis Data Streams), two record kinds | one record per position or per load row | party_id, sequence_number | 29 | one shard per party | 24 hours | region |
| TIDES vehicle_locations planned | Silver | TIDES vehicle_locations plus extras | one row per position | location_ping_id; party_id, service_date, vehicle_id, event_timestamp | 19 | by party and service day | 3 years, as costed; a leaver's part deleted at once, snapshots expired | region |
| Timetables already standard | Silver | GTFS, unchanged, plus party and version | as GTFS | party_id, feed_version, then each file's own key | 42 | by party and feed version | while the archive covers it | region |
| Delay and load per route replayed on the sample | Gold | CloudWatch metrics; the band is the detector's | route × direction × 5-minute window, one value per metric | party_id, route_id, direction_id, metric_name, timestamp | 11 | one series per route and direction | 63 days; cannot be deleted sooner | region |
| Last state per vehicle planned | Gold | DynamoDB items of two kinds: a vehicle, a counter | one item per vehicle, overwritten; one per route and stop for the counters | pk = party_id; sk = vehicle_id, or route_id and stop_id | 16 | by party | until overwritten; expires a day after the last sighting | region |
| Who is affected planned | Gold | DynamoDB item, built with Athena | party × route × stop → neighbours and their share | pk = party_id; sk = route_id#stop_id | 10 | by party | replaced nightly | built under each agency's key, by grant |
| Regional transfer table planned | Source | Iceberg table; the contract's row, with the party ids resolved | to-agency × from-party × route × date × 3-hour band | party_id, from_party, service_date, to_route, time_band | 11 | by party (the to-agency) and service date | 3 years; a leaver's rows deleted, snapshots expired, reports rebuilt | each agency's, by revocable grant |
| Registry planned | Source | Aurora tables: parties, contracts, shared_stops | one party; one contract version; one shared stop pair | party_id; contract_id; party_id, stop_id, neighbour_party | 22 | not partitioned | while the region runs; a leaver's row marked left, kept for audit | region |
| Alerts replayed on the sample | Out | no TIDES home; the shape the contract names (DynamoDB alert log) | one row per alert, open or cleared | alert_id; party_id and month for the partition | 18 | by party and month | 13 months at the region; copies stay with receivers | region; each receiver's own |
| Live alert feed planned | Out | JSON over the API | the open alerts a reader may see | reader's party; allow-or-deny rules | 14 | per request | not stored | region |
| Weather and events planned | Source | not chosen | not chosen | place and time | 6 | not chosen | not chosen | none, open |
Tested: an exploration built the table from the real month. Replayed: the sample replay computed its values at route grain from the month's files. Standard: the shape is the published one already. Nothing is deployed. The column count links to the picture, where every column is listed with its type and key role.
Keys and joins.
Four identifiers carry every join in this use case. Each is written once in the sample's vendor form and once in the standard's.
| Key | In the vendor files | In the standard | Live | Checked |
|---|---|---|---|---|
| Service day | CALENDAR_ID, 1YYYYMMDD; times as seconds past midnight, past 86,400 after midnight | service_date; a timestamp per event | start_date in the GTFS-Realtime trip | 5.45 M visits decoded, none rejected |
| Trip | vendor TRIP_ID, never in GTFS trips.txt; 15,230 ids, each one timetable trip all month | trip_id_performed → GTFS trip_id through the trip map, held in trips_performed.trip_id_scheduled | trip_id as the feed names it | 99.78% of 136,684 trip-days match one GTFS trip exactly, 99.97% within 60 s |
| Route and direction | ROUTE_ABBR; direction codes such as Noh, Soh | GTFS route_id through route_short_name; direction_id 0 or 1 from the timetable trip | route_id, direction_id | every route-direction pair maps to one direction_id |
| Stop | GEO_NODE_ABBR (AVL), STOP_NUMBER (APC); repeated stops told apart by sequence | stop_id = GTFS stop_id, which equals stop_code in this feed | stop_id in the trip update; shared stops from the registry's crosswalk | 100% of visits find their GTFS stop |
| Window | none | window_start: the departure time rounded down to 5 minutes | the same | 96% of 247,241 route-windows hold three or more visits |
| Party | the file is one agency's | a party id from the registry, on every regional row | the feed address the registry holds | by contract: no registered party, no row |
AVL and APC join to each other on service day, trip, route, stop and stop sequence; the four-column key alone collides on loop routes. Neither joins to GTFS on the trip id, which is why the trip map exists.
Quality and privacy rules.
The same rules the data contracts page states, written against the tables above. Each is also written into the step that applies it, on the picture.
On the way into Silver
- Every row checked against the published TIDES schema: types, required fields, non-negative counts and dwell, enums, unique key.
- Stop must exist in the party's GTFS; sequence must run 1, 2, 3 within a trip.
- Duplicate counter records of one visit summed (20,077 visits in the sample); the string NULL becomes null.
- Flagged, not rejected: load above capacity (2,251), visits with no observation (50,532).
While it runs
- Feed gap, frozen vehicle, position jump, dead counter: the rules on the live lane (T8).
- Loads late or off-contract: crowding alerts pause for that party; delay alerts carry on.
- A window with fewer than three visits, or a party not sharing, shows unknown, never normal.
- A new series alarms only after two weeks of history; a stale timetable check is still to be drawn.
Never
- No fare card is read in this use case; loads are counts of people from door sensors.
- No card serial or per-card record is written to the repo or the site (decision 16); the sample's fare file is not touched.
- The one fare-derived input, transfer totals, is protected at home: rows under 5 cards dropped (decision 26); 10 proposed for other fare counts.
- Alerts name a party, a route, a vehicle as its own feed names it, and a neighbour; never a rider.
Decided
- Standards are the table shapes (4); raw data stays home (5); loads are counts with no minimum group size (21)
- Live loads v1 and transfer totals v1 set the grain, cadence, custody and retention of what crosses (42, 55)
- Metrics age out in 63 days; the archive is costed at 3 years
Open
- Decision 56, proposed: grain, partitioning and retention of every other table as listed above
- Decision 57, proposed: the columns of the regional tables
- Decision 60, proposed: the live-loads contract names route, direction and visits as extras and on_board as the mean load over the window's visits, as the column-level pass found it must
- Decision 61, proposed: the registry and the regional transfer table are the same tables, column for column, in both use cases
- Whether 5-minute loads are also archived raw: the detailed picture writes every lane record to the archive, the contract keeps loads 24 hours
- A TIDES home for alerts and for the summed loads; both are named extras for now
- Weather and events: not sourced, not shaped
Caveats
- Tested means the adapter prototype built stop_visits from one agency's month; trips_performed, the live lane, archive and state tables exist on paper only
- Replayed values are at route grain from stop-level arrivals, not from positions; about 48 delay and 46 crowding alerts a weekday across {('gtfs', 'T2'): {'fs': 't', 'fo': -40, 'ts': 'b', 'via': [['y', 'gap:public:-30']], 'label': 'fetched when they change'}, ('gtfs', 'T6'): {'fs': 'r', 'ts': 't', 'via': [['x', 'x:T6']], 'label': 'when they change'}, ('rt', 'T5'): {'fs': 'r', 'ts': 't', 'via': [['x', 'x:T5']], 'label': 'every 10 s'}, ('T4', 'lane'): {'fs': 'b', 'fo': -20, 'ts': 't', 'via': [['y', 'top:region:1']], 'label': '5-minute loads, every 5 min, within 2'}, ('T5', 'lane'): {'fs': 'b', 'ts': 'l', 'via': [['y', 'row:region:0']]}, ('T6', 'timetables'): {'fs': 'b', 'ts': 'l', 'via': [['y', 'row:region:2']]}, ('registry', 'T5'): {'fs': 't', 'fo': 40, 'ts': 'b', 'tof': 30, 'via': [['y', 'row:region:0.5'], ['x', 'x:T5:30']], 'kind': 'ctl', 'label': 'which feeds'}, ('registry', 'T6'): {'fs': 't', 'fo': 70, 'ts': 'b', 'tof': -20, 'via': [['y', 'row:region:1.5'], ['x', 'x:T6:-20']], 'kind': 'ctl', 'label': 'which timetables'}, ('lane', 'T7'): {'fs': 'b', 'ts': 'l', 'via': [['y', 'row:region:1']]}, ('lane', 'T9'): {'fs': 'r', 'fo': 14, 'ts': 'l', 'tof': -12, 'via': [['x', 'colR:2:14']]}, ('timetables', 'T9'): {'fs': 'r', 'fo': -14, 'ts': 'l', 'tof': 12, 'via': [['x', 'colR:2:28']]}, ('timetables', 'T10'): {'fs': 'r', 'fo': 14, 'ts': 'l', 'tof': 14, 'via': [['x', 'colR:2:28']]}, ('registry', 'T10'): {'fs': 'r', 'fo': -14, 'ts': 'l', 'tof': -14, 'via': [['x', 'colR:0:20']]}, ('metrics', 'T11'): {'fs': 'r', 'ts': 'l', 'tof': 12, 'via': [['x', 'colR:3:28']]}, ('affects', 'T11'): {'fs': 'r', 'ts': 'b', 'tof': -30, 'via': [['x', 'colR:3:14']]}, ('weather', 'T11'): {'fs': 'r', 'ts': 't', 'tof': 24, 'via': [['x', 'colR:0:16'], ['y', 'gap:region:32'], ['x', 'x:T11:24']], 'label': 'a label, planned'}, ('T11', 'alerts'): {'fs': 'r', 'ts': 'l'}, ('alerts', 'T12'): {'fs': 'b', 'ts': 't'}, ('T12', 'feed'): {'fs': 'b', 'ts': 't'}, ('a_trips', 'T3'): {'fs': 'r', 'ts': 'l', 'tof': 14, 'via': [['x', 'colR:2:20']]}} routes
- Vendor ids and formats are one agency's; a second vendor would need its own adapter mapping
- The dead-counter rule at the region sees route and stop sums, so it flags a stop whose counter reads zero, not a vehicle; the vehicle-level check belongs at home