Referential Integrity

GCSE Databases (14-16 years)

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

A-Level Relational Databases (16-18 years)

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

What is Referential Integrity:

A part given by social database organisation structures (RDBMS) that shields customers or appeals from entering clashing data. Most RDBMSs have distinctive appropriate uprightness and conclude that you can apply when you make an association between two relations.

For example, expect Relation B has a new key that concentrations to a meadow in Relation A. Appropriate trustworthiness would shield you from adding a evidence to Relation B that can’t be associated with Relation A. Also, the appropriate genuineness chooses may in like manner establish that at whatever point you delete an evidence from Relation A, any evidences in Relation B that are associated with the eradicated evidence will similarly be deleted. This is called falling delete. Finally, the appropriate reliability choice could establish that at whatever point you change the assessment of an associated meadow in Relation A, all evidence in Relation B that is associated with it will similarly be altered in like way. This is called falling update

Appropriate genuineness suggests the accuracy and consistency of data inside a relationship. Seeing somebody, data is associated between in any event two relations. This is cultivated by having the new key (in the connected relation) recommend a fundamental key worth (in the basic or parent relation). Thus, we need to ensure that data on the different sides of the relationship remain immaculate.

Thus, appropriate reliability requires that, at whatever point a new key is used, it must recommend a generous, living fundamental key in the parent relation.


A property of information indicating that all the recommendations are genuine is appropriate trustworthiness. In contrast with social information bases, where an estimation of one characteristic (segment) of a relationship (relation) compares to an estimation of another quality (in the equivalent or separate relationship), the referred to esteem must remain.

To keep up appropriate dependability, the social data in informational collection relations must be generally configurable with the goal that alters in a solitary part of the system don’t fast unexpected issues away. Specifically, keys that recommend segments of various relations ought to be related with those various meadows, so that if there is an altar, everything gets invigorated together, and not autonomously. This thwarts botches where gradually updates make mistakes

Referential Integrity in Database

For appropriate reliability to hold in a general database, any part in a base relation that is declared a new key can simply contain either wrong attributes or attributes from a parent relation’s basic key or an up-and-comer key. Accordingly, when a new key is used it must recommend a generous, existing fundamental key in the parent relation. Occasion, deleting an evidence that contains a value insinuated by a new key in another relation would spilt appropriate uprightness. Some social database organisation structures (RDBMS) can approve appropriate reliability, routinely either by eradicating the new key lines likewise to take care of uprightness, or by re-establishing a goof and not playing out the delete. Which strategy is used may be directed by an appropriate decency impediment portrayed in a data word recommendation.

The modifier ‘appropriate’ depicts the accomplishment that a new key accomplishes, ‘implying’ an associated fragment in another relation. In essential terms, ‘appropriate uprightness’ warranty that the goal ‘suggested’ will be found. A nonattendance of appropriate decency in a database can lead social informational collections to re-establish divided data, customarily with no indicator of a botch.


For eg, on the off chance that we erase the evidence number 15 out of an essential relation, we have to ensure that in any comparative relation with an estimation of 15, there is no unfamiliar key. What’s more, when there are no connected reports should we have the option to delete an essential key. We would wind up with a stranded evidence in any case.

Referential Integrity Image 1

Subsequently, appropriate trustworthiness will disallow clients from:

  • Adding information to a comparative relation if the essential relation doesn’t have a related report.
  • Changing qualities that bring about stranded evidence in a connected relation in the essential relation.
  • Erasing information from an essential relation if comparable information is coordinated.

Here we consider a bank information base framework, which holds two relations:

  • Client Relation: This contains crucial customer container data, for instance, name, government sponsored retirement number, address and date of birth.
  • Evidences relation: This stock crucial monetary equalization data, for instance, account type, account creation date, account container and removal limits.

To particularly recognise each customer/account container in the CUSTOMER relation, a fundamental key area named CUSTOMER_ID is made. To perceive a customer and evidence connection in the Accounts relation, a current customer in the CUSTOMER relation must be alluded to.

Henceforth, the CUSTOMER_ID section — moreover made in the Accounts relation — is a new key. This part is remarkable since its characteristics are not as of late made. Or then again perhaps, these characteristics must recommend holding and unclear characteristics in the basic key segment of another relation, which is the CUSTOMER_ID fragment of the CUSTOMER relation.

