List:General Discussion« Previous MessageNext Message »
From:Daevid Vincent Date:March 8 2003 12:27am
Subject:Multiple foreign keys?
View as plain text  
Can I have multiple foreign keys in a table? Like this... I ask because I
can't seem to get it to work. Errno: 150.

CREATE TABLE `dept_table` (
  `dept_id` mediumint(8) unsigned NOT NULL auto_increment,
  `dept_timestamp` timestamp(14) NOT NULL,
  `dept_company_table_id` mediumint(8) unsigned NOT NULL default '0'
REFERENCES company_table(company_id),
  `dept_rep_table_id` smallint(8) unsigned default NULL REFERENCES
rep_table(rep_id),
  `dept_name` varchar(255) NOT NULL default '',
  `dept_SCM_10` date NOT NULL default '0000-00-00',
  `dept_SCM_20` date NOT NULL default '0000-00-00',
  `dept_SCM_40` date NOT NULL default '0000-00-00',
  `dept_SCM_60` date NOT NULL default '0000-00-00',
  `dept_SCM_80` date NOT NULL default '0000-00-00',
  `dept_SCM_90` date NOT NULL default '0000-00-00',
  `dept_SCM_100` date NOT NULL default '0000-00-00',
  `dept_notes` text NOT NULL,
  PRIMARY KEY  (`dept_id`),
  KEY `dept_company_table_id` (`dept_company_table_id`),
  KEY `dept_rep_table_id` (`dept_rep_table_id`),
  FOREIGN KEY (dept_company_table_id) REFERENCES company_table(company_id)
ON DELETE CASCADE,
  FOREIGN KEY (dept_rep_table_id) REFERENCES rep_table(rep_id) ON DELETE SET
NULL
) TYPE=InnoDB;

Thread
Foreign keys and being FIRST indexDaevid Vincent6 Mar
  • Re: Foreign keys and being FIRST indexDan Nelson6 Mar
    • RE: Foreign keys and being FIRST indexDaevid Vincent6 Mar
      • Re: Foreign keys and being FIRST indexDan Nelson6 Mar
      • RE: Foreign keys and being FIRST indexKeith C. Ivey6 Mar
        • Multiple foreign keys?Daevid Vincent8 Mar
          • re: Multiple foreign keys?Egor Egorov8 Mar
  • Re: Foreign keys and being FIRST indexWilliam R. Mussatto6 Mar