@@ -495,8 +495,8 @@ CREATE TABLE products (
495495 </indexterm>
496496
497497 <para>
498- Unique constraints ensure that the data contained in a column or a
499- group of columns is unique with respect to all the rows in the
498+ Unique constraints ensure that the data contained in a column, or a
499+ group of columns, is unique among all the rows in the
500500 table. The syntax is:
501501<programlisting>
502502CREATE TABLE products (
@@ -518,8 +518,8 @@ CREATE TABLE products (
518518 </para>
519519
520520 <para>
521- If a unique constraint refers to a group of columns, the columns
522- are listed separated by commas:
521+ To define a unique constraint for a group of columns, write it as a
522+ table constraint with the column names separated by commas:
523523<programlisting>
524524CREATE TABLE example (
525525 a integer,
@@ -545,10 +545,11 @@ CREATE TABLE products (
545545 </para>
546546
547547 <para>
548- Adding a unique constraint will automatically create a unique btree
549- index on the column or group of columns used in the constraint.
550- A uniqueness constraint on only some rows can be enforced by creating
551- a <link linkend="indexes-partial">partial index</link>.
548+ Adding a unique constraint will automatically create a unique B-tree
549+ index on the column or group of columns listed in the constraint.
550+ A uniqueness restriction covering only some rows cannot be written as
551+ a unique constraint, but it is possible to enforce such a restriction by
552+ creating a unique <link linkend="indexes-partial">partial index</link>.
552553 </para>
553554
554555 <indexterm>
@@ -557,10 +558,10 @@ CREATE TABLE products (
557558 </indexterm>
558559
559560 <para>
560- In general, a unique constraint is violated when there is more than
561+ In general, a unique constraint is violated if there is more than
561562 one row in the table where the values of all of the
562563 columns included in the constraint are equal.
563- However, two null values are not considered equal in this
564+ However, two null values are never considered equal in this
564565 comparison. That means even in the presence of a
565566 unique constraint it is possible to store duplicate
566567 rows that contain a null value in at least one of the constrained
@@ -584,8 +585,9 @@ CREATE TABLE products (
584585 </indexterm>
585586
586587 <para>
587- Technically, a primary key constraint is simply a combination of a
588- unique constraint and a not-null constraint. So, the following
588+ A primary key constraint indicates that a column, or group of columns,
589+ can be used as a unique identifier for rows in the table. This
590+ requires that the values be both unique and not null. So, the following
589591 two table definitions accept the same data:
590592<programlisting>
591593CREATE TABLE products (
@@ -605,7 +607,7 @@ CREATE TABLE products (
605607 </para>
606608
607609 <para>
608- Primary keys can also constrain more than one column; the syntax
610+ Primary keys can span more than one column; the syntax
609611 is similar to unique constraints:
610612<programlisting>
611613CREATE TABLE example (
@@ -618,31 +620,31 @@ CREATE TABLE example (
618620 </para>
619621
620622 <para>
621- A primary key indicates that a column or group of columns can be
622- used as a unique identifier for rows in the table. (This is a
623- direct consequence of the definition of a primary key. Note that
624- a unique constraint does not, by itself, provide a unique identifier
625- because it does not exclude null values.) This is useful both for
626- documentation purposes and for client applications. For example,
627- a GUI application that allows modifying row values probably needs
628- to know the primary key of a table to be able to identify rows
629- uniquely.
630- </para>
631-
632- <para>
633- Adding a primary key will automatically create a unique btree index
634- on the column or group of columns used in the primary key.
623+ Adding a primary key will automatically create a unique B-tree index
624+ on the column or group of columns listed in the primary key, and will
625+ force the column(s) to be marked <literal>NOT NULL</>.
635626 </para>
636627
637628 <para>
638629 A table can have at most one primary key. (There can be any number
639- of unique and not-null constraints, which are functionally the same
640- thing, but only one can be identified as the primary key.)
630+ of unique and not-null constraints, which are functionally almost the
631+ same thing, but only one can be identified as the primary key.)
641632 Relational database theory
642633 dictates that every table must have a primary key. This rule is
643634 not enforced by <productname>PostgreSQL</productname>, but it is
644635 usually best to follow it.
645636 </para>
637+
638+ <para>
639+ Primary keys are useful both for
640+ documentation purposes and for client applications. For example,
641+ a GUI application that allows modifying row values probably needs
642+ to know the primary key of a table to be able to identify rows
643+ uniquely. There are also various ways in which the database system
644+ makes use of a primary key if one has been declared; for example,
645+ the primary key defines the default target column(s) for foreign keys
646+ referencing its table.
647+ </para>
646648 </sect2>
647649
648650 <sect2 id="ddl-constraints-fk">
0 commit comments