C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
4
Reply
What is referential integrity?
Ahsan Siddique
7y
6.3k
6
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
Referential integrity is a relational database concept.This is the most common type of integrity constraint. This is used to manage the relationships between primary and foreign keys. Referential integrity is best illustrated by an example.Let's assume the department and employee entities have been implemented as tables in a relational database system.When entering a new employee, the department in which they work needs to be specified. Department number is the foreign key in the employee table and the primary key in the department table.In order to preserve the integrity of the data in the database there are a set of rules that need to be observed:If inserting an employee in the employee table, the insertion should only be allowed if their department number exists in the department tableIf deleting a department in the department table, the deletion should only be allowed if there are no employees working in that departmentIf changing the value of a department number in the department table, the update should only be allowed if there are no employees working in the department whose number is being changedIf changing the value of a department number in the employee table, the update should only be allowed if the new value exists in the department tableIf any of the above is allowed to happen then we have data in an inconsistent state. The integrity of the data is compromised - the data does not make sense.
Rajneesh Chaubey
7y
6
Referential integrity (RI) is a relational database concept, which states that table relationships must always be consistent. In other words, any foreign key field must agree with the primary key that is referenced by the foreign key. Thus, any primary key field changes must be applied to all foreign keys, or not at all. The same restriction also applies to foreign keys in that any updates (but not necessarily deletions) must be propagated to the primary parent key.
Bharathi Raja
7y
2
category should not be .NET
Nilesh Shah
7y
2
Foreign Key releationship in database
Udit Chauhan
7y
0
How many ways are there for a page to pass something/data to another page?
What is Composition and Aggregation? And difference among both
Message