What the Heck Are Document Databases?
Related Data in a Single Record
A lot of people incorrectly presume that nonrelational databases are flat files. The documents stored in a document database are capable of containing shaped data: trees with nodes. Each record in the database is a document and can be an autonomous set of data. It’s self-describing—including its possibly unique schema—and isn’t necessarily dependent on any other document.
Following is a typical example of what a record might look like in a document database (I’ll steal a sample from the MongoDB tutorial that represents a student):
{ "name" : "Jim", "scores" : [ 75, 99, 87.2 ] }And here’s one from the CouchDB introductory article, which describes a book:
{ "Subject": "I like Plankton" "Author": "Rusty" "PostedDate": "5/23/2006" "Tags": ["plankton", "baseball", "decisions"] "Body": "I decided today that I don't like baseball. I like plankton." }These are simple structures with string data, numbers and arrays. You can also embed objects within objects for a more complex document structure, such as this blog post example:
{ "BlogPostTitle”: “LINQ Queries and RavenDB”, "Date":"\/Date(1266953391687+0200)\/", "Content":”Querying RavenDB is very familiar for .NET developers who are already using LINQ for other purposes”, "Comments":[ { "CommentorName":"Julie", "Date":"\/Date(1266952919510+0200)\/", "Text":"Thanks for using something I already know how to work with!", "UserId":"users/203907" }, ] }