Jump to content

Creating relations in mySQL, how do u do this? More Details needed please!


bulgaria_mitko

Recommended Posts

I have created a database with 2 tables one with Products->ProductID and Products->TypeID and the other with ProductsType->TypeID and i want to related them so when i delete a ProductType it will NOT delete all the Products related to that ProductType. How have to set the ON DELETE and ON UPDATE in order to do this and also how to u set them when u delete a ProductType to delete all the Products related to that ProductType? Thank you very much!  ???
The default is NOT to delete related data.

If you are finding that related data is deleted automatically, then it is due to something you have added to the table definitions.  It could be related to foreign keys.  There is no requirement to specify foreign keys.
There are several rules you have to abide by if you plan on using foreign keys.  From what I know, InnoDB is the only engine that can implement foreign keys.  I strongly suggest that you read the MySQL manual regarding the construction of InnoDB databases. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.