On Wednesday 05 July 2006 12:26 pm, z247 wrote:
> How would a foreign key constraint work in this case?

An example of a foreign key constraint would be something like:

CREATE TABLE users (
  id BIGINT UNSIGNED NOT NULL UNIQUE,
  username VARCHAR NOT NULL,
  password VARCHAR NOT NULL,
  status INT UNSIGNED,
  PRIMARY KEY (id),
   CONSTRAINT foreign_user_status FOREIGN KEY foreign_user_status (status)
    REFERENCES user_status (id)
    ON DELETE SET NULL
);

another option is to have it as an ALTER TABLE statement:

ALTER TABLE users ADD FOREIGN KEY(foreign_user_status) 
REFERENCES user_status ( id );
-- 
Chris White
PHP Programmer/DBoooooo
Interfuel

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to