FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Consistency
How-ToProgramming Languages

Consistency

via Dev.to PythonAshiq Omar2h ago

Let’s understand how a database keeps data valid using an accounts table. Assume the table has a rule like: balance ≥ 0 This is a constraint which means the database wont allow any negative balance. Initial data Alice = 1000 Bob = 500 Trying to break the rule now suppose we try to deduct more money than Alice actually has UPDATE accounts SET balance = balance - 2000 WHERE name = 'Alice' ; Alice only has 1000 so this would make her balance -1000 which violates the constraint. Result: The database throws an error and rejects the update. Directly setting a negative value UPDATE accounts SET balance = - 500 WHERE name = 'Bob' ; Again this violates the rule. Result: The database blocks the query with an error. Checking the data again SELECT * FROM accounts; Alice = 1000 Bob = 500 invalid operations were rejected the data remains unchanged. Inside a transaction Now lets try the same invalid update within a transaction: BEGIN ; UPDATE accounts SET balance = balance - 2000 WHERE name = 'Alice'

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
2 views

Related Articles

Blog 15: SDLC Phase 4 — Testing
How-To

Blog 15: SDLC Phase 4 — Testing

Medium Programming • 2h ago

Before We Write a Single Data Structure, We Need to Talk
How-To

Before We Write a Single Data Structure, We Need to Talk

Medium Programming • 3h ago

How-To

How to implement the Outbox pattern in Go and Postgres

Lobsters • 4h ago

The Hidden Algorithm Behind Google Maps Traffic!!!!
How-To

The Hidden Algorithm Behind Google Maps Traffic!!!!

Medium Programming • 4h ago

Percentage Change: The Most Misused Metric in Data Analysis (And How to Calculate It Correctly)
How-To

Percentage Change: The Most Misused Metric in Data Analysis (And How to Calculate It Correctly)

Medium Programming • 9h ago

Discover More Articles