One thing that distinguishes a simple excel sheet from a SQL server or MS Access databases is referential integrity. This concept helps to fetch the data in an easy and fast manner. It provides the ability to group the data on the basis of subjects and link the information in different tables.
So let’s see what actually Referential Integrity is. According to Wikipedia, the definition of Referential Integrity is:
“Referential integrity is a property of data stating that all its references are valid. In the context of relational databases, it requires that if a value of one attribute of a relation references a value of another attribute, then the referenced value must exist.”
To make it easier we can say that Referential Integrity is the method to ensure the validity or correctness of the data within a database management system. To understand RI you must know the concept of Foreign and Primary key. Different constraints are set on the database to make sure that the data is semantically correct. To set up a referential constraint you need to set up a primary key in the parent table and a foreign key in the corresponding child table. There are different sets of rules such as insert, update, and delete.
An example of RI could be like if there is a course/class database then:
Course(CourseCode, DeptCode, CourseName)
Class(CourseCode, ClassID, Section, ClassTime)
In this example, you can see that the primary key of the Course table is present as a foreign key in the Class table and hence ensures the referential integrity.