Aother column modifier: FOREIGN KEY this column(s) is the link to another table's primary key. Table is related to another by sharing a common attribute. in "child" table ct: ct_fk itsTypeAndMods, FOREIGN KEY(ct_fk) REFERENCES pt(pt_pk) #pt_pk is primary key of "parent" table pt Desc ct: +-------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | ct_fk | itsType | YES | MUL | NULL | | A foreign key is an index: "MUL" Create Table event ( name Varchar(20) Not Null, ... FOREIGN KEY(name) REFERENCES pet(name) ) fk and pk can be same or different name but must be same datatype. "Controlled redundancy" (duplication) of this column in both tables. Cannot Insert/Update an fk value in child that is not in parent, preserving "referential integrity". i.e. a child must have a parent that exists; cannot have orphans. (OK to have pk values in parent that are not in any fk of child, i.e. a parent can have no children.) == Foreign key may be Null but may not be a value that is not in parent's primary key column. == Every non-null foreign key value must reference an existing primary key value. == Impossible to have an invalid value. Parent row can have many children: 1-to-many relation. One PK value in parent can exist many times (rows) as FK value in child. Parent can have many children (or none). A child has exactly one parent. Foreign keys are the basis of the "join" operation (pulling info from multiple tables by following the links.) Parent table must be created before child (so reference is understood). Parent table must be populated before child (so referential integrity can be checked when inserting child table rows). Also, must handle cases when pk value in parent Updated or Deleted (can 1. disallow the update/delete, or 2. cascade changed value to child tables or set to Null, or 3. delete child rows).?? Added to Foreign Key modifier in child: ON DELETE {RESTRICT | CASCADE | SET NULL} ON UPDATE {RESTRICT | CASCADE | SET NULL} MySQL defaults: On Delete Restrict (cannot delete a row in parent if any child has the key being deleted). On Update Restrict (cannot change pk in parent if any child has that value in its fk). MySQL: tables must be InnoDB engine type (default in Windows if Configuration Wizard was used to install, else MyISAM is default engine.) #explicitly specify engine: CREATE TABLE t (columns_definitions) ENGINE=InnoDB; ALTER TABLE t Engine=InnoDB; #change type after creation =MyISAM SHOW CREATE TABLE t; #lists engine type and foreign key constraints