First page Back Continue Last page Image

Constraints

Constraints are criteria placed on objects (Table, Record, Field) that limit what may be placed in that Object

We are already using constraints, NOT NULL means the field may not contain nothing

You can use the CONSTRAINT command at the Table level or at the Column (Field) level

CREATE TABLE invoices

(

invoice_id INT PRIMARY KEY,

vendor_id INT NOT NULL,

invoice_number VARCHAR(50) NOT NULL UNIQUE,

CONSTRAINT invoices_fk_vendors

FOREIGN KEY (vendor_id)

REFERENCES vendors (vendor_id)

)

Here is an example of a Constraint being used at the table level to enforce a Foreign key Relationship