What does First Normal Form mean?
&gt; A relation more or less correspond to a table<p>&quot;More or less&quot;, but mostly less. Views are relations. The rowsets returned by a SELECT query are relations. Etc.<p>Without going into what relational algebra is about, I find it a lot more helpful to understand a &quot;relation&quot; like this:<p>A relational database is like a Prolog interpreter: it&#x27;s a thing that &quot;knows&quot; a bunch of &quot;facts&quot;, because someone has &quot;asserted&quot; (declared to be true) those facts to it.<p>In Prolog, facts look like this:<p>• red(MyCar).<p>• father(HarryPotter, JamesPotter).<p>• succ(1, 2).<p>Those look like functions, but what they really are, are tuples, and moreover, tuples that are members of a <i>relation</i>. They describe &#x2F; assert a particular relationship. The &quot;function name&quot; at the beginning of a fact is the <i>label</i>, an identifier for a particular kind of relationship known to the system; it is then followed by an N-tuple of values, describing the <i>details</i> of this particular instance of the relationship.<p>A mathematical &quot;relation&quot;, then, can be understood as an arbitrary set containing facts&#x2F;relationships of a given <i>type</i> (the &quot;type&quot; being the predicate label, the tuple&#x27;s arity, and the domain types of the tuple&#x27;s slots.)<p>Note that what this definition is <i>defining</i> is, essentially, an ADT. A relation is a container for relationships, that exposes certain operations (relational algebra).<p>You can think of the set of &quot;asserted&quot; facts&#x2F;relationships of each kind, as being a special relation. A global data structure.<p>But remember that Prolog can <i>derive</i> truth from predicate functions (e.g. that &#x27;succ&#x27; predicate above can be defined by induction by defining a base-case fact and a function succ(N, N + 1).) So, while the set of <i>asserted</i> facts is <i>a</i> relation declaring which facts&#x2F;relationships are &quot;true&quot;, it&#x27;s not the <i>only</i> source of truth.<p>-----<p>Now, going back to the world of relational databases:<p>SQL is a language for manipulating relations, just as APL is a language for manipulating arrays.<p>Database tables <i>are</i> relations! But they&#x27;re not the <i>only</i> relations in the DB. Any &quot;rowset&quot; (as Postgres terms it) that you create or manipulate is a relation.<p>Every relation in an RDBMS (table, view, result rowset, etc.) has a type. That type is the kind of its relation, as defined above. It includes the arity and types of the tuple fields, yes, but <i>also the label</i>.<p><pre><code>    -- Prolog equivalent relation type: foo(A, B).
    CREATE TABLE foo (a text, b text).
</code></pre>
When you&#x27;re creating an RDBMS table with CREATE TABLE, and giving a structural inline row-type definition, you&#x27;re implicitly first defining a relation type with the same <i>label</i> as the table&#x27;s <i>name</i>. The table itself is now just one relation of that type. You can have others! (In fact, queries selecting * from that table, are already other relations of the same type. However, if you&#x27;re <i>projecting</i> or <i>joining</i> — changing the shape of the result-set — then your result relation is of a new temporary relation type.)<p>Perhaps surprisingly, you <i>can</i> have two RDBMS tables that have the same relation <i>type</i>, which makes them both sources of truth about the same <i>facts</i>. (Why? Partitions, for one.)<p>But two RDBMS tables aren&#x27;t sources of truth about the same facts just <i>because</i> they share a shape. They need to actually be defined as having the same relation type (including the label!), to be considered interchangeable by the DB (for purposes of e.g. defining stored procedures that operate on rows of a given type.)<p>You can&#x27;t do this by just creating another table with the same (structural inline) row-type definition. Those tables will have different relation types, because those types are <i>carrying around predicate labels</i>, and those labels are different.<p><pre><code>    -- BAD: relation types are fathers_us(text, text) and fathers_eu(text, text). Incompatible!
    CREATE TABLE fathers_us (child text, father text);
    CREATE TABLE fathers_eu (child text, father text);
</code></pre>
Instead, you must either explicitly define a relation type using CREATE TYPE; or reuse the type implicitly created from your first CREATE TABLE, to create the second. Only then are the relation labels the same.<p><pre><code>    -- Single type: father(A, B).
    CREATE TYPE father AS (child text, father text);

    -- GOOD: same type father(A, B).
    CREATE TABLE fathers_us OF father;
    CREATE TABLE fathers_eu OF father;
</code></pre>
Why don&#x27;t DBMSes use structural typing? Well, because facts can have the same <i>structure</i> but still not be facts about the same thing:<p><pre><code>    CREATE TABLE fathers(child text, parent text);
    CREATE TABLE mothers(child text, parent text);
</code></pre>
A stored procedure that takes a fathers(text, text) row, shouldn&#x27;t necessarily be able to accept a mothers(text, text) row!