articles

Home / DeveloperSection / Articles / Referential Integrity in SharePoint 2010

Referential Integrity in SharePoint 2010

Referential Integrity in SharePoint 2010

Chris Anderson13693 08-Dec-2011

In this article, I am going to explain how to implement referential integrity between lists in SharePoint Foundation 2010.

I have created two lists "Course (Parent list)" and "Student (Child list)". The parent list (Course) contains four columns i.e. Title, Course_ID, Course_Name and Duration and child list (Student) contains four columns i.e. Title, Student_ID, Student_Name, and Course. In the "ChildList (Student)" I am creating a lookup column (Course) which will take values from the "ParentList (Course) column (Course_ID)". Whenever you create a lookup column you can see "Relationship" where you can maintain referential integrity enforcing the relationships defined by lookup columns. Just like foreign key constraints in a relational database, in SharePoint 2010 you can configure restrict delete and cascade delete rules on lookup column relationships.

Cascade Delete:When an item in the parent list is deleted, the cascade delete will delete all related items from the child lists.

Restrict Delete:It will prevent the deletion of an item in the parent list if it has one or more related items in the child list. When you try to delete an item in the parent list you will get the error message.

Here I am going to implement both Cascade and Restrict deletion:

1) Restrict Deletion:

·   Create a Course List (Parent List):
Site Actions
à More Options…à List à Custom List.

Referential Integrity in SharePoint 2010

Add columns and courses in the Course list as shown in the list below:

Referential Integrity in SharePoint 2010

·      Create a Student List (Child List):
Site Actions
à More Options…à List à Custom List.

Note: While creating a Course column in the Student list chooses the following option as shown in the below figure:

Referential Integrity in SharePoint 2010

Referential Integrity in SharePoint 2010

Referential Integrity in SharePoint 2010

Referential Integrity in SharePoint 2010

Now when you attempt to delete the information present in the child list (Student) from the parent list (Course) it will give an error as shown in the below dialog box:

Referential Integrity in SharePoint 2010

1) Cascade Deletion:

In order to implement cascade deletion change the Course column relationship behaviors of the Student table into Cascade delete.

Student Listà List Tools à List ribbon à List Settings.

Referential Integrity in SharePoint 2010

Change the column (Course) behavior to Cascade delete:

Referential Integrity in SharePoint 2010

Now when you attempt to delete the information from the parent list (Course) it will also remove the matching information from the child list (Student).

Here I am going to delete the course id from the Course list that is also present in the Student list:

Referential Integrity in SharePoint 2010

It will remove the matching course id present in the Student list:

Referential Integrity in SharePoint 2010

Thanks for reading this article. I think this will help you a lot.


Updated 27-May-2020
hi I am software developer at mindstick software pvt. ltd.

Leave Comment

Comments

Liked By