我有一张表格,用来记录从一个供应商向另一个供应商运送产品的天数和成本。我们(出色地:p)将运输供应商(FedEx、UPS)和产品处理供应商(Think...Dunder Mifflin)存储在“供应商”表中。所以,我的 SHIPPING_DETAILS 表中有三列都引用了 VENDOR.no。出于某种原因,MySQL 不允许我将所有三个定义为外键。有任何想法吗?
CREATE TABLE SHIPPING_GRID(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row',
shipping_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the shipping vendor (vendors_type must be 3)',
start_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the vendor being shipped from',
end_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to the VENDOR.no for the vendor being shipped to',
shipment_duration INT(1) DEFAULT 1 COMMENT 'Duration in whole days shipment will take',
price FLOAT(5,5) NOT NULL COMMENT 'Price in US dollars per shipment lbs (down to 5 decimal places)',
is_flat_rate TINYINT(1) DEFAULT 0 COMMENT '1 if is flat rate regardless of weight, 0 if price is by lbs',
INDEX (shipping_vendor_no),
INDEX (start_vendor_no),
INDEX (end_vendor_no),
FOREIGN KEY (shipping_vendor_no) REFERENCES VENDOR (no),
FOREIGN KEY (start_vendor_no) REFERENCES VENDOR (no),
FOREIGN KEY (end_vendor_no) REFERENCES VENDOR (no)
) TYPE = INNODB;
编辑删除双主键定义...
是的,不幸的是,这并没有解决它。现在我得到:
无法创建表'./删除我的数据库名称/SHIPPING_GRID.frm'(错误号:150)
做一个 phpinfo() 告诉我这个mysql:
客户端 API 版本 5.0.45
是的,VENDOR.no 是 int(6) 类型。