Audio blog of document based databases
Before
moving into document based databases let me make it clear what is a
relational database as i doubt many people won’t be clear with it.
Relational database:
Relations between two tables in the form of foreign key is not the
reason why a database is called relational database. A table is itself a
relation. It has a specified number of attributes or fields and each
record abides to this fixed schema. Each tuple is related to each other
because of the defined attributes. This is why a database like mysql is
called relational database.Primary key , foreign key are nothing but
constraints that user can create in a relational database.
Hope you can understand what i mean. Next let's look at another type of database which is not relational.
Document based database:
It is not relational. So obviously it doesn’t have a fixed schema and
tuples of same table may be unrelated. Unrelated in the sense each may
have different number of attributes or different types of attributes.
So what is document based?? Let me explain. In general a non relational database model is called as nosql.
As
the name suggests you cannot use sql for querying information from
nosql databases. They are used to store huge amount of data which do not
need a relational model of storage.For example, facebook uses nosql for storing user messages and searching it efficiently.
nosql databases are classified based on how they store data,
- Key-value stores
- Big table implementation
- Document based
- Graph
These
are different types of nosql database. I think there are no well
defined differences between the above classifications. Key-value store
is how data gets stored in Big table as well as Document based
databases. Difference is that Big table is a google proprietary storage
used in Google File System(GFS). Read about Big table and Gfs more...
Google has developed them for their own use and they are very
interesting.
So let’s now come back to Document based database. Here database has only documents. Documents are like tables. Here data is stored in some encoded form like JSON, BSON etc...
JSON-
Javascript object notation. It's a way of storing text(just like xml).
However it is more readable , easily parsable than xml. It uses
javascript object kind of format. So instead of using some parser a
javascript program can parse JSON and convert them into objects easily
using eval() function.
In document based databases records are stored as key-value pair. For example a consider a person’s record , it is stored as ,
{
firstname:”raj” lastname:”kumar” devices: [{type:”mobile”
model:”samsung” number: “9988776655”},{type:”laptop” model:”apple”}] }
here firstname is the key and raj is value. devices is an array which inturn has objects with keys type , model etc...
Notable points:
- There is no fixed schema
- Each record can be considered as object stored something like hash(key value pairs)
- Each tuple may have different number of attributes and an attribute may inturn be an array of objects.
- When a tuple doesn’t contain an attribute which is present in previous tuple no NULL values are stored. In other words space allocated only for attributes mentioned.
- Since adding a new record is just writing into a document writes are extremely fast.
- So for an application which has huge amount of data to be maintained, relational model is not needed and ACID properties are relaxed, nosql would be very helpful !!
- However for applications where security is of high priority nosql should not be used since it doesn’t provide transaction safe processing.
Examples of document based databases are mongoDB,couchDB...
Posted by teera at 6:02 AM
ReplyDeletedude... u ended the day with this blog or started with it ?
ended ! y ?
ReplyDelete