MongoDB, Redis, BSON, JSON and etc.

The network communication and disk storage of data in MongoDB is based on BSON.

BSON (binary JSON) is a binary-encoded serialization of JSON-like documents.

JSON (JavaScript Objective Notation) is a lightweighted data-interchange format.

JSON is built on two structures:
– object: a collection of unsorted name/value pairs, and
– arry: an ordered list of values,
where each value could be either of the following:
– object
– array
– string
– number
– true/false/null

BSON is comparable with Protocol Buffers, where BSON is schema-less
and thus flexible, but has the overhead for field names in the serialized data.

document := int32 e_list ”
elist := a list of element
element := e_type e_name value

Note: compared with JSON, there is only “object”, but no “array”, in BSON.

The C++ implementation of BSON is provided by MongoDB:

Both BSON and MongoDB have Go API.

MongoDB v.s. Redis v.s. memcachedb v.s. Berkeley DB

Redis, memcachedb and Berkeley DB manage key-value pairs. MongoDB is
more powerful and support geo-indexing.

Redis and memcachedb run as services, but Berkeley DB, as a library,
runs in the client process space.