Re: [GENERAL] Deleted Flag/Unique Constraint

2007-04-02 Thread Bryan Murphy
Yeah, personally, I'm not entire 100% convinced of the concept myself and am actively investigating alternatives. Most of what I'm doing right now is simple research, as well as trying out a few ideas to see what works in practice and what doesn't. Unfortunately, this is one of those areas where

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-04-02 Thread Lew
*Jonathan Hedstrom* wrote Yes, something like this: CREATE UNIQUE INDEX index_name ON table_name ( unique_field) WHERE deleted=0; My only concern here is Note: The preferred way to add a unique constraint to a table is ALTER TABLE ... ADD CONSTRAINT. The use of indexes to enforce unique const

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-04-02 Thread Lew
Bryan Murphy wrote: I think the other guys suggestion will work better. ;) Really, the table was just an example off the top of my head. I believe we do use a boolean as the deleted flag. We primarily use it to track the user who originally created an item (even if their account is deleted)

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-03-29 Thread John D. Burger
Bryan Murphy wrote: I think the other guys suggestion will work better. ;) Good lord, yes. Dunno what I was thinking - I use partial indexes all the time, and I know a unique constraint is implemented with an index. Just got carried away, I guess. :) - John Burger MITRE

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-03-29 Thread Bryan Murphy
I think the other guys suggestion will work better. ;) Really, the table was just an example off the top of my head. I believe we do use a boolean as the deleted flag. We primarily use it to track the user who originally created an item (even if their account is deleted). It's a bit like a fin

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-03-29 Thread Jonathan Hedstrom
Bryan Murphy wrote: Is it possible to declare a unique constraint in combination with a deleted flag? For example, if I have a table like this: CREATE TABLE ( ID NOT NULL PRIMARY KEY, Key VARCHAR(32) NOT NULL, Value VARCHAR(32) NOT NULL, Deleted INT NOT NULL DEFAULT 0 ); can I declar

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-03-29 Thread Bryan Murphy
Thanks! That works great! Bryan On 3/29/07, Jonathan Hedstrom <[EMAIL PROTECTED]> wrote: Bryan Murphy wrote: > Is it possible to declare a unique constraint in combination with a > deleted flag? > > For example, if I have a table like this: > > CREATE TABLE > ( > ID NOT NULL PRIMARY KEY, >

Re: [GENERAL] Deleted Flag/Unique Constraint

2007-03-29 Thread John D. Burger
On Mar 29, 2007, at 17:39, Bryan Murphy wrote: Is it possible to declare a unique constraint in combination with a deleted flag? For example, if I have a table like this: CREATE TABLE ( ID NOT NULL PRIMARY KEY, Key VARCHAR(32) NOT NULL, Value VARCHAR(32) NOT NULL, Deleted INT NOT NUL

[GENERAL] Deleted Flag/Unique Constraint

2007-03-29 Thread Bryan Murphy
Is it possible to declare a unique constraint in combination with a deleted flag? For example, if I have a table like this: CREATE TABLE ( ID NOT NULL PRIMARY KEY, Key VARCHAR(32) NOT NULL, Value VARCHAR(32) NOT NULL, Deleted INT NOT NULL DEFAULT 0 ); can I declare a unique constraint that