Appropriate dependability is a standard that suggests any CUSTOMER_ID regard in the CUSTOMER relation may not be adjusted without changing the relating motivation in the Accounts relation.

For example: if Andrew Smith’s customer ID is changed in the CUSTOMER relation, this change similarly ought to be applied to the Accounts relation, consequently allowing Andrew Smith’s evidence information to association with his customer ID.

Referential Integrity Rules and Constraints

In a relational model, constraints are a very significant function. The relational model, in particular, supports the well-defined principle of attribute or relation constraints. Constraints are beneficial since they allow a designer to define in the database the meanings of content. Restrictions are the laws that require DBMSs to verify that the connotation is fulfilled by knowledge.

Domain Integrity

The scope limits the attribute values in the relationship and is a comparative. sample constraint. There is real-world connotation for data, however, which cannot be defined if used for domain constraints only. We require more precise methods of stating what data attributes are permissible or not and which appearance is sufficient for a characteristic. The Employee ID (EID) must, for example, be special or the birthdate of the employee is in the range [Jan 1, 1950, Jan 1, 2000]. In logical statements called honesty constraints, such data is given.

There are many forms of limits to honesty, listed below.

Entity integrity

To guarantee the credibility of an individual, each relation must have a primary key. There can be null values for nor the PK nor any part of it. This is because null values for the primary key mean that any rows cannot be found. For eg, the phone cannot be a primary key in the EMPLOYEE relation and certain individuals do not have a smartphone.

Referential integrity

Appropriate validity requests that an unfamiliar key must have, or should be vacant, a relating essential key. This limitation is expressed between the two relations (parent and youngster); the correspondence between the columns in these relations is held. This implies that the connection starting with one relation’s line then onto the next relation should be exact.

Referential integrity in Microsoft Access

In Microsoft (MS) Entry, by joining the PK in the Consumer relation to the CustID in the sequence relation, appropriate credibility is set up. See the figure on the Edit Relationships screen in MS Access for an explanation of how this is achieved.

Referential Integrity Image 2

Enterprise Constraints

Enterprise restrictions are additional rules that users or database managers define and may be based on several relations, often referred to as semantic constraints.

Any explanations are here.

  • There will be a limit of 60 students for a lesson.
  • A limit of four courses per semester can be taught by an instructor.
  • An employee is unlikely to work in more than five programs.
  • An employee’s pay cannot exceed the employee’s manager ‘s salary.

Business Rules

Business rules are acquired from clients when meeting necessities. The prerequisites convention measure is significant, and its outcomes ought to be checked by the client before the information base plan is fabricated. On the off chance that the business rules are inaccurate, the plan will be erroneous, and at last the appeal constructed won’t work true to form by the clients.

A few instances of business rules are:

  •  An educator can show numerous understudies.
  • A class can have a limit of 35 understudies.
  • A course can be shown commonly, however by just a single educator.
  • Not all instructors educate classes.

Result of absence of Referential Integrity

A nonattendance of appropriate uprightness in a database can provoke divided data being returned, generally speaking with no indication of a misstep. This could achieve evidence being “lost” in the database, since they’re remained away perpetually in questions or reports.

It could in like manner achieve odd results appearing in reports, (for instance, things without a connected association).Or of course more lame relation yet, it could achieve customers not getting things they paid for.

More horrible still, it could impact life and passing conditions, for instance, a clinical facility constant not tolerating the correct treatment, or a calamity mitigation bunch not getting the correct supplies or information.

Importance of Referential Integrity

It takes into account the relation to be altered when they should be. Assume you have a relation of directors in a single relation, and a relation of colleagues in another relation, with a recommendation to the colleague’s administrator from the principal relation. In the event that one of the supervisors leaves, and the information base needs to mirror that, the appropriate uprightness framework ensures that in the subsequent relation, the different colleague relation, the meadow for appointed chief gets altered over, as well.

Else, you should have the old name springing up while looking through the subsequent relation.

The entirety of this cycle can likewise be alluded to as making “stability.”

Information base standardisation endeavours frequently add to this cycle also.

Information base standardisation is regularly portrayed as “decreasing a perplexing information formation into a straightforward one” and through these procedures, which incorporate the utilisation of the three “structures” known to overseers, analogic honesty can be normally authorised to a critical degree.

Test of Referential Integrity

An analogic respectability test states that all the unfamiliar keys in a given section connect to the right information in the parent relation. Such a test will be debarring elation for an objective information base that has appropriate uprightness requirements essentially on the grounds that the data set motor will guarantee that this statement is genuine each time it stacks evidence into the information stockroom. Numerous groups turn off appropriate honesty limitations, nonetheless, so the information will stack all the more rapidly. They believe the rationale of the information change component to accomplish analogic respectability. Any time the group plans ETL to execute a significant business rule, it is shrewd to test that it has been actualised accurately. On the off chance that appropriate uprightness requirements in the information base are killed, at that point the task’s QA exertion should anticipate unequivocally testing that the unfamiliar keys resolve without mistake.

Business Rules and Levels of Enforcement

Appropriate trustworthiness is upheld at the information base level in that it controls the respectability of information between relations. You, as the information base fashioner, can likewise get things done at both the meadow and relation levels to help guarantee information uprightness. This is the place the information you picked up of business rules can be actualised and you can help guarantee that the information entered meets the prerequisites of the specific setting for the data set.

As you actualise the business rules, you should report each standard and how and where it is implemented in your plan. Rules do change and the documentation will make it a lot simpler to discover what part of the plan should be adjusted. As you work through them, you may discover some that can’t be worked in at the meadow or relation level in the RDBMS where you are working.

Scope of Referential Integrity in RDBMS and SQL

There are a few benefits of Appropriate Integrity in the general information base and keeping up trustworthiness of details among parent and kid relations. Here is the absolute most saw focal points of Appropriate Integrity in SQL:

  • Appropriate Integrity forestalls entrenching information with erroneous subtleties in relation. Any addition or update activity will fall flat on the off alter that it does not fulfil metaphoric honesty rule.
  • If an information from parent relation is deleted, metaphoric trust benefits permits to delete all connected evidence from youngster relation utilising course erase usefulness.

Authorise Referential Integrity

Authorising Appropriate Integrity for a connection in a Microsoft Access information base can evade the misfortune or unintentional refreshing of information data.

Appropriate Integrity Implementation Instructions:

You can set Appropriate Integrity between two relations in Microsoft Access if coming up next are valid –

  •  Both of the relations are in a similar Microsoft Access information base.
  • The coordinating meadow is a Primary Key in one relation or has an interesting file.
  • The connected meadows have a similar information type (the special case is that an AutoNumber meadow can be identified with a Number information type with a meadow size of Long Integer).

At the point when information base relations are connected together, one relation is typically known as Parent relation and the other (the relation that it is connected to) is generally known as the Child. This is called a parent-kid connection between Microsoft Access relations. Appropriate Integrity ensures that there will never be a vagrant, a youngster evidence without a parent evidence.

Appropriate Integrity works carefully based on the relations key meadows; it examines each time a key meadow, regardless of whether essential or unfamiliar, is included, altered or erased. On the off chance that an altar to a key makes an unwell connection, it is said to disregard analogic uprightness.

The results on Data Softening

