tags:

views:

45

answers:

3

Possible Duplicates:
Storing Images in DB - Yea or Nay?
Saving images in database mysql

I have a site where user can upload profile picture and photo albums. Now i'm starting to wonder was I suppose to save pictures into a database or is file operation still ok as it gets bigger? I'm thinking in a huge scale like social networks, hundred of millions of pictures stored in files seem to me crazy so im sure it must be stored some other way?

Any advice or guidance. Thanks

+4  A: 

Storing them on your webserver and having the URL in your database would be a better idea. It makes it easier to modify the images, too.

domsterr
yep - if not on the web server at least on a static CDN.
RPM1984
A: 

Save you pictures on you web server as you are going to develop social networking site so it will be a huge burden on database. Because some times you have to handle pictures of ++MB. So store only link in BD.

From File you can easily play with pics and even can migrate them easily without any effect to database.

Azhar
A: 

There are pros and cons to both approaches. Databases are not really great for storing large blobs of data. Doing so will tend to use up lots of resources on the database (CPU, memory, hard drive space and network bandwidth between the database and web server). It will make the database backups much larger.

However, the big problem with storing the images on a separate file system (say on the web server) is that it is much more difficult to sync it with the data that is in the database. If a user changes a photo while a database backup is going on, who knows what state you will end up in. If you ever need to restore the database from a backup, it will be very difficult to sync up the images. You could also get orphaned images hanging around wasting disk space if you aren't careful.

IMHO, it is too much effort to maintain data integrity between the database and a file system, so I would store them in the database throw some money are the hardware so that it can keep up.

TallGuy