Forum Moderators: open

Message Too Old, No Replies

pdf stored in DB or folder

         

neonpie

10:57 am on May 1, 2009 (gmt 0)

10+ Year Member



Hi Guys,

which is better? storing the PDFs in the DB or uploading the files to a folder - probably best to rename them so they dont mistakenly get overwritten by newer files and also to identify the files if something happened to the DB.

I was thinking if i was to create a table that links with a user table. each user will have about 8 pdf files uploaded to their account by admin so they can download when logged in.

these files would be deleted after about 6-9 months by a cron job, so at any time we expect upto 300 users with 8 pdf files.
the 8 files will total about 2.5MB

any thoughts?

Cheers

LifeinAsia

5:39 pm on May 1, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



My comments would be the same as as a similar thread regarding storing images in a DB or folders-
I think [url=http://www.webmasterworld.com/databases_sql_mysql/3704208.htm]Storing images in database{/url] is the most recent one. I vote for folders.

neonpie

6:48 pm on May 1, 2009 (gmt 0)

10+ Year Member



Hi LifeinAsia - thanks for that. I read a similar one to that, but both referred to images, so i just wondered if it made any difference to the file type being stored.

can you give an example of when it would be best to store the file as a blob?

Cheers

LifeinAsia

7:02 pm on May 1, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



As far as I know, to the DB, a binary file is a binary file. I don't see much difference to the file system either.

Offhand, the only time I can think of is if you have multiple load balanced web servers using the same database. It would probably make more sense to have the files stored in 1 database instead of having to have a copy on each web server. Although in that case it might be better, in my opinion, to either use a NAS or dedicate one server for images (using something like images.example.com to server images for example.com), although that may require additional hardware and/or recoding lots of pages.