What is a Blob?

From InterBase
Jump to: navigation, search

Go Up to Working with Blob Data

A Blob is an object that cannot easily be stored in a database as one of the standard data types. You can use a Blob to store large amounts of data of various types, including:

  • Bitmapped images
  • Sounds
  • Video segments
  • Text

InterBase support of Blob data provides all the advantages of a database management system, including transaction control, maintenance, and access using standard API function calls. Blob data is stored in the database itself. Other systems only store pointers in the database to non-database files. InterBase stores the actual Blob data in the database, and establishes a unique identification handle in the appropriate table to point to the database location of the Blob. By maintaining the Blob data within the database, InterBase greatly improves access to and management of the data.


How is Blob Data Stored

Blob is the InterBase data type that can represent various objects, such as bitmapped images, sound, video, and text. Before you store these items in the database, you create or manage them as platform- or product-specific files or data structures, such as:

  • TIFF, PICT, BMP, WMF, GEM, TARGA or other bitmapped or vector-graphic files
  • MIDI or WAV sound files
  • Audio Video Interleaved Format (.AVI) or QuickTime video files
  • ASCII, MIF, DOC, WPx or other text files
  • CAD files

You must programmatically load these files from memory into the database, as you do any other data items or records you intend to store in InterBase. For more information about creating a Blob and storing data into it, see Writing Data to a Blob.


Blob Subtypes (API Guide)

Although you manage Blob data in ways similar to other data types, InterBase provides more flexible data typing rules for Blob data. Because there are many native data types that you can define as Blob data, InterBase treats them generically and allows you to define your own data type, known as a subtype. InterBase also provides two predefined subtypes: 0, an unstructured subtype generally applied to binary data or data of an indeterminate type, and 1, applied to plain text.

User-defined subtypes must always be represented as negative integers between –1 and –32,678.

A subtype of a Blob column is specified when the Blob column is defined.

The application is responsible for ensuring that data stored in a Blob column agrees with its subtype; InterBase does not check the type or format of Blob data.


Blob Database Storage

Rather than storing Blob data directly in the Blob field of a table record, InterBase stores a Blob ID there. A Blob ID is a unique numeric value that references Blob data. The Blob data is stored elsewhere in the database, in a series of Blob segments, units of Blob data read and written in chunks. Blob segments can be of varying length. The length of an individual segment is specified when it is written.

Segments are handy when working with data that is too large for one application memory buffer. But it is not necessary to use multiple segments; you can put all your Blob data in a single segment.

When an application creates a Blob, it must write data to it a segment at a time. When an application reads a Blob, it reads a segment at a time. For more information about writing segments, see Writing Data to a Blob. For more information about reading segments, see Reading Data from a Blob.

Advance To: