views:

102

answers:

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.

+1  A: 

See this question. Or this or this.

Anton Gogolev
Thank you very much. Obviously, I didn't search well!
Shaw
I'll save you clicking on the links. The preferred method is in the database.
DOK
+1  A: 

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
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
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