PHP Ferrari
PHP Ferrari

Reputation: 15656

MySQL set Integrity checks on table

In MySQL I have two tables

roles

role_id | role_name

user_roles

user_id | role_id

in user_roles table role_id is a FOREIGN KEY. Now I want to restrict on deletion of row in roles table if role_id is also exists on user_roles table

I think this could be done either from Integrity setting while creating table. I don't know what does CASCADE or RESTRICT do and how they works.

I read somewhere that FOREIGN KEY does not supported by Storage Engine MyISAM so please guide me for both Storage Engine (MyISAM and InnoDB)

Upvotes: 1

Views: 355

Answers (2)

azzaxp
azzaxp

Reputation: 717

You read it right that MyISAM engine does not support the foreign key integrity checks. My Advice is to go for innodb.

There is another option which most of the times, I use when I want to stick to MyISAM table, i.e Manage all these at the front end. But At times this is not good as your adding more headaches at front end.

Go for InnoDB

Upvotes: 1

Related Questions