Database Flashcards

1
Q

Data sharding?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Type of primary keys?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

CAP theorim

A

Consistency

Consistency means that all clients see the same data at the same time, no matter which node they connect to. For this to happen, whenever data is written to one node, it must be instantly forwarded or replicated to all the other nodes in the system before the write is deemed ‘successful.’

Availability

Availability means that any client making a request for data gets a response, even if one or more nodes are down. Another way to state this—all working nodes in the distributed system return a valid response for any request, without exception.

Partition tolerance

A partition is a communications break within a distributed system—a lost or temporarily delayed connection between two nodes. Partition tolerance means that the cluster must continue to work despite any number of communication breakdowns between nodes in the system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Type of Nosql databases

A

CP database: A CP database delivers consistency and partition tolerance at the expense of availability. When a partition occurs between any two nodes, the system has to shut down the non-consistent node (i.e., make it unavailable) until the partition is resolved. MongoDB

AP database: An AP database delivers availability and partition tolerance at the expense of consistency. When a partition occurs, all nodes remain available but those at the wrong end of a partition might return an older version of data than others. (When the partition is resolved, the AP databases typically resync the nodes to repair all inconsistencies in the system.) Casandra, DynamoDB, might not always provide strong consistency

CA database: A CA database delivers consistency and availability across all nodes. It can’t do this if there is a partition between any two nodes in the system, however, and therefore can’t deliver fault tolerance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Types of NoSQL Databases

A

Key-value Pair Based
Column-oriented Graph
Graphs based
Document-oriented

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When Would You Want to Use NoSQL over SQL?

A

The pace of development with NoSQL databases can be much faster than with a SQL database.
The structure of many different forms of data is more easily handled and evolved with a NoSQL database.
NoSQL databases are often better suited to storing and modeling structured, semi-structured, and unstructured data in one database.
The amount of data in many applications cannot be served affordably by a SQL database.
The scale of traffic and the need for zero downtime cannot be handled by SQL.
The scalability of NoSQL databases allows one database to serve both transactional and analytical workloads from the same database.
NoSQL databases often have superior integration with real-time streaming technologies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the Advantages of NoSQL?

A

Can be used as Primary or Analytic Data Source
Big Data Capability
No Single Point of Failure
Easy Replication
No Need for Separate Caching Layer
It provides fast performance and horizontal scalability.
Can handle structured, semi-structured, and unstructured data with equal effect
Object-oriented programming which is easy to use and flexible
NoSQL databases don’t need a dedicated high-performance server
Support Key Developer Languages and Platforms
Simple to implement than using RDBMS
It can serve as the primary data source for online applications.
Handles big data which manages data velocity, variety, volume, and complexity
Excels at distributed database and multi-data center operations
Eliminates the need for a specific caching layer to store data
Offers a flexible schema design that can easily be altered without downtime or service disruption

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When should we use a NoSQL database instead of a SQL Database (relational database)?

A

A relational database enforces ACID. So, you will have schema-based transaction-oriented data stores. It’s proven and suitable for 99% of real-world applications. You can practically do anything with relational databases. But, there are limitations on speed and scaling when it comes to massive high availability data stores.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do I choose between NoSQL and relational databases?

A

NoSQL is more flexible for inserting data when you can’t predict the structure of your data. But it makes it harder to run optimized queries later. That is, you can design NoSQL to optimize for one type of query, but it makes it less optimal for all other types of queries. Also you are inevitably forced to write a lot of code in your application to support business rules with the more fluid structure of data.

RDBMS is more flexible for queries when you can’t predict the types of queries you will need to run in your app. But it requires you use a schema, and data you insert must match that schema strictly. There’s no limit to the powerful SQL queries you can create, but some people find it confusing to write queries in such a powerful language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly