Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does being schema-less mean for a NoSQL Database?

Tags:

schema

nosql

Schemaless is a term that is currently floating around in the NoSql world.

  1. What does this mean ?
  2. I have a document with 3 properties today and I move to production with it, then what happens to my data when I need to add 2 more properties to my document?
  3. Is this purely a migrations problem where I need to manage my data migration or can a NoSql database create as much friction as a RDBMS or make it easier in someway ?
like image 213
ashutosh raina Avatar asked Mar 23 '13 16:03

ashutosh raina


People also ask

What is schema less in NoSQL?

As a NoSQL database, MongoDB is considered schemaless because it does not require a rigid, pre-defined schema like a relational database. The database management system (DBMS) enforces a partial schema as data is written, explicitly listing collections and indexes.

What does it mean to be schema less?

A schemaless database manages information without the need for a blueprint. The onset of building a schemaless database doesn't rely on conforming to certain fields, tables, or data model structures. There is no Relational Database Management System (RDBMS) to enforce any specific kind of structure.

Do NoSQL databases require schema?

Does NoSQL have a schema? NoSQL databases do not have a schema in the same rigid way that relational databases have a schema. Each of the four main types of NoSQL database has an underlying structure that is used to store the data.

Why do we use schema when MongoDB is a schema less database Are there any benefits to having a schema for different collections?

MongoDB pushes schema concerns up to your application level, where you can handle them more flexibly. For example, in order to add a new field to your documents, you don't need to do an all-or-nothing ALTER on your collection—potentially millions of entries.


1 Answers

Schema-less is a bit of a misnomer, it's better to think of it as:

  • SQL = Schema enforced by a RDBMS on Write
  • NoSQL = Partial Schema enforced by the DBMS on Write, PLUS schema fully enforced by the Application on Read (Externalised schema)

So while a supposed Schema-less NoSQL data-store will in theory allow you to store any data you like (typically key value pairs, in a document) without prior knowledge of the keys, or data types, it will be pointless unless you have some mechanism to retrieve and use the data. So essentially the schema is partially moved from the RDBMS into the application code. I say partially as you'll have added Indexes to document collections and or partitioned the data for performance, so the NoSQL DBMS will have a partial schema defined locally, and possibly enforced via Unique constraints.

As to adding additional attributes to a document/object in the store. Depending on how much padding is around the document (un-used space), in its physical data block, adding a few more key value pairs to the documents may result in the document having to be physically moved to a larger contiguous block of storage, and the associated indexes re-built. If you plan to use the new keys in a frequently utilised query then you'll be wanting to also add a suitable new index, which will obviously require some physical storage, take a while to initially build and possibly lead you to ask the sysadmin to allocate more memory to the DBMS, to allow the new index(s) to be cached.

like image 105
arober11 Avatar answered Sep 23 '22 22:09

arober11