At the point when analogic uprightness is authorising, certain guidelines apply to the information. The accompanying rundown gives a few instances of this –

  • You can’t enter an incentive in the Foreign Key meadow of one relation if there is certainly not a coordinating incentive in the Primary Key of the connected relation.
  •  You can’t erase an evidence from the Primary relation (the relation where the essential key is the connected evidence if a coordinating evidence holds in the connected relation.
  •  You can’t alter the incentive in the Primary Key of the essential relation if there is connected evidence in the connected relation.

Valid justifications for Impose Referential Integrity

A nonappearance of appropriate uprightness in a database can incite A Customer ID AutoNumber meadow in the Customers relation is a novel Primary Key and can be connected to a numeric meadow in the Orders relation in a One-To-Many attribute.

You would not want to permit a customer to enter any Order data for a Customer that doesn’t have any evidence in the Customers relation. Nor would you have to permit a customer to change the Customer ID meadow for evidence in the Customer relation, as this would split the association with connected Order data for that Customer.

Deleting a Customer evidence that has organising evidence in the Orders relation would moreover not be permitted.

How Referential Integrity Ensures Database Consistency:

Appropriate honesty is an information base element in social information base management substructure. It guarantees the relationship between relations in an information base stays exact by appealing requirements to keep customers or appeal from entering mistaken evidence or highlighting evidence that doesn’t exist.

Primary Key

The necessary key of an information base relation is an interesting accessory relegated to each evidence. Each relation determines at least one piece assigned as the necessary key. A Social Security number can be an essential key for an information base posting of representatives in light of the fact that every Social Security number is exceptional.

Contingent upon the multifaceted nature of the basic information, it might demonstrate valuable to utilise compound keys as the essential key. For instance, in a representative relation, albeit a Social Security number attempts to distinguish an individual, a mix of the SSN in addition to a recruit date may seclude explicit worker evidence in the event that the individual has joined, left, at that point re-joined the organisation.

 Foreign Key

A new key is an accessory in a relation that arranges the basic key of a substitute relation. The new key makes a connection with a substitute relation. Appropriate decency suggests the association between these relations.

Right when one relation has a new key to another relation, the possibility of appropriate trustworthiness communicates that you may not add any evidence to the relation that holds the new key aside from if there is a contrasting evidence in the associated relation. It moreover joins the approach known as falling update and falling delete, which make sure that alters made to the associated relation are thrown back in the basic relation.

Example of Referential Integrity Rules:

Consider, for example, the condition where you have two relations: Employees and Managers. The Employees relation has a new key quality qualified Managed by, which centres to the evidence for each delegate’s boss in the Managers relation. Appropriate uprightness actualises the going with three standards:

You can’t add an evidence to the Employees relation aside from if the Managed by trademark centres to an authentic evidence in the Managers relation. Appropriate trustworthiness thwarts the consideration of wrong nuances into a relation. Any movement that does not make sure the appropriate dependability rule misfires.

In case the fundamental key for an evidence in the Managers relation changes, all contrasting evidences in the Employees relation are changed using a falling update.

In case any evidence in the Managers relation is deleted, all relating evidence in the Employees relation are eradicated using a falling eradicate.

Advantages of Referential Integrity Constraints

Utilising a social information base administration framework with appropriate uprightness offers a few favourable circumstances:

  •  Stop the segment of copied data
  • Shields one relation from featuring a non-existent meadow in another relation
  • Warranty steadiness between “teamed up” relations
  • Stop the deletion of an evidence that holds a value insinuated by a new key in another relation
  • Stop the extension of an evidence to a relation that holds a new key aside from if there is a basic key in the associated relation

Effect of Referential Integrity constraints:

At the point when relations are associated with appropriate trustworthiness imperatives, the principles for choosing negligible logging are:

  • All DML proclamations on a relation with appropriate uprightness imperatives are in every case completely logged, abrogating any logging settings showed up for the relation dependent on the information base level or meeting explicit settings.
  •   You can’t use modify relation to change the logging method of a relation to insignificant if the relation incorporates appropriate honesty imperatives.
  • You can’t make any appropriate honesty limitations between relations that have negligible logging characterised for them. For instance, making an unfamiliar appropriate honesty limitation from a relation to its essential relation when insignificant logging has been expressly determined to the essential relation raises a mistake.


  1. Ralph Hughes MA, PMP, CSM, in Agile Data Warehousing for the Enterprise, 2016
  2. Date, C. J. (1981, September). Referential integrity. In Proceedings of the seventh international conference on Very Large Data Bases-Volume 7 (pp. 2-12).
  3. Smith, M. D., Hennings, E., & McKee, C. W. (2003). U.S. Patent No. 6,578,078. Washington, DC: U.S. Patent and Trademark Office.
  4. Ordonez, C., & García-García, J. (2008). Referential integrity quality metrics. Decision Support Systems, 44(2), 495-508.
  5. Kappe, F. (1996). A scalable architecture for maintaining referential integrity in distributed information systems. In J. UCS The Journal of Universal Computer Science (pp. 84-104). Springer, Berlin, Heidelberg.


Leave a Comment