当前位置:网站首页>Error1822 and error1824 are displayed in the database

Error1822 and error1824 are displayed in the database

2022-06-25 13:36:00 CSDN Q & A

Display when running order Where? ERROR 1822 : Failed to add the foreign key constraint. Missing index for constraint ‘orderitem_ibfk_1’ in the referenced table ‘orders’, I did some research on the Internet , See that you want to check whether the foreign key is the primary key of another table , But they are all , What's going on
I put it back order Table commented out , Show c_sevice That watch ERROR 1824 : Failed to open the referenced table 'fastfood_shop' What's going on

CREATE TABLE admin_login(
admin_id varchar(50) NOT NULL,
admin_pass varchar(50) DEFAULT NULL,
PRIMARY KEY (admin_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE order1(
cons_phone varchar(50) NOT NULL,
service_id varchar(50) NOT NULL,
order_id varchar(50) NOT NULL,
forder_money varchar(50) DEFAULT NULL,
order_way varchar(50) DEFAULT NULL,
cons_name varchar(50) DEFAULT NULL,
cons_addre varchar(50) NOT NULL,
PRIMARY KEY (cons_phone,service_id),
FOREIGN KEY (cons_phone) REFERENCES order1 (cons_phone),
FOREIGN KEY (service_id) REFERENCES c_service (c_service_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE c_service(
c_service_id varchar(50) NOT NULL,
c_service_name varchar(50) NOT NULL,
fastfood_shop_name varchar(50) NOT NULL,
PRIMARY KEY (c_service_id),
FOREIGN KEY (fastfood_shop_name) REFERENCES fastfood_shop(shop_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE fastfood_shop(
shop_name varchar(50) NOT NULL,
m_sale_v varchar(50) NOT NULL,
PRIMARY KEY (shop_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE dispatcher(
dispatcher_id varchar(50) NOT NULL,
dispatcher_name varchar(50) NOT NULL,
dispatcher_phone varchar(50) NOT NULL,
fastfood_shop_namel varchar(50) NOT NULL,
PRIMARY KEY (dispatcher_id),
FOREIGN KEY (fastfood_shop_namel) REFERENCES fastfood_shop(shop_name)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE wuliu(
cons_phonel varchar(50) NOT NULL,
disp_id varchar(50) NOT NULL,
deliver_time varchar(50) DEFAULT NULL,
PRIMARY KEY (cons_phonel,disp_id),
FOREIGN KEY (cons_phonel) REFERENCES order1(cons_phone),
FOREIGN KEY (disp_id) REFERENCES dispatcher(dispatcher_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

原网站

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206181901525696.html