Web Hosting Talk







View Full Version : DB structure suggestion


seodevhead
10-25-2005, 04:10 PM
I am developing a php/mysql database app for web visitors to submit their automobile profile. For instance, they will tell a little bit about their car in a form and select a file on their hard drive to upload for the picture of their car.

My question is... where should the BLOB type variable go in my database scheme?? I have a table called "posts" which will include all the form elements submitted by the web visitors (ie, car description, miles on car, color, etc.).... is the "posts" table where I want to add the BLOB image???

The reason I ask this is because there will be a lot of sorting and searching going on within the database and I was wondering if it was smart to have that large BLOB column amongst the other columns in the post table.... should the images have their own table??? Look forward to your suggestions.

innova
10-25-2005, 04:23 PM
Here is an alternate idea: Dont store images in the DB at all.

Just store the http path to the image file (relative or absolute)

If you insist on having images stored, store them in a separate table with a link to the vehicle_id or whatever appropriate field.

seodevhead
10-25-2005, 04:33 PM
How do I save the uploaded images to a directory on my server? I know how to save them to the DB, unfortunately I do not know how to save to folder as file.

innova
10-25-2005, 05:07 PM
There is a set of file-upload handling functions. You would probably want to put certain constraints on the data (filesize, extension, etc) and assign it a unique filename.

Anyway, the php.net manual page on filesystem functions should be of help:

http://us2.php.net/manual/en/ref.filesystem.php