4.0 KiB
4.0 KiB
Boarding Plan — Table Relations (BusPro schema)
Authority:
docs/buspro-database-reference.md§8.4. Retained for the detailed ER diagram of theZustiegsPlanung*subsystem.
Read-only reference for building the boarding-plan API endpoint (look up a plan
by IDZustiegsPlanung, returning names, addresses, and times).
The query walks:
ZustiegsPlanung → persons → (name via BuchungTN/AdressePerson) →
PersonStelle junction → BusStelle (time) → Zustieg (address) → Bus.
ZustiegsPlanungPersonStelle is the pivot that ties a passenger to a timed stop.
ER diagram
erDiagram
ZustiegsPlanung ||--o{ ZustiegsPlanungBus : "IDZustiegsPlanung_FS"
ZustiegsPlanung ||--o{ ZustiegsPlanungPerson : "IDZustiegsPlanung_FS"
ZustiegsPlanungBus ||--o{ ZustiegsPlanungBusStelle : "IDZustiegsPlanungBus_FS"
ZustiegsPlanungPerson ||--o{ ZustiegsPlanungPersonStelle : "IDZustiegsPlanungPerson_FS"
ZustiegsPlanungBusStelle ||--o{ ZustiegsPlanungPersonStelle : "IDZustiegsPlanungBusStelle_FS"
ZustiegsPlanungPerson }o..|| BuchungTN : "IDBuchungTN_FS"
BuchungTN }o..|| AdressePerson : "IDAdressePerson_FS (name)"
ZustiegsPlanungBusStelle }o..o| Zustieg : "IDZustieg_FS (soft, address)"
ZustiegsPlanung {
bigint IDZustiegsPlanung PK
datetime Datum
}
ZustiegsPlanungBus {
bigint IDZustiegsPlanungBus PK
string ReiseleiterName
}
ZustiegsPlanungBusStelle {
bigint IDZustiegsPlanungBusStelle PK
datetime Zeit "TIME"
smallint Sortierung
}
ZustiegsPlanungPerson {
bigint IDZustiegsPlanungPerson PK
}
ZustiegsPlanungPersonStelle {
bigint IDZustiegsPlanungPersonStelle PK
string Art "Einstieg/Ausstieg"
}
AdressePerson {
string Name
string Vorname
}
Zustieg {
string Strasse
string Plz
string Ort
}
ASCII fallback
ZustiegsPlanung (the planning id)
/ \
IDZustiegsPlanung_FS IDZustiegsPlanung_FS
/ \
ZustiegsPlanungBus ZustiegsPlanungPerson ──IDBuchungTN_FS──▶ BuchungTN
│ (Reiseleiter) │ │
IDZustiegsPlanungBus_FS IDZustiegsPlanungPerson_FS IDAdressePerson_FS
│ │ ▼
▼ ▼ AdressePerson
ZustiegsPlanungBusStelle ◀──┐ ZustiegsPlanungPersonStelle (NAME)
• Zeit (TIME) │ • Art (boarding/alighting)
• IDZustieg_FS ··soft··▶ Zustieg (ADDRESS)
└──IDZustiegsPlanungBusStelle_FS───┘ (junction: passenger ↔ stop)
Legend: ||--o{ / solid = enforced FK constraint; }o.. / ··soft·· =
convention-only _FS reference (no DB constraint — join defensively, expect
NULL/0/orphaned values).
Notes for the query
- Name is not stored in the plan; join out live via
ZustiegsPlanungPerson.IDBuchungTN_FS → BuchungTN.IDAdressePerson_FS → AdressePerson. - Time lives on
ZustiegsPlanungBusStelle.Zeit(per stop), not on the plan header (ZustiegsPlanung.Datumis the plan date). - Address comes from
Zustieg(the boarding point). Prefer reaching it viaZustiegsPlanungBusStelle.IDZustieg_FSso it never depends onZustiegsPlanungPerson.IDZustieg_FSbeing populated. - A passenger can have multiple
ZustiegsPlanungPersonStellerows (boarding + alighting), distinguished byArt. Filter onArtfor boarding-only. - To verify against real data: the actual
Artcodes (nvarchar(6)), and whetherBusStelle.IDZustieg_FSalways matches the passenger'sPerson.IDZustieg_FSon the boarding leg.