Javatpoint Logo
Javatpoint Logo

Consistency in DBMS


Consistency in database systems refers to the need that any given database transaction only change affected data in allowed ways.Data written to a database must be legitimate according to all stated rules, including constraints, cascades, triggers, or any combination, for the database to be consistent.

Consistency also implies that any changes made to a single object in one table must be mirrored in all other tables in which that object appears. Continuing with the driver's license example, if the new driver's home address changes, the change must be shown in all tables where the previous address previously existed. Data inconsistency occurs when one table has the old address, and the others have the updated address.

Consistency does not ensure transactional correctness in all ways that an application programmer may expect (that is the responsibility of application-level code). Instead, consistency ensures that programming errors do not violate established database constraints.

Importance of Consistency in DBMS

Consistent data is what keeps a database running like clockwork. Established rules/values keep inconsistent data out of primary databases and replicas, allowing its processes to run smoothly.

  • Accuracy
  • Increased database space
  • Faster and more efficient data retrieval

Database consistency governs every data that enters. So, while the database changes when new data is added, it does so consistently and in accordance with the validation rules that were specified at the start. In today's environment, billion-dollar judgments are made every day all around the world based on the apparent consistency of a database.

When real-time information becomes the new norm for modern-day digital organizations, it's vital that validation methods are put in place to keep datasets free of erroneous data, as this adds delay and makes real-time experiences less real.

Strong Consistency vs Weak Consistency

  • Strong consistency implies that all data in a primary replica and all relevant nodes conform to the validation rules and are the same at all times. With robust database consistency, no matter which client accesses the data, they will always see the most recently updated data that adheres to the database's standards.
  • Weak consistency is reminiscent of the untamed Wild West. There is no guarantee that the data in your primary, replica or node will always be the same. One client in India may gain access to the data and view information that matches the validation rules but is not the most recently updated data, causing consistency difficulties. They may be acting on information that is no longer relevant, despite the fact that it was formerly.

What's the Distinction between ACID and BASE Database Consistency?

Relational databases that provide strong consistency provide 'ACID guarantees' in general. ACID is an abbreviation that stands for the basic characteristics of a highly consistent database.

Relational databases that provide strong consistency provide 'ACID guarantees' in general. ACID is an abbreviation that stands for the basic characteristics of a highly consistent database.

  • Atomicity: If any component of the transaction fails, the complete transaction is reverted.
  • Consistency: With each transaction, the database's structural integrity is maintained.
  • Isolation: Each transaction is distinct from the others.
  • Durability: All transaction outcomes are saved indefinitely.

ACID compliance is a complicated and much-discussed topic. In essence, it denotes the straightforward promise that a READ will deliver the outcome of the most recent successful WRITE. While this may appear to be a straightforward assurance, it is quite difficult to implement in a globally distributed database structure with numerous clusters, each having many nodes.

As a result, ACID-compliant databases are typically prohibitively expensive and difficult to scale.

Because SQL databases are all ACID compliant to varied degrees, they all have the same drawbacks. It should be noted that some RDBMS systems allow ACID guarantees to be weakened in order to mitigate these drawbacks. Creating durable, distributed SQL database deployments may be extremely complex and costly.

As a result, ACID-compatible databases are typically utilized for financial transactions that require accurate recording.

Unlike SQL, which provides ACID guarantees, NoSQL databases provide BASE guarantees.

Basic Availability: Even when the system is partially down, data is available most of the time.

Soft state: Replicas are not always accurate.

Eventual Consistency: Data will become constant at some point in time, but when it is unknown.

  • In order to boost availability, NoSQL databases compromise some consistency. Rather than providing robust consistency, NoSQL databases provide eventual consistency.
  • In order to boost availability, NoSQL databases compromise some consistency. Rather than providing robust consistency, NoSQL databases provide eventual consistency.
  • There is a chance that certain transactions will overlap in a globally distributed NoSQL database implementation. In the typical example, a NoSQL database may allow two different customers, one in Hong Kong and the other in New York City, to reserve a hotel room on the same night.
  • Many corporate applications do not have this issue. The sacrifice for NoSQL's robustness, availability, and reduced latency is definitely worth it. A dissatisfied customer can be reimbursed, but a regional interruption could result in a significant turnover.

What is the Difference between ACID and BASE Database Consistency?

The CAP Theorem captures another interpretation of Database Consistency. The CAP theorem, first suggested by Eric Brewer, asserts that a distributed data store cannot provide more than two of the three requirements listed below at the same time:

Consistency: All identical queries receive the same response.

Availability: Requests are responded to even when the system is partially down.

Partition Tolerance: Operations continue to run even when some nodes are down.

Any data store, according to the CAP theorem, comes with a trade-off. The key distinction between relational and non-relational data stores is the trade-off between availability and consistency. (Partition tolerance is sometimes regarded as a need for achieving a compromise that allows for eventual consistency and improved scalability)

Does ScyllaDB offer Database Consistency Solutions?

ScyllaDB, like most non-relational databases, uses an "eventual consistency" approach. Eventual consistency serves the continuously expanding number of modern workloads that rely primarily on availability and are less reliant on robust consistency assurances. For example, it is often better for an isolated data center to continue accepting reads and writes during partitioning caused by an outage.

ScyllaDB's consistency is adjustable; users can specify how consistent their transactions should be. Here are two such examples:

Consistency Levels

Consistency levels are another set of preconditioned variables that specify how many replicas or nodes must react with the new permitted data before the transaction is recognized as valid. This operation can be modified per transaction. So, for example, a programmer can specify that just two nodes must read newly input data before recognizing data consistency. Once it crosses that threshold, it is deemed consistent data.

  • Isolation levels:
    The ACID (Atomicity, Consistency, Isolation, Durability) features of a database include isolation levels. ACID is a fundamental concept of SQL database consistency that certain databases adhere to in order to maximize database consistency. One of ACID's qualities is isolation, which separates certain pieces of data from the rest of the information in a database network, preventing it from being affected by other user transactions. Isolation is used to limit reads and writes of insignificant data created by concurrent transactions.
  • There are Four Types of Isolation Levels:
    1. Read Uncommitted: The lowest level. Row updates are halted if a prior transaction made an uncommitted update to that row.
    2. Read Committed: This prevents "dirty reads." If a transaction has already been changed but has not yet been committed, this prevents any further reads or writes.
    3. Repeatable Read: This level prevents the read row from being viewed and potentially modified.
    4. Serializable: The most severe level of isolation, serializable often locks a complete database rather than a single row of data.


While ScyllaDB prioritises availability above consistency, it also provides an API for enhanced consistency that makes use of lightweight transactions (LWTs). LWTs allow database administrators to match database consistency behaviour to the needs of various workloads.

Lightweight transactions consist of a single conditional statement that allows for an atomic "compare and set" operation. Before performing a transaction, such an operation checks to see if a condition is true. The transaction is not executed if the condition is not met. (This is why LWTs are frequently referred to as 'conditional statements')

Instead of using locks, LWTs use the Raft consensus mechanism to ensure that all nodes in the cluster agree on the change that has been committed. ScyllaDB can thus provide sufficient consistency for applications that also require high availability, predictable low latency, and resilience.

Next TopicDependency in DBMS

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA