How to virtually delete data from multiple tables that are linked by a foreign key ?

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-03-15T14:40:47Z Indexed on 2010/03/15 14:49 UTC
Read the original article Hit count: 279

alt text

I am using Sql Server 2005

This is a part of my database diagram. I want to perform deletion on my database which will start from tblDomain up tp tblSubTopics.

Consider that each table has IsDeleted column which has to be marked true if request was made to delete data. But that data shoud remain their physically.

Tables which will have IsDeleted Column are

tblDomain tblSubject tblTopic tblSubTopic

Now I want, if a user marks one domain as deleted then all the refrence field should also get marked as deleted. i.e.

1 domain is related to 5 subjects, those 5 subjects are related to 25 topics, those 25 topics are related to 500 subtopics and so on.

Then how should i mark all these fileds as Deleted. ?

© Stack Overflow or respective owner

Related posts about sql

Related posts about database