Database structure

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
comtek
Forum Commoner
Posts: 39
Joined: Tue Feb 17, 2004 10:46 pm

Database structure

Post 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.
comtek
Forum Commoner
Posts: 39
Joined: Tue Feb 17, 2004 10:46 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
comtek
Forum Commoner
Posts: 39
Joined: Tue Feb 17, 2004 10:46 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

a one-to-many is the way to head, yes.
comtek
Forum Commoner
Posts: 39
Joined: Tue Feb 17, 2004 10:46 pm

Post 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?
comtek
Forum Commoner
Posts: 39
Joined: Tue Feb 17, 2004 10:46 pm

Post 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.
Post Reply