For an invoice, I need to store multiple amounts. To simplify maintenance, I decided to design one table in which I will store amount types, and second in which I will store amount and amount type. Incoming and outgoing invoice have different amount types, proscribed by law. Foreign invoice has different amounts, too.
So, I would have:
table invoice_amount_types(id, type_desc)
table invoice_amounts(id, invoice_id, amount_types_id, amount)
But, in this case I would have aprox. 10 records for every invoice. I’m not sure about affect of pivot function to performance of my queries.
Is it better to design few tables like this (invoice and invoice_amounts_… tables would be in one-to-one relationship)
table invoice_amounts_incoming(invoice_id, amount_full, amount_0, amount_10, amount_22, amount_23, pre_vat10, pre_vat22, pre_vat23)
table invoice_amounts_outgoing(invoice_id, amount_full, no_vat, no_vat_export, no_vat_transport, no_vat_other, amount_10, amount_22, amount_23, vat10, vat22, vat23)
The first way(multiple tables) will initially be more work to setup correctly, but is a better solution. In the long run it will save you time and pain.