structure - MySQL documents linking -


i have 4 tables:

  • orderforms
  • deliverynota
  • invoices
  • creditnota

what make possible link of document other document. example creditnote id 10 linked invoice id 155. orderform 17 linked deliverynote 10.

i see 3 possible solutions:

  1. create table every link ex.: orderform_link_diliverynote, orderform_link_invoice, orderform_link_creditnote, deliverynote_link_invoice, ...
  2. table "document_linking" 5 columns: link_id, orderform_id, deliverynote_id, invoice_id, creditnote_id.
  3. table "document_linking" once again 5 cols, in following way: link_id, documentype_one (eg.: invoice, creditnote, ...), document_id_one, document_type_two (eg.: invoice, creditnote, ...), document_id_two

i personaly prefer last one, in opinion dynamic solution. if ever add 1 or more doctypes, able without changing document_linking table. other advantage, in opinion, can link documents of thesame type.

as don't have experience on kind of linking, ask advice. every kind of welcome (articles, books, tips, ...), haven't found usefull on web :(


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -