Constraints in Database

Data Integrity:
 The fundamental function of the DBMS is to maintain the integrity of the data.
 Data integrity ensures that the data in the database is consistent, accurate, correct, and
 It ascertains that the data adhere to the set of rules defined by the database
administrator and hence, prevent the entry of invalid information into the database.
Entity Integrity:
 The entity integrity constraint states that no primary key (nor any part of the primary
key) value can be null.
 This is because the primary key value is used to identify individual rows in a table.
 Having a null value for the primary key implies that we cannot identify some rows.
 This also specifies that there may not be any duplicate entries in the primary key column.
Referential Integrity:
 The referential integrity constraint is specified between two tables and is used to
maintain the consistency among rows in the two tables.
 Informally, the referential integrity constraint states that a row in one table that refers
to another table must refer to an existing row in that table.
 It is a rule that maintains consistency among the rows of the two tables.
Domain Integrity:
 A domain represents a set of values that can be assigned to an attribute.
 A domain integrity constraint is specified on the column of a table, so that correct values can be entered in the column for each record.
 The domain integrity states that every element from a relation should respect the type and restrictions of its corresponding attribute.
 Assertions are general-purpose checks that allow the enforcement of any condition over the entire database.
 When an assertion is made, the system tests it for validity and tests it again on every update that may violate the assertion.
 This testing may introduce a significant amount of overhead; hence assertions should be used with great care.
 A trigger is a procedure that is automatically invoked by the DBMS in response to
specified changes to the database.
 A database that has a set of associated triggers is called an active database.
 Triggers are useful mechanisms for alerting humans or for starting certain tasks
automatically when certain conditions are met.
 Trigger follows the Event-Condition-Action Scheme (ECA Scheme).
 To design a trigger mechanism, we must meet the following three requirements:
o Event: A change to the database that activates the trigger.
o Condition: Trigger performs some action only if a specified condition matches at the occurrence of the event.
o Action: A procedure that is executed when the trigger is activated and its condition is true.

Enjoy and Download Video
Watch Video

Post a Comment