OK your right, this table design sucks!!!
However in the begining of my project I was not sure how to loop properly with PHP (cold fusion background) so I built the table like you see it
This is the run down
********History************
I am creating a documetn management system for DHL(parcell delivery co.) what they want is a system where users can create documents(via special interface)and then send them on to supivisors for approval.
Part of the document creation process is that users can link other documents to there document that they are creating(this has to do with some internal Hiearchy of document management ,some documents are dependent of others)
I get the link documents from another table The final_main_table, I assume that a document will not exceed 20 links(therefore I created a table final_link_doc that would accept up to 20 link_documents)
So when the user chooses what documents to link they are inserted into the final_link_doc table
final_link_doc TABLE
document_number [primary key]
link_doc_1
link_doc_2
link_doc_3
link_doc_4
link_doc_5
link_doc_6
link_doc_7
link_doc_8
link_doc_9
link_doc_10
link_doc_11
link_doc_12
link_doc_13
link_doc_14
link_doc_15
link_doc_16
link_doc_17
link_doc_18
link_doc_19
link_doc_20
final_main TABLE
document_number [priamary key]
document_title
purpose
scale
date_created
written_by
approved_by
Well everything works fine so far, but now I need to build a system that will e-mail the user who created the document if there is a revision.
************example***********
user Chris creates docuemnt AM0101
he links document AM0101 to document PP0101.(exsisting document in final_main TABLE)
user Jennifer makes edits to document PP0101
after these edits the system needs to notify all authors who created documents that are linked to PP0101 that there has been a change made to PP0101(this is to insure that if a process changes in one document that it does not change the other document process, this referes to the Hiearchy I mentioned before)
so what I need to do is select all the document_number fields in TABLE final_link_doc that have PP0101 in one of the link_doc_% fields.
Then I will generate a mail() by author names in final_main
so user Chris will get a e-mail that document PP0101 has been modified please check that this modification does not afect your document AM0101
I hope this makes sense.
If yo have a better Idea on how to stor these link documents please let me know
thanks
christopher