I ask for help in learning) I'm trying to make a cascade delete and update. I create 2 tables:
create table Details( code_detail mediumint not null auto_increment, type_detail enum('buy', 'own'), name_detail varchar(20) default 'detail', unit_detail varchar(20), price_detail int check (price_detail>0), primary key (code_detail) ) engine=InnoDB; create table Availability( number_stock int not null, code_detail int, unit_detail varchar(20), quantity_detail int default '0', last_date date, primary key(number_stock, code_detail), key code_detail(code_detail), constraint detail_ibfk_1 foreign key (code_detail) references Details(code_detail) on update cascade on delete cascade )engine=InnoDB; There are no problems with the first one, however, when creating the second one (Availability), an error appears:
Error Code: 1005. Can't create table 'Mounth.Availabity' (erno: 150)
Thanks to active googling, I found out - an error with foreign keys, but I can not understand what the problem is. Thanks in advance for the answers :)