Basic Concepts of Blobs

Blobs (Binary Large Objects) are, essentially, large amounts of any kind of data being written to a Zim database. The meaning of the word "large" is that this data can range from zero bytes to many megabytes in length, usually binary data like an image, a document of any kind (for instance, a Word document), a spreadsheet, a music, etc. It can also a Zim program. In essence, the source of the data to be stored in a blob field is normally an operating system file (for example: photo1.jpg, report.doc, etc.) that should be read and then converted to a blob. Conversely, the data from a blob field is retrieved so that it can be stored back to an operating system file and the presented on screen, for instance.

The maximum size of a blob is only determined by the size of the memory at the moment the blob is being processed.

Since blobs are binary data and their sizes can be very big, they cannot be accommodated in normal Zim fields nor they are operated in the same way, like the allowed operations over blobs, importing and exporting blobs, etc. As a consequence, it is always a good idea to separate a Zim entity set that holds a blob from all other entity sets. For example, pictures from customers can be kept in an entity set and the data from these customers maintained in another entity set. When needed, they can be associated via a relationship.

A blob field defined in a Zim database has the type "blob", but its size is ignored by Zim. Also, a blob field cannot be a virtual field. Even though it can be indexed, it does not actually make much sense doing it because the result of the index is always the size of blob.

Any entity sets or relationships with fields can have a blob, but only one blob at a time.

A blob record comprises two parts:

1) The record describing the blob. All usual database operations (ADD, DELETE, sets, etc.) work exactly in the same way as with any other information type;

2) The blob itself which can be the stored blob information or a $Null reference (in which case nothing is stored). Operations can only be performed via assignments or using the special function $FromBlob;

The following sections discuss all the details needed in order to properly operate with blobs.