Why are you storing invoice_no in the Hotels table? Are you creating a
new row for every invoice? Or is that an invoice_id? Like a hotel_id?
As I see it, invoices is basically a join table linking hotels to cars
so you need to set up a has_and_belong_to_many relationship between
hotels and cars through the invoices table. You shouldn't be storing
invoice data in the Hotel model. That don't make no sense...
Why are you storing invoice_no in the Hotels table? Are you creating a
new row for every invoice? Or is that an invoice_id? Like a hotel_id?
As I see it, invoices is basically a join table linking hotels to cars
so you need to set up a has_and_belong_to_many relationship between
hotels and cars through the invoices table. You shouldn't be storing
invoice data in the Hotel model. That don't make no sense...
ESPNDev
This database is not created by me, I have job to develop/maintain
their application. So that database was composed by previous programmer.
IN table invoices has no hotel_id and car_id, only has :
id, invoice_no, customer_id, amount, created_at
hotels table has id, invoice_no, price, amount. And
cars table has id, invoice_no, price, amount.
It is impossible if i have to change invoice_no to be invoice_id,
because there are already queries / records in those tables.
Please give me suggestion to make it works properly as foreign key using
invoice_no.