Welcome Guest, Not a member yet? Register   Sign In
Database row pseudo-deletion
#1

[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?
#2

[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.
#3

[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.




Theme © iAndrew 2016 - Forum software by © MyBB