Foreign Key Syntax

Creating new tables and want to get the Foreign Key syntax correct. (using MySQL 5.0) Is the code below correct?

CREATE TABLE company
(
    id                  INT(11)         NOT NULL    AUTO_INCREMENT  PRIMARY KEY
,   company             VARCHAR(100)
,   first_name          VARCHAR(50)
,   last_name           VARCHAR(50)
,   address             VARCHAR(100)
,   address2            VARCHAR(100)
,   city                VARCHAR(100)
,   state               VARCHAR(50)
,   zip                 VARCHAR(10)
,   phone               VARCHAR(25)
,   cell_phone          VARCHAR(25)
,   fax                 VARCHAR(25)
,   email               VARCHAR(50)
,   website             VARCHAR(50)
,   license             VARCHAR(50)
,   insurance_carrier   VARCHAR(100)
,   insurance_phone     VARCHAR(50)
,   forms_email         VARCHAR(50)
)
    DEFAULT CHARACTER SET utf8 ENGINE=InnoDB
;


CREATE TABLE users
(
    id                  INT(11)         NOT NULL    AUTO_INCREMENT  PRIMARY KEY
,   company_id          INT(11)
,   name                VARCHAR(50)     NOT NULL
,   email               VARCHAR(50)     NOT NULL
,   password            CHAR(32)        NOT NULL
,   role                CHAR(5)         NOT NULL

,   CONSTRAINT          email_uk        UNIQUE      (  email  )

,   CONSTRAINT          FOREIGN KEY (company_id) REFERENCES company (id)
        ON DELETE CASCADE
        ON UPDATE CASCADE
)
    DEFAULT CHARACTER SET utf8 ENGINE=InnoDB
;

Any comments would be appreciated.

looks okay to me

however, the best way to determine whether your syntax is any good …

… is to test it :slight_smile: