Monday, May 28, 2018

How to prevent delete if data associate with another table

Leave a Comment
how to prevent delete if data associate with another table
how to prevent delete if data associate with another table

Hi, everyone. in this tutorial will see how to prevent delete from a parent if data associated with another table. for this example, I have used programme and course table to prevent deletion of programme, if programme name is available on course table. in this case, I have map the one-to-many relation ship between programme table and course table. there for we need to relate the primary key of programme table as foreign key of course table. so let's get start.

Here is the DEMO checkout


Step 1 - Create database and table


Programme table


course table


Step 2 - Let's dumb data to tables


Add data to programme table


Add data to course table


Step 3 - Connect to database


Make sure to create database and define the database name in connection page


Step 4 - Let's insert programme



Step 5 - Let's insert course



Step 6 - Delete from programe


In this case if the programme name is associated with course table we can not delete the programme from programme table. this example is very important when you having large erp system.


Step 7 - Delete from course



That's all, Thank you so much for reading this how to prevent delete if data associated with another table, please download the complete source code below to access complete features.
I hope this tutorial will useful for your future projects. for more updates do not hesitate to contact me via email webriderat@gmail.com. if you like this tutorial share with your friends and social media. happy coding. 

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment