loading..
Ðóññêèé    English
17:43

Once more about NULL values page 1

The meaning of the NULL value is an absence of information or inapplicability of the current attribute in the current tuple.

You can ask:”For what to have an attribute if its value is inapplicable?” The answer to this question lies in a field of modeling of the enterprise. Let's consider, for example, the database schema “Computers”. It represents the relational model of the association “type-supertype”. The models of computer production are the entries of the enterprise here; under this every type of production (PC, laptop or printer) represents an individual table with relations “many-to-one” with the Product table.

Such a model provides a high degree of normalization (3NF). However this is not the only way. We would have stored all information in one table, which could contain both mutual attributes for all models (for example, price) and attributes, which have sense only for models of certain types (for example, color – for printer defining). The NULL value is fully justified for this schema just in the meaning of an inapplicability of characteristic, that is NULL in the column color tells that this characteristic doesn't refer, let us say, to PC models.

Let's get back to the second aspect of null values – absence of information. If we decide to refuse the using of null values, we will have to offer an alternative. The natural way is using of the default value that will be substituted in the appropriate column under the absence of information. We should note that such default values should be at least so many as different data types that are supported by DBMS (integer, character strings, datetime, … ).

Let's consider, for example, the Laptop table and the price column. Let the enterprise to be so that at the moment of information input about the models of laptops their price is sometimes unknown. In choosing the default value we should be bounded by permissible values for the price column. Data type for the column (money) makes us to be bounded by numerical values, compatible with current type and domain constraints (constraint of the CHECK type), imposed on permissible values for this column. Any positive value as a default value will cause a confusion, because it is impossible to differ “true” value of price from the substitution of the absent price. That is why we should choose zero or any negative value. And now let's speak about disadvantages of such a substitute.

Bookmark and Share
Pages 1 2 3
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
month ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.