Consistency
Hi! To explore how the database enforces rules that maintain valid data states, particularly ensuring that account balances never become negative. first create a table account, CREATE TABLE account...

Source: DEV Community
Hi! To explore how the database enforces rules that maintain valid data states, particularly ensuring that account balances never become negative. first create a table account, CREATE TABLE accounts (id SERIAL PRIMARY KEY,name TEXT NOT NULL,balance INT NOT NULL CHECK (balance >= 0),last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP); the table contains atributes id as primary key,name,balance hee check for condition as if balance >=0,last_updated here set default value as current timestamp. Next,insert values to the table. INSERT INTO accounts (name, balance) VALUES ('Alice', 1000),('Bob', 500); Attempt to perform operations that violate deducting more money than is available in an account or directly updating a balance to a negative value. UPDATE accounts SET balance = balance - 1200 WHERE name = 'Alice'; IT WILL THROW ERROER as attempting to deduct 1200 from Alice who only has 1000. In PostgreSQL,the failure occurs due to Constraints because if the deduction occour with balance l