2

Is it good to store the uploaded file into a relational database or put it in a file system under a directory in IIS? I thought relational system will be a better choice. Any comments? When will you use one over the other?

EDIT: RDBMS, will make it easier to relate multiple file attachments to a record. It's easier to maintain version(s)

File systems make it easier to store data and I think performance wise this is a better choice.

James
  • 2,454
  • 1
  • 22
  • 22
Shaw
  • 1,484
  • 4
  • 20
  • 31
  • See [this](http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay) question. Or [this](http://stackoverflow.com/questions/662488/would-you-store-binary-data-in-database-or-in-file-system) or [this](http://stackoverflow.com/questions/815626/to-do-or-not-to-do-store-images-in-a-database). – Anton Gogolev May 25 '09 at 10:40

1 Answers1

1

It really depends on the case. If you are storing very large files your DB will become really big - consider this - it may affect the price of your hosting.

Storing files in a DB is preferred when you are in a web farm - for example if the requests to your application are processed by several servers and you store the files in a DB, then SQL clustering is all you need, and storing the files in the file system in such case is a lot harder - you have to use a common location or synchronize the files through the server farm!

I would use a DB for a file store - one location for all the data related to your application - easier to maintain and backup/restore!

Here is an article explaining how to store in a DB: http://www.dbazine.com/sql/sql-articles/charran5

Here is an interesting reading about SQL Server 2008 and the filestream feature: http://www.devx.com/dotnet/Article/40812

Pavel Nikolov
  • 9,401
  • 5
  • 43
  • 55
  • Very interesting.. If I'm opting for file system, is it a good idea to put it under an IIS folder, or store it in a different file server, maybe a dedicated one? – Shaw May 25 '09 at 11:08
  • I wouldn't use IIS except in case the files must be available for users to access them through browser or a download manager... – Pavel Nikolov May 25 '09 at 11:13