Assertions in DBMS
Assertions are logical conditions or predicates that are specified to the database and are expected to be true at all times. They are used to enforce business rules or other conditions on the data in the database. Assertions are typically defined using a declarative language such as SQL and are checked by the DBMS to ensure that they are always true. If an assertion is violated, it indicates a data integrity issue.
Example:The number of employees with a salary greater than 0 is equal to the total number of employees in the "Employees" table. If this condition is ever false, it means there is a violation of the assertion.
It's important to note that not all database management systems support assertions, and their usage can depend on the specific DBMS being used.
Triggers in DBMS:
Triggers are special types of stored procedures that are automatically executed (or "triggered") in response to specific events in the database. These events could include insertions, updates, or deletions of data. Triggers are used to enforce complex business rules, maintain data integrity, or log changes to the database.
There are two main types of triggers: