I need help to figure out how to store the document in the database.
The DB storage needs to be a BLOB (or the equivalent) since you want to
store an arbitrary number of types of 'things' of presumably arbitrary
size. There is a resource out there on the web, somewhere (if I could
recall where, the link would be yours, but I seem to recall muddling
through it with attachment_fu, so you might want to check those
I did that personally as a proof of concept in my app about a year ago,
but found the DB storage and retrieval much, much too slow as compared
to the file system.