Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it ever a good idea to store BLOBs in a database?

For a while I've been working on inserting the data from a bloated Excel workbook into a SQL database. My team has suggested keeping a backup of the .xls, and they are wondering if it might be a good idea to put the Excel workbook actually inside the database so that all the relevant data from our project was together.

I know some databases support the insertion of binary files, but clearly this was the not the original intended use of DB systems, and so I'm thinking that this is a bad idea. My vote would be to put URLs to the workbooks in the database and keep the workbooks in a secure location on our intranet.

What are the pros (if any, besides keeping both the production data and the backup in the same place) and cons of putting BLOBs in a database?

Edit: Just to clarify a little further, though I give a specific scenario, I intend this question to primarily be about BLOBs in general. But whatever I can glean for your responses that will assist me in my specific situation is, of course, appreciated. :)

Thanks,
-Robert


P.S. For those of you that didn't know, BLOB is a backcronym for "Binary Large Object"

like image 315
JoeCool Avatar asked Jan 23 '23 13:01

JoeCool


2 Answers

Generally I avoid putting blobs in the database if there are other storage options that cost less. Sure, there are valid reasons for storing blobs in the database, but I tend to err on the side of caution and use the FS for file storage, and databases for data structures.

Since you're using SQL 2008, you might also be interested in the FileStream data type. It could make things a lot easier on you.

like image 199
Scott Anderson Avatar answered Jan 26 '23 02:01

Scott Anderson


Many CMS packages (such as Sharepoint) store it all as BLOBs anyway.

A quick summary. I have no personal opinions because I've never had to design or develop very large BLOBs (such as spreadsheets) in a DB. I've stored images and other smaller stuff.

In database:

Pros: Assuming other data as well as BLOBs:

  • it's all in one place.
  • backup/restores are coherent

Cons:

  • Database bloat
  • Performance

Out of database

Pros:

  • No database bloat
  • Stored natively

Cons:

  • Backup/restore more complicated
  • Risk of broken links
like image 36
gbn Avatar answered Jan 26 '23 02:01

gbn