I would like to create a table that optionally links to an other table.
The field company_id in the following table should be either Null or link to the table tblCompany (`id` ). How do I do that. The way I it now, I can not enter records where the field company_id is null.
Thanks robert
drop table IF EXISTS tblAgentCompanyMapper; CREATE TABLE IF NOT EXISTS `energie_2`.`tblAgentCompanyMapper` ( `siaid` INT COMMENT 'id assigned in the excelsheet by SIA' , `company_id` INT NULL DEFAULT NULL UNIQUE COMMENT 'id automatically used by energiecluster adresses' , `name` VARCHAR(128) NOT NULL , `url` VARCHAR(256) NULL , INDEX `fk_tblAgentCompanyMapper_tblCompany1` (`company_id` ASC) , PRIMARY KEY (`siaid`) , CONSTRAINT `fk_tblAgentCompanyMapper_tblCompany1` FOREIGN KEY (`company_id` ) REFERENCES `energie_2`.`tblCompany` (`id` ) ON DELETE SET NULL ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=listsearcharchive@lassosoft.com
May 23
Jo?o C?ndido de Souza Neto Re: need help creating relation
May 23, 2011; 08:21
Jo?o C?ndido de Souza Neto
Re: need help creating relation
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!