У меня есть таблица сопоставления для клиентов и продуктов.Вот шаги
create table `customer_products` (
`customer_id` bigint not null,
`product_id` bigint not null,
primary key (`customer_id`, `product_id`)
);
alter table `customer_products`
add constraint `FK7urin54lem7yxy6umxf899t16`
foreign key (`customer_id`)
references `customer` (`customer_id`);
alter table `customer_products`
add constraint `FKtfgjfwfykaef4wjk00ofyqq8y`
foreign key (`product_id`)
references `product` (`product_id`);
insert into customer_products values(7,5); //should get a contraint error
Когда я вставляю в эту таблицу сопоставлений, хотя соответствующих записей нет в родительских таблицах, я не получаю сообщение об ошибке в приведенном выше операторе insert
.Нужна ли какая-то дополнительная опция для наложения этого ограничения?