DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
MySQL

Referential integrity

Share

It is relational database concept in which multiple tables shares consistent relationship based on the data stored on tables.

For example, a school X has 2 tables, a student table, and a student fee table. In the student table we have 2 columns – the student ID and the student name. In the student fee table, we have 2 columns – the student ID and the fee for the given ID.

Now, suppose we want to remove a student because he no longer study at school X. So we need to remove that student from student table. As the student ID from student table exists in student fee table then from that table we need to delete too manually. That’s a big deal if there are too many table attached.

By referential integrity we can solve this problem. Lets define the student ID column in the student table to be our primary key. Then define the student ID column in the student fee table to be a foreign key that points to a primary key that is the student ID column in the student table.

Once we define our foreign to primary key relationship, we need to add ‘constraint’ on student fee table i.e. ‘cascading delete’. Whenever an student is removed from the student table, any data that student has in the student fee table would automatically be removed from the student fee table.

Referential integrity example:

ALTER TABLE `tbl_1` ADD CONSTRAINT `tbl_std_constr` FOREIGN KEY (`student_id`) REFERENCES `tbl_2` (`student_id`) ON DELETE CASCADE ON UPDATE CASCADE;

Namaste UI (Author)

Namaste UI collaborates closely with clients to develop tailored guest posting strategies that align with their unique goals and target audiences. Their commitment to delivering high-quality, niche-specific content ensures that each guest post not only meets but exceeds the expectations of both clients and the hosting platforms. Connect with us on social media for the latest updates on guest posting trends, outreach strategies, and digital marketing tips. For any types of guest posting services, contact us on info[at]namasteui.com.

Recent Posts

Tips – Advanced Blackjack Strategy

Once you've memorized basic blackjack strategy, it's time to delve deeper into the game. Advanced…

3 days ago

The Modern Practice of Yoga: How Balance, Mindfulness, and Lifestyle Design Are Transforming Everyday Wellbeing

Yoga is no longer just a physical practice. Yoga is popular as a lifestyle practice.…

5 days ago

Best Crypto Sign-Up Bonuses in India 2026: Ranked & Compared

Best Crypto Sign-Up Bonuses in India 2026: Ranked & Compared Every exchange claims to have…

1 week ago

Coach Bus Companies NYC: A Complete Guide Coach Bus Companies NYC

One of the world's busiest travel hubs, New York City relies heavily on coach bus…

2 weeks ago

The Advantages of Event Marketing

Whether large scale or small scale, many businesses want to market their services or products…

2 weeks ago

5 Secrets of Online Trading You Should Know

Online trading has brought ease of trading, better security protocols, and fast trade executions; however,…

4 weeks ago