views:

123

answers:

2

Hello,

Yesterday I asked the question on how I should save my files. After some research I've desided to go with storing the files "in" the database.

I've checked the difference between storing the files using filestream and storing the files in the database itself.

Each has it's advantages and disadvantages. To help me with my research this site helped me out a lot: http://www.codeproject.com/KB/database/SqlFileStream.aspx

So basically it says that saving the files using filestream is better if the files are bigger than 1mb.

But I've discovered another problem with filestreaming. If you delete a record in the database the file still exists on the filesystem.

Therefore I need you guys opinion. What to use? Filestream or saving the files in the database using VARBINARY?

Grtz, M.

+3  A: 

Use Filestreams.

Databases are designed to store relational data, file systems are designed to store files.

I heard often from Microsoft employees that storing large blobs in an SQL Server 2000/2005 (cant remember) is not a good idea.

Also consider Backup: A Databasefile is ONE file (EDIT: If you configure it so). If you're using Filestreams you can backup individual files.

Arthur
indeed, I've noticed that you can backup the files seperatly from the database files.
Sem Dendoncker
If the files are logically part of the database wouldn't you want to backup them up as such. That's to say if you backup the database you backup the files all as one. I suppose maybe you have requirements that the files are not as important as the rest of the database data, but other than that they should be treated with the same backup mind set as the database.
StarShip3000
+3  A: 

The data on the filesystem will (should) be removed soon after you delete the data from the database, though this is done in a separate system background thread, so it may remain on the filesystem until basically the garbage collector runs again. However, all results accessed through any of the filestream APIs (i.e. tsql or streaming) will be guaranteed to not access anything that has been removed, whether or not the filesystem data still resides on disk (ACID is ensured with filestream).

chadhoc
omg: hadn't noticed that one. you are right. thx a bunch
Sem Dendoncker
absolutely, that's why we're all here
chadhoc
i also noticed that it depends on the recovery model. if it is set to full everything will be kept, if it is set to simple it will be removed almost instantly
Sem Dendoncker