> -----Original Message-----
> From: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-
> boun...@mailinglists.sqlite.org] On Behalf Of James K. Lowden
> Sent: Tuesday, June 14, 2016 9:48 AM
> To: sqlite-users@mailinglists.sqlite.org
> Subject: Re: [sqlite] Trouble coding conditional UNIQUE
>
> On Mon, 13 Jun 2016 19:11:29 +0000
> "Drago, William @ CSG - NARDA-MITEQ" <william.dr...@l-3com.com>
> wrote:
>
> > I need UNIQUE(B, C) only when E=0.
>
> A conditional constraint is evidence that you have two kinds of things
> represented in one table: those E=0 types that are identified by {B,C}, and
> the rest.  They're represented in a single table because they seem to have
> the same columns, although the E=0 types don't need an E column.
>
> A better solution might be to separate the two types into to two tables, each
> with its own constraints, and use a UNION to represent them as one.

I'm grouping parts with temporary, reusable serial numbers into matched sets of 
4.
The temporary serial numbers are stick-on labels with alphanumeric text like 
red5, blu7, grn2.
There are duplicates within this pool and the colors don't mean anything.
Before the parts are matched I can't allow more than one part to have the same 
temporary serial number, so as long as Matched=0 (Model, TemporarySerialNumber) 
must be unique.
Once the part has been grouped into a set (Matched=1) it receives a unique 
permanent serial number and the temporary serial number can be reused, so 
(Model, TemporarySerialNumber) doesn't have to be unique anymore.
Information about what parts belong to what set is stored in a different table.

So is using a conditional constraint in this case okay, or is there a better 
way?

Thanks,
--
Bill Drago
Staff Engineer
L3 Narda-MITEQ
435 Moreland Road
Hauppauge, NY 11788
631-272-5947 / william.dr...@l-3com.com
CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any 
attachments are solely for the use of the addressee and may contain information 
that is privileged or confidential. Any disclosure, use or distribution of the 
information contained herein is prohibited. In the event this e-mail contains 
technical data within the definition of the International Traffic in Arms 
Regulations or Export Administration Regulations, it is subject to the export 
control laws of the U.S.Government. The recipient should check this e-mail and 
any attachments for the presence of viruses as L-3 does not accept any 
liability associated with the transmission of this e-mail. If you have received 
this communication in error, please notify the sender by reply e-mail and 
immediately delete this message and any attachments.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to