Normalization Why Normalize? Ideally, a relational database table should be designed in such a way as to exclude the possibility of update, insertion, and deletion anomalies. The normal forms of relational database theory provide guidelines for deciding whether a particular design will be vulnerable to such anomalies. It is possible to correct an unnormalized design so as to make it adhere to the demands of the normal forms: this is called normalization. A table that is not sufficiently normalized can suffer from logical inconsistencies of various types, and from anomalies involving data operations causing Update, Insert and Delete Anomalies .
First/Second/Third Normal Form FIRST NORMAL FORM (1NF) A table with a unique key and without any nullable columns is in 1NF. SECOND NORMAL FORM(2NF) A 1 NF table with where every candidate key has only one attribute. THIRD NORMAL FORM(3NF) A 2 NF table where every non-prime attribute of the table must be non-transitively dependent on every candidate key
A database transaction is a unit of interaction with a database management system or similar system that is treated in a coherent and reliable way independent of other transactions. In general, a database transaction must be atomic, meaning that it must be either entirely completed or aborted. Ideally, a database system will guarantee the properties of Atomicity, Consistency, Isolation and Durability (ACID) for each transaction.
A Simple Transaction
Begin the transaction
Execute several queries
Commit the transaction
ACID In computer science, ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties that guarantee that database transactions are processed reliably. In the context of databases, a single logical operation on the data is called a transaction. Atomicity - Atomicity refers to the ability of the DBMS to guarantee that either all of the tasks of a transaction are performed or none of them are. Consistency - Consistency refers to the database being in a legal state when the transaction begins and when it ends. This means that a transaction cannot break the rules, or integrity constraints, of the database . Isolation - Isolation refers to the ability of the application to make operations in a transaction appear isolated from all other operations Durability -Durability ensures that the results of a completed transaction are permanent and can survive future system and media failures; that is, once they are done, they can not be undone.
Concurrency Control Concurrency control in database management systems (DBMS) ensures that database transactions are performed concurrently without the concurrency violating the data integrity of a database. Concurrency Control • Optimistic - Delay the synchronization for a transaction until its end without blocking (read, write) operations, and then abort transactions that violate desired synchronization rules. • Pessimistic - Block operations of transaction that would cause violation of synchronization rules.
Locks A Lock is a database system object associated with a database object (typically a data item) that prevents undesired (typically synchronization rule violating) operations of other transactions by blocking them. Database system operations check for lock existence, and halt when noticing a lock type that is intended to block them.Concurrency control in database management systems (DBMS) ensures that database transactions are performed concurrently without the concurrency violating the data integrity of a database.
Rollback & Rollforward Rollback Undoing the changes made by a transaction before it commits or to cancel any changes to a database made during the current transaction RollForward Re-doing the changes made by a transaction after it commits or to overwrite the changed value again to ensure consistency
Database design is the process of producing a detailed data model of a database. This logical data model contains all the needed logical and physical design choices and physical storage parameters needed to generate a design in a Data Definition Language , which can then be used to create a database. A fully attributed data model contains detailed attributes for each entity.
Determine the data to be stored in the database
Determine the relationships between the different data elements
Superimpose a logical structure upon the data on the basis of these relationships.
Logical/Physical design A Logical Schema is a data model of a specific problem domain that is in terms of a particular data management technology. Without being specific to a particular database management product, it is in terms of either relational tables and columns, object-oriented classes, or XML tags. A Physical Data Model is a representation of a data design which takes into account the facilities and constraints of a given database management system. In the lifecycle of a project it is typically derived from a logical data model. A complete physical data model will include all the database artifacts required to create relationships between tables or achieve performance goals, such as indexes, constraint definitions, linking tables, partitioned tables or clusters
Database Objects A Database Trigger is procedural code that is automatically executed in response to certain events on a particular table in a database. Triggers can restrict access to specific data, perform logging, or audit data modifications. A Database View is a virtual or logical table composed of the result set of a query. Unlike ordinary tables (base tables) in a relational database, a view is not part of the physical schema: it is a dynamic, virtual table computed or collated from data in the database. Changing the data in a table alters the data shown in the view In relational databases, SQL databases, and flat file databases, a Table is a set of data elements (values) that is organized using a model of horizontal rows and vertical columns.
In database packages, the term Cursor refers to a control structure for the successive traversal (and potential processing) of records in a result set. A Transaction Log (also database log or binary log) is a history of actions executed by a database management system to guarantee ACID properties over crashes or hardware failures. Physically, a log is a file of updates done to the database, stored in stable storage. A Database Index is a data structure that improves the speed of operations in a table. Indexes can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records. A Stored Procedure is a subroutine available to applications accessing a relational database system. Stored procedures (sometimes called a sproc or SP) are actually stored in the database. Database Objects