Jump to content

Recommended Posts

Hey everyone!

 

I have these 2 tables and I am trying to design it in a way that when a product is deleted from the catalog it also get its entry removed from the installation table.

 

The situation is: each installation has its own products list on it. but what if a product is no longer available? the installations having that product should remove it from the list.

 

Appreciate any help!

 

create table products
(
id int unsigned auto_increment not null primary key,
description varchar(64),
price float(5,2) unsigned
)type=InnoDB;

create table inst_products
(FOREIGN KEY (inst_id) references installation(inst_id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (descID) references products(id) ON DELETE NO ACTION,
inst_id int unsigned not null,
unints smallint unsigned, 
descID int unsigned not null
)type=InnoDB;

Link to comment
https://forums.phpfreaks.com/topic/51377-2-tables-on-delete-cascade/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.