FK: because, presumably, they are referencing entities that have their own attributes e.g. a plane has a manufacturer, a model number, a unique identifier/callsign, number of seats, date of manufacture, etc
Try inserting a flight with an arrival code that isn't in your airport table. A foreign key makes the database reject that typo. You can still store just the code on each flight and look up the airport name from the airport table when you display it.
1
u/NW1969 1d ago edited 1d ago
A few thoughts
- Flight: these attributes should probably be FKs to other entities
Departure_IATA
Arrival_IATA
Compagny
Plane
- Ticket: a ticket normally only references a single person. Maybe you need a booking entity and then 1 ticket per traveller?
2
u/squadette23 1d ago
Here is a long-ish tutorial on database design, using a non-trivial problem as an example: https://kb.databasedesignbook.com/posts/google-calendar/
1
u/Discordbothost 1d ago
Try inserting a flight with an arrival code that isn't in your airport table. A foreign key makes the database reject that typo. You can still store just the code on each flight and look up the airport name from the airport table when you display it.