我正在errorno:150
使用 MySQL。当我尝试创建第三个表时,它显示Can't create table。以下是完整的查询。
CREATE DATABASE `test`;
USE `test`;
-- --------------------------------------------------------
--
-- Table structure for table `product`
--
CREATE TABLE IF NOT EXISTS `product` (
`product_no.` int(10) NOT NULL AUTO_INCREMENT COMMENT 'This number represent a unique product',
`name` varchar(50) NOT NULL ,
`price` decimal(5,2) NOT NULL COMMENT 'Price should have a fomat like 25.90',
`max_Rating` int(10) NOT NULL COMMENT 'Maximum available rating for each product (n)',
PRIMARY KEY (`product_no.`)
);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`password` varchar(20) NOT NULL,
PRIMARY KEY (`user_id`)
);
-- --------------------------------------------------------
--
-- Table structure for table `rating`
--
CREATE TABLE IF NOT EXISTS `rating` (
`s.n.` int(10) NOT NULL AUTO_INCREMENT,
`product_no.` int(10) NOT NULL,
`user_id` int(10) DEFAULT NULL,
`given_rating` int(10) DEFAULT NULL,
PRIMARY KEY (`s.n.`),
foreign key (`user_id`) references `user(user_id)`,
foreign key (`product_no.`) references `product(product_no.)`
);
是否发生任何字段不匹配?我现在被困住了。