I've got question regarding problem I've faced in my project. Problem is about model of DB and to be more precise: how I can model this kind of relation (which at first I thought it will be simple M:M,but after some thoughts it is not so obvious ;) ). I have some ideas but maybe someone will have something better:)
My question will be regarding following problem:
I've got 2 tables. One has got e.g. invoices, second one - transactions. One invoice can match to many transactions, and one transaction can match many invoices. I want to allow user to do some matching so he can pick invoices (one or more), pick transactions (one or more) and click "match". But after clicking "Match", all used record (inovoices and transactions) cannot be used any more. My ideas are:
Used standard association table but with 3 columns: idIncoive, IdTransaction and unique id for matching info. And put unique constraint to... and here I've stuck because I don't know how to force that one invoice can have multiple transactinos but within one matching (and here are I'm missing information about matching I guess)
I thought that I will add one extra columnt to invoices and transactions table. And when user do matching, I will put unique numer (but unique for matching, not unique for tables sens of) to these columns. And this number, will be matching number, which I can easliy chcek witch transaction/invoice was checked and with what.
And this is idea which is my best for now. But as I said - I'm not sure that this is the best in all so here is my ask to get your opinions about this too.
One more thing: there is a similar (at first glance) question here but problem stated there is:
- More complicated because user need to do some specific calculations and store information regarding projects
- Not answered yet :).