So I have 3 tables: Users, Customers and Bookings.
The relationship and foreign keys between each:
Users hasOne Customers. Customers belongsTo Users. Users.id = Customers.user_id
Customers hasMany Bookings. Bookings belongsTo Customers. Customers.id = Bookings.customer_id
In an add form, when making a booking, I want to save the logged in user's customer id as the booking's customer_id.
Fields:
In Users table:
-id
-username
-password
-role_id (connected to roles table) -created
-modified
In Customers table:
-id
-user_id (the foreign key connected to Users table)
-name
-created
-modified
In Bookings table:
-id
-customer_id (the foreign key connected to Customers table)
-payment_id (connected to payments table)
-created
-modified