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
*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
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)
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
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
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
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,
>
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
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