Showing posts with label DataBase Basics. Show all posts
Showing posts with label DataBase Basics. Show all posts

ACID properties

ACID (atomicity, consistency, isolation, durability) is a set of properties that guarantee database transactions are processed reliably

Atomicity

Atomicity requires that database modifications must follow an "all or nothing" rule. Each transaction is said to be atomic if when one part of the transaction fails, the entire transaction fails and database state is left unchanged. It is critical that the database management system maintains the atomic nature of transactions in spite of any application, DBMS (Database Management System), operating system or hardware failure.

An atomic transaction cannot be subdivided, and must be processed in its entirety or not at all. Atomicity means that users do not have to worry about the effect of incomplete transactions.

Transactions can fail for several kinds of reasons:


  • Hardware failure: A disk drive fails, preventing some of the transaction's database changes from taking effect
  • System failure: The user loses their connection to the application before providing all necessary information
  • Database failure: E.g., the database runs out of room to hold additional data
  • Application failure: The application attempts to post data that violates a rule that the database itself enforces, such as attempting to insert a duplicate value in a column.

Eg:

An example of an atomic transaction is an account transfer transaction. The money is removed from account A then placed into account B. If the system fails after removing the money from account A, then the transaction processing system will put the money back into account A, thus returning the system to its original state. This is known as a rollback

Consistancy


The consistency property ensures that the database remains in a consistent state; more precisely, it says that any transaction will take the database from one consistent state to another consistent state.Looking again at the account transfer system, the system is consistent if the total of all accounts is constant. If an error occurs and the money is removed from account A and not added to account B, then the total in all accounts would have changed. The system would no longer be consistent. By rolling back the removal from account A, the total will again be what it should be, and the system back in a consistent state.



The consistency property does not say how the DBMS should handle an inconsistency other than ensure the database is clean at the end of the transaction. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction could be rolled back to the pre-transactional state - or it would be equally valid for the DBMS to take some patch-up action to get the database in a consistent state. Thus, if the database schema says that a particular field is for holding integer numbers, the DBMS could decide to reject attempts to put fractional values there, or it could round the supplied values to the nearest whole number: both options maintain consistency.



Isolation


The isolation portion of the ACID properties is needed when there are concurrent transactions. Concurrent transactions are transactions that occur at the same time, such as shared multiple users accessing shared objects. This situation is illustrated at the top of the figure as activities occurring over time. The safeguards used by a DBMS to prevent conflicts between concurrent transactions are a concept referred to as isolation.



As an example, if two people are updating the same catalog item, it's not acceptable for one person's changes to be "clobbered" when the second person saves a different set of changes. Both users should be able to work in isolation, working as though he or she is the only user. Each set of changes must be isolated from those of the other users.


isolation


An important concept to understanding isolation through transactions is serializability. Transactions are serializable when the effect on the database is the same whether the transactions are executed in serial order or in an interleaved fashion. As you can see at the top of the figure, Transactions 1 through Transaction 3 are executing concurrently over time. The effect on the DBMS is that the transactions may execute in serial order based on consistency and isolation requirements. If you look at the bottom of the figure, you can see several ways in which these transactions may execute. It is important to note that a serialized execution does not imply the first transactions will automatically be the ones that will terminate before other transactions in the serial order.



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. The concept of durability allows the developer to know that a completed transaction is a permanent part of the system, regardless of what happens to the system later on.Durability refers to the ability of the system to recover committed transaction updates if either the system or the storage media fails.

Features to consider for durability:

  • recovery to the most recent successful commit after a database software failure
  • recovery to the most recent successful commit after an application software failure
  • recovery to the most recent successful commit after a CPU failure
  • recovery to the most recent successful backup after a disk failure
  • recovery to the most recent successful commit after a data disk failure

Database Management System

What is DBMS?


  • A DBMS is a system software package that helps the use of integrated collection of data records and files known as databases. It allows different user application programs to easily access the same database.
  • Data base management system is the system in which related data is stored in an "efficient" and "compact" manner. Efficient means that the data which is stored in the DBMS is accessed in very quick time and compact means that the data which is stored in DBMS covers very less space in computer's memory. In above definition the phrase "related data" is used which means that the data which is stored in DBMS is about some particular topic.



Components of DBMS


Database Management System



Transaction Management

  • A transaction is a sequence of database operations that represents a logical unit of work and that accesses a database and transforms it from one state to another.
  • A transition can update a record, delete (or) modify a set of records etc.

Concurrency control

Concurrency control is the database management activity of co-ordinating the actions of database manipulating process that separate concurrently that access shared data and can potentially interfere with one another.

Recovery Management

The recovery management system in a database ensures that the aborted or failed transactions create non adverse effect on the database or the other transitions.

Security Management

Security refers to the protection of data against unauthorized access. Security mechanism of a DBMS make sure that only authorized users are given access to the data in the database

Language Interface

The DBMS provides support languages used for the definition and manipulation of data in the database. The data structures are created using the data definition language commands. The data manipulation is done using the data manipulation commands.

Storage Management

The DBMS provides a mechanism for management of permanent storage of the data. The internal schema defines how the data should be stored by the storage management mechanism and this storage manager interface with the operating system to access the physical storage.

Data Catalog Management

Data catalog or Data Dictionary is a system database that contains descriptions of the data in the database (metadata). If contains information about data, relationships, constraints and the entire schema that organize these features in to a unified database.


Need For DBMS

  • Data independence and efficient access.
  • Reduced application development time.
  • Data integrity and security.
  • Uniform data administration.
  • Concurrent access, recovery from crashes.

Introduction To DatabaseManagementSystem


A database consists of four elements as given



  1. Data

  2. Relationship

  3. Schema

  4. Constraints



Introduction To DatabaseManagementSystem



Data

  • Data are binary computer representations of stored logical entities.
  • Software is divided into two general categories-data and programs
  • A program is a collection of instruction for manipulating data
  • Data exist is various forms- as numbers tents on pieces of paper,as bits and bytes stored in electronic memory or as facts stored in a persons mind


Relationship


  • Relationships explain the correspondence between various data elements

Constraints


  • Are predicates that define correct database states




Scheme


  • Schema describes the organization of data and relationships within the database
  • Schema defines various views of the database for the use of various system components of the database management system and for the application’s security
  • A schema separates physical aspects of data storage form the logical aspects of data representation
  • In database management systems data files are the files that store the database information whereas offer files, such as index files and data dictionaries, store administrative information known as metadata.

  • Data base are organized by fields, records and files.
  1. Fields: is a single piece of information.

  2. Record: is one complete set of fields.

  3. File: is a collection of records


Types of schema

  1. Internal schema: defines how and where the data are
    organized in physical data storage.

  2. Conceptual schema: defines the stored data structures in
    terms of the database model used.

  3. External schema: defines a view (or) views of the database
    for particular uses

Template by - Mathew | Mux99