Explain not null constraint. How does a not null constraint enforce domain integrity?

Database Management System >   Database Constraints >   Constraints Introduction  

Long Question

1315


Answer:

Every attribute has a nullability characteristic that shows whether a particular attribute accepts a null value or not. By default, every attribute accepts null values but this default nullability characteristic can be overridden by using the not null constraint. The not null constraint ensures that the attribute must not accept null values. For example, consider a tuple in the BOOK relation where the attribute ISBN contains a null value. Such a tuple provides book information for an unknown ISBN and, hence, it does not provide appropriate information. In such case, null value must not be allowed and this can be done by constraining the attribute ISBN using not null constraint. Here, the not null constraint prevents the null value to be inserted into the attribute ISBN. Any attempt to change the attribute value of ISBN to null value results in an error. The null values are not allowed in the primary key attribute of a relation. Since ISBN is a primary key attribute of BOOK relation, it cannot accept null values. Hence, it is not necessary to explicitly specify not null constraint for the attribute ISBN.

The not null constraint enforces domain integrity by ensuring that the attribute of a particular domain is not permitted to take null values. For example, a domain, say dom2, can be restricted to take non-null values. If the domain dom2 is assigned to the attribute Category of a BOOK relation, it ensures that the attribute Category must have some values. As a result, if null value is inserted into the constrained attribute, it will not be accepted as it violates the not null constraint.


This Particular section is dedicated to Question & Answer only. If you want learn more about Database Management System. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.