I have two tables:
customer (
client_id(PK),
lastname,
firstname,
flightID (Fk)
)
flight (
flight_id(PK),
flightarrival,
flightdepart
)
My questions are:
I really want to separate the two because bulk tables are confusing.
Here is an example of a "bulk table":
customer(
client_id(PK),
lastname,
firstname,
flightarrival,
flightdepart
)
but I want to normalize it and separate it from the customer table and just link them.
The schema you proposed would mean that each customer could be related to one (not zero, not more than one) flight, which feels wrong.
In essence, I think you have a many-to-many relationship, which you can do with three tables:
customer (id(PK), lastname, firstname)
flight (id(PK), flightarrival, flightdepart)
customer_flight (
customer_id REFERENCES customer(id),
flight_id REFERENCES flight(id)
)
You should create a separate cross-reference many-tomany - table which will be like
customer_flights(id int (pk),customer_id int, flight_id int,timecreated(optional))
one customer may have several flights booked like in past and in future...
and later join the two tables basing on the records in this table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With