Shaw
Shaw

Reputation: 1494

In ASP.NET is it better to store an uploaded file into a relational database, or put it into the file system?

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.

Upvotes: 2

Views: 1861

Answers (1)

Pavel Nikolov
Pavel Nikolov

Reputation: 9541

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

Upvotes: 1

Related Questions