Sunteți pe pagina 1din 5

ACID properties of databases

Description of the properties


ACID stands for

• Atomicity
• Consistency
• Isolation
• Durablity

Atomicity

states that database modifications must follow an “all or nothing” rule. Each transaction
is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. It is
critical that the database management system maintain the atomic nature of transactions
in spite of any DBMS, operating system or hardware failure.

Consistency
It states that only valid data will be written to the database. If, for some reason, a
transaction is executed that violates the database’s consistency rules, the entire
transaction will be rolled back and the database will be restored to a state consistent with
those rules. On the other hand, if a transaction successfully executes, it will take the
database from one state that is consistent with the rules to another state that is also
consistent with the rules.

Isolation

It requires that multiple transactions occurring at the same time not impact each other’s
execution or One transaction does not interfere with another. The 'executor' of a
transaction has the feeling that he has the entire database for himeself.

Durablity

A commited(Saved) transaction will not be lost. Durability is ensured through the use of
database backups and transaction logs that facilitate the restoration of committed
transactions in spite of any subsequent software or hardware failures.

normalization helps us to elimate redundant data and to store the data we have in a
manner that makes sense.
Normalization:

Database normalization can essentially be defined as the practice of optimizing table


structures. Normalization helps us to elimate redundant data and to store the data we have
in a manner that makes sense. Atomicity also must be maintained in tables via
normalization. Normalization helps us to create atomic tables by removing redundant
data within rows of a table, thus creating atomic tables.

Denormalized Data

Let’s take a look at some denormalized data. I’m going to use the simplest example that
comes to mind, and that is a auto repair shop that specializes in domestic automobiles
(domestic to the USA, that is). Our table lists automobile manufactuers and the makes of
automobiles they manufactuer that the shop services.

Fig. 1
Manufactuer Make 1 Make 2 Make 3
Ford Mercury Lincoln Ford
GM Chevrolet Pontiac Saturn, Buick
Chrysler Dodge
Normal Forms:

First Normal Form (1NF)

We want to take fig. 1 and normalize it a bit. Before we can do that, we need to know
what the rules of 1NF are. There are 2 rules to 1NF.

• Remove duplicate columns.


• Each column by row position must have a unique value.

As you can see, 1NF is already enforcing the atomic nature of a table. So first we need to
remove duplicate columns from the table, at the same time creating column by row
positions that have unique values, which means we also have to seperate Saturn, Buick
into individual values.

Fig. 2
Manufactuer Make
Ford Mercury
Ford Lincoln
Ford Ford
GM Chevrolet
GM Pontiac
GM Saturn
GM Buick
Chrysler Dodge

Second Normal Form (2NF)

For each level of normal form, the next level must adhere to the rules of the previous
level, in addition to adding its own rules. This means in order to create a data structure
that meets the requirements of 2NF, we must first meet the requirements of 1NF. We
have already discussed the rules for 1NF, so let’s look at the rules required to meet 2NF.

• Remove duplicate data in a single column and place the data in seperate tables.
• Create relationships between the sets of data.

Manufactuer Table
ManufactuerId Manufactuer
1 Ford
2 GM
3 Chrysler

Make table
Manufactuer Make
1 Mercury
1 Lincoln
1 Ford
2 Chevrolet
2 Pontiac
2 Saturn
2 Buick
3 Dodge

Fig. 4

Third Normal Form (3NF)

Again, in order to meet the rules of 3NF, we must first meet the rules of 1NF and 2NF. In
addition to meeting these requirements, 3NF introduces 1 other rule:

• All columns that are not dependent on the primary key must be removed.

Sounds simple enough. First, lets take our Make table from Fig. 3 and add a column to it
that shows how much the auto repair shop charges per hour for each different make, and
also a column that shows if the shop works on cars or trucks for each particular make.

Make table
Manufactuer Make Charge Style
1 Mercury $60 Cars
1 Lincoln $60 Cars
1 Ford $75 Trucks
2 Chevrolet $55 Both
2 Pontiac $60 Cars
2 Saturn $60 Cars
2 Buick $60 Cars
3 Dodge $75 Trucks

The Final Data( In 3rd normal Form)

Manufactuer Table
ManufactuerId (PK) Manufactuer
1 Ford
2 GM
3 Chrysler

Make table
MakeId (PK) Manufactuer (FK) Make Style (FK)
1 1 Mercury 1
2 1 Lincoln 1
3 1 Ford 2
4 2 Chevrolet 3
5 2 Pontiac 1
6 2 Saturn 1
7 2 Buick 1
8 3 Dodge 2

Style Table
StyleId (PK) Style Charge
1 Cars $60
2 Trucks $75
3 Both $55

S-ar putea să vă placă și