I worked in big project last year, it was Educational Management System! My team solved a lot of problems during developing. But we had one problem and now I am again got it.
Problem is:
how to design database structure, if some records that have references can be deleted from Software Interface?
Simple Example: Assume that, you have tables :
Students, StudentClass, Marks, Classes
. So, if I try to delete record from 'Classes'
table, it will be impossible, because 'StudentClass'
table has reference to 'Classes'
table. Of course, it is possible delete records from depending tables(StudentClass, etc.
) and then delete 'Classes'
record, but i need to keep data.
I found solution, in all tables that is referenced by other, i create column 'IsDeleted'
.
It means that If i want to delete record from 'Classes'
table, i just update 'IsDeleted'
column to 1
. To show to users, i use "SELECT * .... FROM ... WHERE Classes.IsDeleted = 0".
This my solution! Can you tell me, how you solve such problems, share with me your approaches, pls! Any opinions will be interesting for me! Thanks in advance for your reply!!!!
EDIT:
Any solutions else?