Book Contents

Book Index

Next Topic

Home

table-constraint

Adds a join constraint or a constraint describing a functional dependency to the metadata of a table. See Adding Constraints in the Database Administrator's Guide.

Syntax

[ CONSTRAINT constraint_name ]

{ PRIMARY KEY ( column [ , ... ] )

| FOREIGN KEY ( column [ , ... ] )

REFERENCES table [ ( column [ , ... ] ) ]

| CORRELATION ( column1 ) DETERMINES ( column2 )

}

Semantics

CONSTRAINT constraint-name

optionally assigns a name to the constraint. Vertica recommends that you name all constraints.

PRIMARY KEY

( column [ , ... ] )

adds a referential integrity constraint defining one or more NOT NULL numeric columns as the primary key.

FOREIGN KEY

( column [ , ... ] )

adds a referential integrity constraint defining one or more NOT NULL numeric columns as a foreign key.

REFERENCES

table [ ( column [ , ... ] )

specifies the table to which the FOREIGN KEY constraint applies. If column is omitted, the default is the primary key of table.

CORRELATION

describes a functional dependency. Given a tuple and the set of values in column1, one can determine the corresponding value of column2.

Notes

Examples

CORRELATION (Product_Description) DETERMINES (Category_Description)

The Retail Sales Example Database described in the Quick Start contains a table Product_Dimension in which products have descriptions and categories. For example, the description "Seafood Product 1" exists only in the "Seafood" category. You can define several similar correlations between columns in the Product Dimension table.