Pages

Friday, November 9, 2012

Practical alternatives to storing BLOB data in the database (MSQL 7+)

Figuring out where to store images, PDFs, and other documents is a major architectural decision. While storing these BLOBs in your database may make it easier to search, secure, and manage them, it isn't always practical from a performance standpoint. Luckily, if you decide not to store BLOBs in the database, you have a number of different alternatives to choose from:

Generate documents programmatically.
You can store data as text (or XML) in the database, and then have your application generate various document formats (RTF, PDF, etc.) from the data. From a purist perspective, this is often the best approach as it avoids duplication of data and provides for compact storage and maximal flexibility.

Store paths in the database.
You can refer to your document in the database by storing its path in a text column. In this manner, your application can use the database to search whether a document exists (based on criteria in other database columns), and then it can load the document using the supplied path.

Database-less solution.
Finally, we need to recognize that there are some situations where the database isn’t needed. If you devise some sort of standardized naming convention for files and directories, your application may be able to find them without requiring a database search. Simple directory searching (such as using the FileSystemObject in .NET) may be sufficient for your application’s needs.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.