Академический Документы
Профессиональный Документы
Культура Документы
Data are very important in any information system. So we must have a very good way of managing such data. The DBMS contain a query language that makes it possible to give quick and exact answers to adhoc queries. The DBMS helps to create an environment in which users have better access to data. Such access makes it possible for end users to respond more quickly and efficiently to changes in their environment. DBMS helps to give an integrated view of the organizations operations. Thus it becomes much easier to see how operations in one unit affect others. Data inconsistency is considerably reduced in a properly designed database. Database systems are designed to manage large volume of information. Data management involves both defining the structure for storage of information and providing mechanism for the manipulation of data. Also the database system must ensure the safety of the information stored. The DBMS makes it possible to share the data in the database among multiple applications and users. DBMS serves as the intermediary between the database and the user by translating user request to the database and getting back exact responses to the user. Also the DBMS hides the internal complexities from the application programs that use the database.
Data Independence
A major purpose of a database system is to provide the users with an abstract view of data. To hide the complexity from users database apply different levels of abstraction. The following are different levels of abstraction. Physical Level Logical Level View Level Physical Level Physical Level is the lowest level of abstraction and it defines the storage structure. The physical level describes complex low level data structures in detail. The database system hides many of the lowest level storage details from the database programmers. Database Administrators may be aware of certain details of physical organization of data. Logical Level This is the next higher level of abstraction which describes what data are stored in database, relation between data, types of data etc. Database programmers, DBA etc knows the logical structure of data View Level This the highest level of abstraction. It provides different view to different users. At the view level users see a set of application programs that hide details of data types. The details such as data type etc are not available at this level. Only view or Access is given to a part of data according to the users access right Physical Data Independence The changes in Physical Level does not affect or visible at the logical level. This is called physical data independence. Logical Data Independence The changes in the logical level do not affect the view level. This is called logical data independence.
Candidate Keys Candidate Keys are super keys for which no proper subset is a super key. In other words candidate keys are minimal super keys. Primary Key It is a candidate key that is chosen by the database designer to identify entities with in an entity set. Primary key is the minimal super keys. In the ER diagram primary key is represented by underlining the primary key attribute. Ideally a primary key is composed of only a single attribute. But it is possible to have a primary key composed of more than one attribute. Composite Key Composite key consists of more than one attributes. Example: Consider a Relation or Table R1. Let A, B, C, D, E are the attributes of this relation. R(A,B,C,D,E) ABCDE This means the attribute 'A' uniquely determines the other attributes B,C,D,E. BCADE This means the attributes 'BC' jointly determines all the other attributes A, D, E in the relation. Primary Key: A Candidate Keys: A, BC Super Keys: A, BC, ABC, AD ABC and AD are not Candidate Keys since both are not minimal super keys.
Normalization
Normalization is the process of decomposing a relation(table) based on functional dependency and primary key. Un-Normalized Form First Normal Form (1 NF) Second Normal Form (2 NF) Third Normal Form (3 NF) Boyce Codd Normal Form (BCNF) Un-Normalized Form (0NF) Un-Normalized relation contains non atomic values. Each row may contain multiple set of values for some of the columns. These multiple values in a single row are called non atomic value.
First Normal Form A Relation is said to be in 1NF if the values in the domain of each attribute of relation are atomic. Each cell of the table must have single value. No two rows in a table may be identical. Second Normal Form A relation R is said to be in 2NF if it is in 1NF and there should not be any partial dependency. Here all the non key attributes are dependent on the key alone. No attribute is dependent upon a part of the key. Any relation having a key with single attribute is in 2NF. Third Normal Form A relation R is in 3NF if it is in 2NF and has no transitive dependency. Here all the non-key attributes are dependent on the key alone. There should not be any dependency among the non-key attributes. Boyce-Codd Normal Form (BCNF) A relation R is in BCNF if every determinant is a candidate key. Problem with BCNF: Given a relation R, Functional Dependency F, BCNF may or may not preserve all given functional dependencies.
Transaction
The term transaction refers to a collection of operation that forms a single logical unit of work. A transaction T is a logical unit of database processing that includes one or more database access operation. Transaction Properties: ACID Properties Atomicity Consistency Isolation Durability Atomicity A transaction must be atomic. That is, it ensure that either all operations of the transactions are reflected properly in the database or none should Consistency If the database is in a consistent state before the execution of the transaction, the database remains consistent after the execution of the transaction. Example: Transaction T1 transfers $100 from Account A to Account B. Both Account A and Account B contains $500 each before the transaction. Transaction T1 Read (A) A=A-100 Write (A) Read (B) B=B+10 Consistency Constraint Before Transaction execution Sum = A + B Sum = 500 + 500 Sum = 1000 After Transaction execution Sum = A + B Sum = 400 + 600 Sum = 1000 Before the execution of transaction and after the execution of transaction SUM must be equal. Isolation When multiple transactions are executing concurrently, then each transaction is unaware of other transactions executing concurrently in the system. Ie the execution of one transaction must not interfere with another. Durability Changes applied to a database by a committed transaction must be made permanent even if the system fails.