Null (SQL): Difference between revisions

Content deleted Content added
mNo edit summary
mNo edit summary
Line 384:
 
{| class="wikitable"
|+ ''J''
|-
! F1 !! F2 !! F3
Line 399:
<syntaxhighlight lang="sql">
SELECT F1, F3 FROM
(SELECT F1, F2 FROM J) AS F12
NATURAL JOIN
(SELECT F2, F3 FROM J) AS F23;
</syntaxhighlight>
 
Line 428:
|}
 
The intuition for what happens above is that the Codd tables representing the projections in the subqueries lose track of the fact that the Nulls in the columns F12.F2 and F23.F2 are actually copies of the originals in the table J. This observation suggests that a relatively simple improvement of Codd tables (which works correctly for this example) would be to use ''Skolem constants'' (meaning [[Skolem function]]s which are also [[constant function]]s), say ω<sub>12</sub> and ω<sub>22</sub> instead of a single NULL symbol. Such an approach, called v-tables or Naive tables, is computationally less expensive that the c-tables discussed above. However, it is still not a complete solution for incomplete information in the sense that v-tables are only a weak representation for queries not using any negations in selection (and not using any set difference either). The first example considered in this section is using a negative selection clause, {{code|WHERE Age <> 22|sql}}, so it is also an example where v-tables queries would not report sure information.
 
==Check constraints and foreign keys==