Hello. Please tell me how to implement this. There are 2 tables products (id, name, description) and images (id, id_product, name)
And I want to make a link, that if a product is deleted, then all images are deleted with this product, but at the same time, so that you can create a product WITHOUT images. I tried it like this
ALTER TABLE tb_product ADD CONSTRAINT tb_product_tb_image_id_product_fk FOREIGN KEY (id) REFERENCES tb_image (id_product); It seems all is well, but I can not create a product without images.
ON DELETE CASCADEto automatically delete the image - Mike