CAP theorem and NoSQL databases Flashcards
Which ACID property correspond to the following affirmation: “ensures that concurrent execution of transactions leaves the database in the same state that would have been obtained if the transactions were executed sequentially”
a) atomicity
b) consistency
c) isolation
d) durability
c)
SQL vs NoSQL databases. Which statement is true?
a) MongoDB is a well-know relational database
b) NoSQL databases are easier to scale horizontally than relational databases
c) Relational databases are easier to scale horizontally than NoSQL
d) NoSQL databases are the best choice if we want to ensure data consistency
b)
What are transactions?
Transactions are a collection of actions that make consistent transformations of system states while preserving consistency.
Which ACID property correspond to the following affirmation: “when we do something to change a database, the change should work or fail as a whole”
a) atomicity
b) consistency
c) isolation
d) durability
a)
Which ACID property correspond to the following affirmation: “any given database transaction must change affected data only in allowed way”
a) atomicity
b) consistency
c) isolation
d) durability
b)
Which ACID property correspond to the following affirmation: “how/when the changes made by one operation become visible to other”
a) atomicity
b) consistency
c) isolation
d) durability
c)
Which ACID property correspond to the following affirmation: “guarantees that transactions that have committed will survive permanently”
a) atomicity
b) consistency
c) isolation
d) durability
d)
What is atomicity?
Atomicity: transactions are often composed of multiple statements. Atomicity guarantees that each transaction is treated as a single “unit”, which either succeeds completely, or fails completely: if any of the statements constituting a transaction fails to complete, the entire transaction fails and the database is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors and crashes.
When we do something to change a database, the change should work or fail as a whole.
What is consistency?
Consistency: ensures that a transaction can only bring the database from one valid state to another, maintaining database invariants: any data written to the database must be valid according to all defined rules, including constraints, cascades, triggers, and any combination thereof. This prevents database corruption by an illegal transaction, but does not guarantee that a transaction is correct.
Any given database transaction must change affected data only in allowed ways.
What is isolation?
Isolation: transactions are often executed concurrently (e.g. reading and writing to multiple tables at the same time). Isolation ensures that concurrent execution transactions leaves the database in the same state that would have been obtained if the transactions were executed sequentially. Isolation is the main goal of concurrency control; depending on the method used, the effects of an incomplete transaction might not even be visible to other transactions.
Isolation defines how/when the changes made by one operation become visible to other.
What is durability?
Durability guarantees that once a transaction has been committed, it will remain committed even in the case of a system failure (e.g. power outage or crash). This usually means that completed transactions (or their effects) are recorded in a non-volatile memory.
Durability guarantees that transactions that have committed will survive permanently
characteristics of relational database management systems (RDBMSs):
- Are ACID compliant
- RDBMSs put a lot of emphasis on keeping data consistent.
- They require a formal database schema.
- New data or modifications are not accepted unless they comply with this schema in terms of data type, referential integrity, etc
What are the disadvantages of RDBMSs?
- May induce overhead and hampers scalability and flexibility.
- RDBMS cannot handle ‘data variety’ (all types of data under a unified schema of tables).
- Addition of a new functionality would need all the elements to support the new structure. Change is inevitable.
What is the difference between vertical and horizontal scaling?
- Vertical scaling: extending storage capacity and/or CPU power of the database server (RDBMSs/SQL).
- Horizontal scaling: multiple DBMS servers being arranged in a cluster (NoSQL). It needs to be tolerant to partition failures.
What are the characteristics of NoSQL databases?
- They store and manipulate data in formats other than tabular relations, i.e. non-relational databases.
- NoSQL databases aim at near-linear horizontal scalability by distributing data over a cluster of database nodes for the sake of performance and availability.
- Eventual consistency: the data (and its replicas) will become consistent at some point in time after each transaction.
NoSQL databases are suitable for critical transactions as in a bank system. True or false
False, as they are not ACID compliant.