Database Reference
In-Depth Information
MongodB offers durability when used in tandem with at least three servers,
which is the recommended minimum for production deployments. It is possible to make the
primary replica member wait for one or more of the secondary members to confirm receipt
of the data before the primary itself confirms that the data has been accepted.
Note
JSON and MongoDB
JSON (Java Script Object Notation) is more than a great way to exchange data; it's also a
nice way to store data. An RDBMS is highly structured, with multiple files (tables) that
store the individual pieces. MongoDB, on the other hand, stores everything together in a
single document. MongoDB is like JSON in this way, and this model provides a rich and
expressive way of storing data. Moreover, JSON effectively describes all the content in a
given document, so there is no need to specify the structure of the document in advance.
JSON is effectively schemaless (that is, it doesn't require a schema), because documents
can be updated individually or changed independently of any other documents. As an
added bonus, JSON also provides excellent performance by keeping all of the related data
in one place.
MongoDB doesn't actually use JSON to store the data; rather, it uses an open data
format developed by the MongoDB team called BSON (pronounced Bee-Son), which is
short for binary JSON. For the most part, using BSON instead of JSON won't change how
you work with your data. BSON makes MongoDB even faster by making it much easier for
a computer to process and search documents. BSON also adds a couple of features that
aren't available in standard JSON, including the ability to add types for handling binary
data. We'll look at BSON in more depth in “Using Document-Oriented Storage (BSON),”
later in this chapter.
The original specification for JSON can be found in RFC 4627, and it was written by
Douglas Crockford. JSON allows complex data structures to be represented in a simple,
human-readable text format that is generally considered to be much easier to read and
understand than XML. Like XML, JSON was envisaged as a way to exchange data between
a web client (such as a browser) and web applications. When combined with the rich way
that it can describe objects, its simplicity has made it the exchange format of choice for
the majority of developers.
You might wonder what is meant here by complex data structures . Historically, data
was exchanged using the comma-separated values (CSV) format (indeed, this approach
remains very common today). CSV is a simple text format that separates rows with a new
line and fields with a comma. For example, a CSV file might look like this:
Membrey, Peter, +852 1234 5678
Thielen, Wouter, +81 1234 5678
 
 
Search WWH ::




Custom Search