Background:
We have an in house document storage system that was implemented long ago. For whatever reason, using the database as the storage mechanism for the documents was chosen.
My question is this:
What is the best practice for storing documents? What are the alternatives? What are the pros and cons? Answers do not have to be technology or platform specific, it is more of a general best practice question.
My Thoughts:
Databases are not meant for document storage. File Systems or 3rd party Document Management systems may be of better use. Document Storage in Databases is expensive. Operations are slow. Are these logic assumptions? Perhaps this is best, but in my mind, we have better alternatives. Could oracle BFILE's (links to document on NAS or SAN) be better than BLOB / CLOB?
Details:
UPDATE (from questions below):
Your best bet with storing important documents is a safe deposit box. Most banks or credit unions offer safe deposit boxes. Some banks will offer a discount if you're a current customer as well.
Database storage structure All the information in a database is organized and structured in database tables. These tables are stored on the hard disk of the database server.
Since the dawn of time, database vendors have called out to developers, “Store everything inside the database. You know you want to. Here, we'll make it easy for you by adding data types like binary and features like filestream.”
Based on my experience I'd say keep them in the database. We've moved two of our systems to doing this.
Putting it in the database means:
We had documents out of the database. It becomes a problem with lots of documents. A normal directory in Linux is one block, which is usually 4K. We had a directory that was 58MB because it had so many files in it (it was just a flat directory, no hierarchy). It had that many indirect blocks. It took over an hour to delete. It took minutes to get a count of the number of files in the directory. It was abysmal. This is on ext3.
With the filesystem you need:
It's really a pain. For any non-trivial number of documents, I'd recommend against the file system based on what I've seen.
I prefer to store the document in the file system and then store a link to the file and associated file meta-data in the database.
It has proven more convenient, easier to maintain, and less expensive than the alternative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With