Home » Questions » Computers [ Ask a new question ]

Storing Images in DB - Yea or Nay?

Storing Images in DB - Yea or Nay?

"Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.








So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB.

What do you think are the pros/cons?"

Asked by: Guest | Views: 335
Total answers/comments: 3
Guest [Entry]

"As with most issues, it's not as simple as it sounds. There are cases where it would make sense to store the images in the database.

You are storing images that are
changing dynamically, say invoices and you wanted
to get an invoice as it was on 1 Jan
2007?
The government wants you to maintain 6 years of history
Images stored in the database do not require a different backup strategy. Images stored on filesystem do
It is easier to control access to the images if they are in a database. Idle admins can access any folder on disk. It takes a really determined admin to go snooping in a database to extract the images

On the other hand there are problems associated

Require additional code to extract
and stream the images
Latency may be
slower than direct file access
Heavier load on the database server"
Guest [Entry]

File store. Facebook engineers had a great talk about it. One take away was to know the practical limit of files in a directory.
Guest [Entry]

"This might be a bit of a long shot, but if you're using (or planning on using) SQL Server 2008 I'd recommend having a look at the new FileStream data type.

FileStream solves most of the problems around storing the files in the DB:

The Blobs are actually stored as files in a folder.
The Blobs can be accessed using either a database connection or over the filesystem.
Backups are integrated.
Migration ""just works"".

However SQL's ""Transparent Data Encryption"" does not encrypt FileStream objects, so if that is a consideration, you may be better off just storing them as varbinary.

From the MSDN Article:

Transact-SQL statements can insert, update, query, search, and back up FILESTREAM data. Win32 file system interfaces provide streaming access to the data.
FILESTREAM uses the NT system cache for caching file data. This helps reduce any effect that FILESTREAM data might have on Database Engine performance. The SQL Server buffer pool is not used; therefore, this memory is available for query processing."