NoSQL Flashcards
What is NoSQL?
NoSQL databases are non-tabular databases and store data differently than relational tables. Basically databases that store data in a format other than relational tables.
- Non-Relational
- Mostly JSON files
- Dynamic Schema
- Horizontal Scalability
- No JOINS
- Not recommended for OLTP
What is the CAP and Brewer Theorem?
CAP Theorem states that within a large-scale data system, there are three requirements that have a relationship of sliding dependency.
- Consistency: All clients will read the same value for the same query
- Availability: All clients will always be able to read and write data
- Partition Tolerance: The database can be split into multiple machines.
Brewer’s theorem says that you can strongly support only two of the three.
What are some NoSQL databases and which requirements do they apply to, for the CAP theorem?
Availability & Partition Tolerance
- Dynamo
- Cassandra
Availability & Consistency
- RDBMS (MySQL, PostgressDB)
Consistency & Partition Tolerance
- BigTable
- MongoDB
- Redis
NoSQL DB Types
Document Databases (MongoDB): Designed for storing, retrieving and managing semi-structured data.
Column Based Databases (BigTable, HBase): Stores data tables as columns rather than rows.
Key/Value Databases (Dynamo, Redis): Similar to a dictionary or a hash
What are the advantages of NoSQL over traditional RDBMS?
It supports semi-structured data and it does not enforce a schema.
Read/Write throughput is very high and horizontal scalability can be achieved easily.
Define ACID properties
Atomicity: It ensures that either all operations succeed or fall together.
Consistency: It ensures that changes made within a transaction are consistent with database constraints.
Isolation: It ensures that concurrent transactions do not affect each other’s outcomes.
Durability: Data is not lost even at the time of server failure
These ACID properties ensure that a set of database operations (grouped together in a transaction) leave the database in a valid state even in the event of unexpected errors.
For reference and a nice explanation: https://www.mongodb.com/basics/acid-transactions
Is MongoDB ACID-compliant?
It has always been compliant at the document level. Not until 2018 has it started allowing multiple-document updates (transactions).
Remember that transactions allows you to group a set of database read and write operations so that it only succeeds if all the operations within succeed.
What is the difference between Document-Oriented and Key-Value in NoSQL Databases?
A key-value store provides the simplest possible data model. It’s a storage system that stores values indexed by a key.This allows very fast read and write operations.
A document-oriented extends the previous model and values are stored in a structured format (document) but still uses key/value pairs.
What is the difference between Column-oriented vs Document-oriented NoSQL databases?
The main difference is how the data is physically stored. With column-types, data is stored by columns which can enable efficient aggregation operations / queries on a particular columns. With document-types, the entire document is logically stored in one place and it is generally retrieved as a whole (no efficient aggregation possible on columns/fields)
What are Indexes in MongoDB?
They support the efficient execution of queries. Without them, MondoDB must perform a collection scan (scan every document in a collection, to select those documents that match the query statement. With an index, MongoDB can limit the number of documents it must inspect.
They are special data structures that store a small portion of the collection’s data set in an easy to traverse form.