Diving into Databases…
Databases are an organized collection of data stored and accessed electronically from a computer system and there are many types of databases such as Cloud database, Relational database, Object-oriented database, NoSQL database and more! Depending on the type, structure, data model, data store, and intended use-case of your data, different systems are likely to be better suited to your needs. In this blog we will focus on two major categories of Databases SQL and NoSQL.
What is even SQL? It stands for Structured Query Language and is the standard language for Relational Databases (RDBMS). A relational database defines relationships in the form of tables. SQL programming can be effectively used to insert, search, update, delete database records. SQL uses syntax and queries to analyze and get the data. Some examples of Relational databases are MySQL Database, Postgres, Oracle, Ms SQL Server, Sybase, etc.
NoSQL is a non-relational database or distributed database. NoSQL database is used for distributed data stores with very LARGE data storage needs (best for big data and real time web applications). A NoSQL database system encompasses a wide range of database technologies that can store structured, semi-structured, unstructured and polymorphic data. NoSQL databases can be document based, key-value pairs, graph databases and some examples are MongoDB, Redis, Neo4j, Cassandra, and Hbase.
Let’s get into the major differences between the two…
- Query Language: NoSQL has no declarative query language while SQL is a structured query language.
- Schema: NoSQL databases use dynamic schema for unstructured data and SQL databases have a predefined schema.
- Ability to Scale: NoSQL databases are horizontally scalable and SQL databases are vertically scalable.
- Variations: NoSQL has many different types which include key-value stores, document databases, and graph databases. While SQL has one type with minor variations.
- Best Used For: NoSQL is a best used for solving data availability problems and RDBMS database is the right option for solving ACID (Atomicity, Consistency, Isolation, and Durability) problems.
- Best Features: SQL has cross-platform support as well as being secure and free. NoSQL is easy to use, has high performance, and is a flexible tool.
- Top Companies Using: SQL- Hootsuite, CircleCI, Gauges. NoSQL- Airbnb, Uber, Kickstarter.
One other difference is the model that both databases use. SQL uses the ACID which is a standard for RDBMS and BASE is used in many noSQL systems. An ACID model provides a consistent system while BASE provides high availability.
ACID stands for:
- Atomicity — The database transaction must completely succeed or completely fail. Partial success is not allowed.
- Consistency — During the database transaction, the RDBMS progresses from one valid state to another. The state is never invalid.
- Isolation — Transactions cannot compromise the integrity of other transactions by interacting with them while they are still in progress. They must occur in isolation from other clients.
- Durability — The data related to the completed transaction will persist even in the cases of network or power outages. If a transaction fails, it will not impact the manipulated data.
BASE stands for:
- Basically Available — The system is guaranteed to be available for querying by all users. (No isolation here)
- Soft State — Due to the lack of immediate consistency, data values may change over time. The BASE model breaks off with the concept of a database which enforces its own consistency, delegating that responsibility to developers.
- Eventually Consistent — The fact that BASE does not enforce immediate consistency does not mean that it never achieves it. However, until it does, data reads are still possible (even though they might not reflect the reality).
There are many strengths to each database type and depending on the company you work for (as well as the data you are working with) one type may suite your programming needs over the other!
Thanks for reading and connect with me via LinkedIn!