8 messages in com.mysql.lists.mysqlre: Multiple foreign keys?| From | Sent On | Attachments |
|---|---|---|
| Daevid Vincent | 05 Mar 2003 18:36 | |
| Dan Nelson | 05 Mar 2003 19:24 | |
| Daevid Vincent | 05 Mar 2003 19:38 | |
| Dan Nelson | 05 Mar 2003 21:44 | |
| William R. Mussatto | 06 Mar 2003 09:30 | |
| Keith C. Ivey | 06 Mar 2003 10:21 | |
| Daevid Vincent | 07 Mar 2003 16:26 | |
| Egor Egorov | 08 Mar 2003 01:12 |
| Subject: | re: Multiple foreign keys?![]() |
|---|---|
| From: | Egor Egorov (egor...@ensita.net) |
| Date: | 03/08/2003 01:12:38 AM |
| List: | com.mysql.lists.mysql |
On Saturday 08 March 2003 02:27, Daevid Vincent wrote:
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.
Yes, you can. Check that all tables are InnoDB, that columns have the same type and so on ..
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;
-- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ Egor...@ensita.net /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com




