by orf · 10y ago · 0 comments
For stuff like this then I would say it's always preferable to store a json encoded representation rather than a format like pickle (python's object serialization format). If you don't and some clever chap works out a way to write input to that field then you've got an easy RCE. Plus it's easier to debug JSON, and databases like PG have a native data type for it.
That's just the format du jour. Ten years ago it would have been "store an XML encoded representation" and ten years before that it would have been some delimited representation. Tomorrow it may be yaml or something even more hideous.
Blobs in the DB can make sense in some situations but they should really be blobs: images, or other binary/raw data. But beyond a certain size it's almost always easier to manage things like these in a filesystem and just store a pointer (filename) in the DB.
That's called progress. We can't store it in some future language, who wants to store it as XML, so let's use the best of what we have.
File systems are about storing files. Databases are about intelligently organizing data for retrieval and reliably delivering atomic transactions.
Any system that I've seen scale up well separated blob data to a traditional or object file system. In addition to scaling the database more effectively, this allowed the infrastructure teams to optimize delivery of blob data from a platform POV.
Often folks doing this try to re-invent a content management system like FileNet in the DB.
Yeah, better to instead deal with the overhead of the database combined with the overhead of the filesystem! Referential integrity is also very easy to deal with.
I work at a place that has been trying to undo the damage of having serialized BLOBs for about 3 years. Granted, these are especially nasty things with a custom serialization layer written in Java.
Software companies consist of two assets produced by it's employees: data and algorithms to make the data useful.
Why would you ever lock your data down and make it harder to make cool algorithms to make the data useful?
Stop right there. There are plenty of examples for storing blobs in a datastore - images and videos are 2 prime examples.
I think what you should say is in a SQL database. Google's AppEngine with their datastore makes it dead easy and with high performance to store&retrieve things like images and videos.