I have a table of user relationship which stores who follows whom, the table str
ID: 651510 • Letter: I
Question
I have a table of user relationship which stores who follows whom, the table structure is as follows
when someone follows any other user, I add a record with follower user id and id of user he is following, now my question=> When user wants to unfollow that user, I have decided rather than deleting the record I can add another column break at the end of this table, which I will set to true when user wants to unfollow, this way I can maintain consistency in the records, that is there wont be any gap like 1,2,4,7,8,9,15 if I delete records. If I dont delete the record, I can use it if that user want to follow that user again in future I can set break column of that record to false and the relationship will exist again..what do you guys think should I use this approach or I should delete the record? Tell me if the approach is good or there could be any issues associated with it and also tell me if there is any better way you know.
Thanks
Explanation / Answer
In general flagging records as inactive isn't uncommon and would work as you describe it, you often find flags like "deleted" when there is a good reason to keep the information that something existed at some time, for example there are other records that relate to its id.
An alternative way would be a date field that is null unless deletion, in case you need to know when deletion happened.
But in your special case it seems useless to keep old records. Why would you worry about gaps in the id? Happens all the time.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.