-I;Berkeley DB Reference Guide: Simple Tutorial[P5

Berkeley DB Reference Guide: Simple Tutorial



$

Key/data pairs



EBerkeley DB uses key/data pairs to identify elements in the database.HThat is, in the general case, whenever you call a Berkeley DB interface,Cyou present a key to identify the key/data pair on which you intend to operate.

0For example, you might store the key/data pairs:

FIn each case, the first element of the pair is the key, and the second is the data.

GTo store the first of these key data pairs into the database, you wouldLcall the Berkeley DB interface to store items, with fruit as the key,Band apple as the data. At some future time, you could thenHretrieve the data item associated with fruit, and the Berkeley DB5retrieval interface would return apple to you.

HWhile there are many variations and some subtleties, all accesses3to data in Berkeley DB come down to key/data pairs.

7Both key and data items are stored in simple structures(called DBTs) that containBa reference to memory and a length, counted in bytes. The key andBdata items can be arbitrary binary data of practically any length.

OAPÿÿ