I always used to wonder why we need NoSQL database in first place like most of the developers who have worked on SQL. As I started exploring it, the thing that struck me most is NoSQL's "Dynamic Schema".
In Relational databases, you need to define schemas before you can add data. Structure and data types are fixed in advance. For example, you define a customer table with first name, last name and phone number. Now if you want to store customer address and his/her favorites then you'll have to add new columns to the table. Each time you add a new feature in your application, the schema of your database changes. If the database is large, this is a very slow process and involves significant downtime.
NoSQL databases are built to store data without a predefined schema. This makes it easy to make significant application changes in real-time. So in NoSQL database, dissimilar data of customer and product can be stored together, if necessary. There's also no way, using a relational database, to effectively address unstructured or unknown data.
NoSQL databases have provided a solution for dealing with modern scaling and data format challenges. NoSQL is not a replacement for SQL databases, but it is a valid alternative for a lot of situations where standard SQL is not the best approach to store your data.
Selecting the right database for your application is important. Following should be your parameters to decide one database type over another:
- Manage structured or unstructured data
- To scale or perform beyond the capabilities of your existing system
- Affordable alternatives or expensive proprietary software
- Need for speed and agility of development