SQL - BusinessRuleConstraints - Page8
👉Business Rule Constraint
So far, we have learned the first category i.e. I/O Constraints, and 3 types of I/O Constraints - Primary key, Foreign Key and Unique Key.
Now, let's take a look at the second category i.e Business Rule Constraint.
Business Managers determine business rules, and these rules vary from system to system.
These rules are applied to data, prior to the data is being inserted into table columns.
This ensures that the records in the table have integrity.
For ex, no employee in the company shall get a salary less than Rs.10000 is a business rule.
If an attempt is made, to insert a value less than 10000 into the salary column, the database engine rejects the entire record automatically.
👉NULL value Constraint
Often there may be records in a table that do not have values for every field.
If the column was treated as Nullable, the database engine will place a null value in the column in the absence of a user-defined value.
✅Principles:
1)A null value is not equivalent to zero or space if the data type is a number or character.
2)A null value will evaluate to null in any expression.
3)Null value can be inserted into columns of any data type.
4)If the column has a null value, the database engine ignores any unique, foreign key, check constraints that may be attached to the column.
👉NOT NULL Constraint
The NOT NULL column constraint ensures that a table column cannot be left empty.
The NOT NULL constraint can only be applied at the column level.
Comments
Post a Comment