Wednesday, July 13, 2011

Intro to document-oriented databases

In this post I will explain the basics and advantages of the document-oriented databases over relational dbs.

Document database is a database constructed of documents that has its own structure and can be independent from each other i.e there is no need of relations like in RDBMS.  There are no tables, rows, relations at all. So when I want to add new field in the database I simply select a document and add it without the need to update and affect other documents in the db.

DO databases are called semi-structured dbs because they don't have the need of a predefined schema like in RDBMS.

For example if I have one document that have these fields: name, surname, proffession, phone, I can create document by filling all fields except the phone field which can be empty and it will not be kept as null but it will simply do not exist. But I can also add new field which is not in the above list for example email and give it a value of my email.

Below is a list of the advantages over RDBMS:

Objects are stored as documents. So now we can use the serialize method in a language to convert object to a document and save it to the db.
- Documents can be of any complexity. Objects model can be read and written at once. NICEEEEEEE :)
In this case we are relieved of the need to think of complex sql statements and stored procs.
Documents are all the way independent. This is good for performance and the side effects of concurrency are decreased
- Formats for accessing and using DO dbs. The documents in the dbs are described with JSON, XML and derivatives like Binary JSON
- Schema free. This ability gives us flexibilty to sturcture the data inside without the need to restructure it again after some time.
Built-in verisoning. DO databases can support versioning of documents and it can be done with several clicks

The DO dbs can be sorted in these categories Document, Graph, Key/Value, and Tabular/Wide Column.
 All of them with its own advantages and drawbacks.

The most popular products that declare themselves as DO dbs are:

- CouchDB
- RavenDB
- MongoDB

So where these dbs would best fit in? Well DO dbs are good for CMS and CRM systems where the user usually wants to customize his data and this is easy with saving documents. Also DO dbs would be useful in creating and storing data from a shopping cart and user sessions.

In the next posts I will try to explain briefly the above given products and their properties.

1 comment:

  1. I’m seriously happy to discover this great site the future of this blog is getting good and more useful for me thanks and god bless you.....
    Argumentative essay

    ReplyDelete