I am working with a MySQL Database and I need to store rich text and images in HTML format. I need to store the images in Blobs due to convenience an organization and I was wondering if it is possible to store a small document made out of text and multiple images in a single Blob.
Share
If you have some method of signifying where the breaks between files are, yes. You’d simply look up the location of the divisors and do a substring on the blob field to get the relevant chunk of data.
But that’s a very poor design – DB fields should contain a SINGLE value only, even if it’s a binary blob. If you need to store multiple files, then use a child table and store each file in its own child record.
Consider how painful it’d be to “delete” one of those files from the middle of the record. With a child table, it’s a simple matter of deleting the record. With the all-in-one field, you have to do an update with multiple substring extractions: