CodeIgniter Forums
Database row pseudo-deletion - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database row pseudo-deletion (/showthread.php?tid=22921)



Database row pseudo-deletion - El Forum - 09-23-2009

[eluser]Madmartigan1[/eluser]
Hi guys,

In most of my database tables, I use a field called 'active' for when a user 'deletes' a record.

TINYINT, DEFAULT 1

0 = deleted
1 = not deleted

The sql to select the records will always have 'WHERE active=1', unless for some reason I'm displaying 'deleted' data.

I know this is splitting hairs, but I was wondering if it might be better to use a field called 'deleted' with a default of 0. Is it better to use 'WHERE active != 0' with the first method? It probably makes no difference.

What do you guys usually do? Is there a standard for this technique?


Database row pseudo-deletion - El Forum - 09-23-2009

[eluser]Damien K.[/eluser]
Is the glass half full or half empty?

Boils down to preference and how the field describes the record. For product item records, it makes sense to me to have deleted/is_deleted. For like user records, active might make sense to some people.


Database row pseudo-deletion - El Forum - 09-24-2009

[eluser]stommert[/eluser]
as you state, it doesn't make any difference. What's important is that when you read your query it makes sense. (as it does in your case)
The next thing that's important that you are consistant. So ones you use active as a delimiter, use it everywhere.
I prefer to use deleted for no particular reason.