Data Independence and ACID Properties
In addition to the data entered by users, a database system typically holds a large amount of data.
For example, It holds metadata about data to make it easier to find and retrieve data.
Once a set of metadata has been saved in a database, changing or updating it is challenging.
However, as a database management system (DBMS) grows, it must evolve to meet the needs of its users. If all of the data is dependent, it will be time-consuming and challenging.
Metadata has a tiered structure so that changing data at one level does not affect data at another.
This information is self-contained. However, it is linked to one another.
The ACID properties, which are four properties stated in the database management system, are used to maintain data integrity.
The ACID qualities are intended for transactions that go through a series of tasks, and it is here that the role of the ACID characteristics is shown.
Data independence is known as the ability to change the schema at one level of the database system without affecting the schema at the next higher level.
It allows users to access the data in the database in various ways.
Data independence can be divided into two categories:
Logical Data Independence
Logical data is database data, which means that it stores information about how data is managed within the database.
- The ability to update the conceptual schema without changing data is called logical data independence.
- It is used to distinguish the external level from the conceptual view.
- Any modifications to the conceptual representation of the data will not affect the user’s view of the data.
- Logical data independence arises at the user interface level.
For example, consider a database table (relation) and all of the constraints that apply to it.
Logical data independence is a method that decouples itself from the actual data on the disc.
If we make modifications to the table format, the data on the disc should not be affected.
Physical Data Independence
All of the schemas are logical, and the data is saved on the disc in bit format.
The ability to update physical data without affecting the schema or logical data is known as physical data independence.
- The database's conceptual structure will not be altered if the storage size of the database system server is changed.
- Separating conceptual and internal levels is accomplished by physical data independence.
- Physical data independence occurs at the level of the logical interface.
For example, if we wish to update or upgrade the storage system itself (for example, by replacing hard drives with SSDs), it should not affect the logical data or schemas.
Transaction: Transactions combine several tasks into a single unit of execution. Each transaction starts with a single task and finishes when all of the tasks in the group have been completed successfully. The transaction fails if any of the tasks fails.
As a result, a transaction can only end in one of two ways: success or failure.
A transaction is a very short piece of software containing numerous low-level tasks.
In order to assure correctness, completeness, and data integrity, a transaction in a database system must maintain the ACID properties: Atomicity, Consistency, Isolation, and Durability.
The term atomicity refers to the fact that the data is kept atomic.
It indicates that if any action on the data is conducted, it should either be performed or executed entirely.
This means that transactions are not carried out in phases but rather as a single entity that is either finished or not carried out at all.
It comprises the two processes listed below.
—> Abort: If a transaction aborts, any database modifications are lost.
—> Commit The modifications made by a transaction become apparent when it commits.
Atomicity is often known as the ’all or nothing rule.'
Example: Consider the T1 and T2 transactions:
A 1000 transfer from account A to account B has been made.
If a transaction fails after T1 but before T2 (for example, after write(A) but before write(B)), the amount is deducted from A but not added to B.
As a result, the database is in a state of inconsistency.
As a result, to ensure that the database state is legitimate, the transaction must be completed in its entirety.
To guarantee that the database is consistent, integrity constraints must be maintained before and after the transaction.
It relates to the accuracy of a database.
As seen in the example above, the total amount must be kept before and after the transaction.
Before T, the total is 5000 + 2000 = 7000.
After T, the total is 4000+ 3000 = 7000.
As a result, the database is well-organized.
There is inconsistency when T1 succeeds, but T2 fails, T is no longer present.
The phrase 'isolation' refers to a state of separation.
Isolation in DBMS refers to the property of a database where no data from one database should impact the other and where many transactions can take place simultaneously.
In other words, when the operation on the first database is finished, the process on the second database should begin.
It indicates that if two actions are conducted on two distinct databases, the value of one database may not be affected by the value of the other.
When two or more transactions occur simultaneously in the case of transactions, consistency should be maintained.
Any modifications made in one transaction will not be visible to other transactions until the change is committed to the memory.
Let's say A=5000 and B=5000.
Consider the following two transactions: T and T."
Assume T has been run until Read (B); at this point, T" begins.
As a result of this interleaving, T" reads the correct value of A but the incorrect value of B and the sum computed by
T": (A+B = 500, 000+5000=500, 5000) is inconsistent with the sum at the end of the transaction:
T: (A+B = 500,000 + 4500 = 500, 4500).
This results in a database inconsistency due to the loss of 500 units.
As a result, transactions must be carried out in isolation, and modifications should be seen only after they have been written to the main memory.
This attribute ensures that after a transaction has completed execution, the database updates and modifications are saved and written to disk and that they persist even if the system fails.
These modifications are now saved in non-volatile memory and are permanent.
As a result, the transaction's effects are never lost.
- Which data independence is easiest?
Physical data independence is simple to achieve. The user can change the physical storage structures or devices that affect the conceptual schema with this level of independence.
- Is data independence useful for the database? Why?
Data Independence is a DBMS attribute that allows you to alter the Database schema at one level of a database system without updating it at the next higher level.
Data independence allows you to keep information independent from the applications that use it.
- How do ACID properties affect transactions?
In order to assure correctness, completeness, and data integrity, a transaction in a database system must preserve the ACID properties: Atomicity, Consistency, Isolation, and Durability.
- What is the significance of ACID properties for a database?
The ACID properties, taken together, provide a mechanism for ensuring the correctness and consistency of a database in such a way that each transaction is a group of operations that acts as a single unit, produces consistent results, is isolated from other operations, and the updates it makes are durably stored.
- Cheers if you reached here!! In this blog, we learned about Data Independence in Databases.
- We have covered the basic idea of Data Independence in DBMS.
- We have also seen the need for data independence.
- Further, we saw the types of data independence.
- We have also witnessed the ACID properties, their uses with examples.
Check out the Top 100 SQL Problems to get hands-on experience with frequently asked interview questions and land your dream job.
On the other hand, learning never ceases, and there is always more to learn. So, keep learning and keep growing, ninjas!!
Good luck with your preparation!!