1.

What is the notion of schema-less in MongoDB?

Answer»

In MONGODB data is stored as JSON documents. These documents can have different sets of fields, with different data type for each field. For example, we can have a collection with number, varchar and array all as different documents.

         { “a” : 143 }          { “name” : “john” }          { “x” : [1,2,3] }

It is not correct to say MongoDB is schemaless, in fact, schema plays an important role in the designing of MongoDB applications. MongoDB has a dynamic schema having database structure with collections and indexes. These collections can be created either implicitly or explicitly.

Due to the dynamic behaviour of the schema, MongoDB has several advantages over RDBMS systems.

Schema Migrations BECOME very easy as in traditional systems we had to use ALTER TABLE command after adding any column which could result in downtime. In MongoDB, such adjustments become transparent and automatic. For example, if we want to add CITY field to PEOPLE collection, we can add the attribute and resave, that’s it. Whereas in a traditional system we would have to run ALTER TABLE command FOLLOWED by REORG which would require downtime.



Discussion

No Comment Found