Hello - See these example with explanation:
Atomicity
Definition: The atomicity property identifies that the transaction is atomic. An atomic transaction is either fully completed, or is not begun at all. An example of an atomic transaction is updating an employee record by updating the salary,
in between the the process, the system goes down so when it comes back again you should see the original value for the salary for that employee
Example:
-- Start the Transaction in First Query Session
BEGIN TRANSACTION
UPDATE Employee SET Salary = 20000 WHERE EmpID = 1
-- In other query session, simulate failure
-- By shutdown no wait
SHUTDOWN WITH NOWAIT
-- Now again start the SQL Server Service and Query, you will realize no updates happened
SELECT * FROM Employee
Consistency
A transaction enforces consistency in the system state by ensuring that at the end of any transaction the system is in a valid state. If the transaction completes successfully, then all changes to the system will have been properly made, and the system will
be in a valid state. If any error occurs in a transaction, then any changes already made will be automatically rolled back. This will return the system to its state before the transaction was started. Since the system was in a consistent state when the transaction
was started, it will once again be in a consistent state.
Example:
-- First Query Session
BEGIN TRANSACTION
UPDATE Employee SET Salary = 20000 WHERE EmpID = 1
-- Inserting entry into TransactionRecords Table about the
-- Do not execute this
INSERT INTO TransactionRecords SELECT 1, 20000, '2015-06-19'
-- Second Query Session
SHUTDOWN WITH NOWAIT
In the above example, we updated the salary & the next thing to be done was making an entry in TransactionRecords table about salary update but before that we simulated the failure by issuing shutdown, so when services are restored again we should old
consistent value for the salary instead of 20,000
Isolation
When a transaction runs in isolation, it appears to be the only action that the system is carrying out at one time. If there are two transactions that are both performing the same function and are running at the same time, transaction isolation will ensure
that each transaction thinks it has exclusive use of the system.
-- First Query Session
BEGIN TRANSACTION
UPDATE Employee SET Salary = 20000 WHERE EmpID = 1
-- Second Query Session
BEGIN TRANSACTION
-- This will be prohibited (BLOCKED) because other session is making change to this data
UPDATE Employee SET Salary = 30000 WHERE EmpID = 1
-- However this will be allowed because this transaction is updating different row
UPDATE Employee SET Salary = 20000 WHERE EmpID = 2
Durability
A transaction is durable in that once it has been successfully completed, all of the changes it made to the system are permanent. There are safeguards that will prevent the loss of information, even in the case of system failure. By logging the steps that the
transaction performs, the state of the system can be recreated even if the hardware itself has failed.
Example: First example can be considered for this explanation
Hope this helps !