Page 1 of 1

Database structure

Posted: Tue Feb 01, 2005 12:48 am
by comtek
I am new to php and MySQL as well as web design as far as that goes. Thru some books I have and some online help I have put together a script that will upload multiples files into a directory and enter the appropriet info in to a db. Having completed a working form , I now want to add more info into the form. I want to add things like name, address, phone, etc. What is the proper way to setup the db to handle this new info? Each record that will contain name, address, phone, etc will need to be associated with several uploades files. I currently have a table called "uploads" in my db which stores the info about the individual files that get uploaded. Do I just add more fields to it, Or do I create a new table? Either way how will I make the associations. I may have rambled a bit, sorry for that. I am a little over my head and strugling to understand the theory as well as the practice of it all, but i am determined to get thru it. Thanks in advance.

Posted: Tue Feb 01, 2005 12:53 am
by comtek
I don't know if it makes any difference but, I wanted to mention that the number of files that will be associated with any one record could be 2-3 or as many as 10-12 or more. This number could be different for each record and will change as new documents get scanned and entered into the db.

Thanks

Posted: Tue Feb 01, 2005 12:54 am
by feyd
reading this: http://www.oreilly.com/catalog/javadtab ... r/ch02.pdf should clarify how they should generally be laid out to attach them all together..

Posted: Tue Feb 01, 2005 11:11 am
by comtek
Thanks for the link. It has been very helpful. It would appear that I would be best served using a one to many relation. I already have an "upload" table that contains the uploaded file info. I could add a foreign key from a newly created table that would contain the customers info.

Does this sound correct?

Posted: Tue Feb 01, 2005 11:48 am
by feyd
a one-to-many is the way to head, yes.

Posted: Tue Feb 01, 2005 1:45 pm
by comtek
After looking into this a little more, Ihave some questions.

Do I need to create a new InnoDB or convert my existing MyISAM table to an InnoDB?

Posted: Tue Feb 01, 2005 4:00 pm
by comtek
OK, I actually created a new db with two InnoDB tables Patients & Documents, I then indexed them and created th FK.

Now for the fun part... the PHP.. I need direction on how to deposit the form data to the correct tables.