From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Anuradha Ratnaweera <Aratnaweera(at)virtusa(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [SQL] Unique constraints for a list |
Date: | 2003-08-29 08:52:33 |
Message-ID: | 200308290952.33833.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
On Friday 29 August 2003 06:50, Anuradha Ratnaweera wrote:
[snipped description of groups consisting of unique lists of members, i.e.
group A contains (1,2,3) so B can't contain the same]
I was looking at something almost identical a few days ago.
> Then we added a unique string field to t3 which is a comma seperated and
> sorted list of group members. But when this is done, the DB is no
> longer normalized.
I looked at this, but I was planning to use this "member_key" as an addition
to the two tables and just keep it up to date with triggers. In your case add
the comma-separated-list to t1 but keep t2. This seemed to work OK speed-wise
and was no less normalised than having a "group_size" field in t1 that
triggers kept up to date.
> Are there any other approaches we can take? Or are we missing something
> obvious here?
The other approach I looked at was to build a new group in a test table, join
its members to the real table and compare the number of matches to the size
of both groups (for this a pre-calculated size came in useful).
If the number of matches equalled the size of both our new list and an
existing list then they were duplicates. The query wasn't as bad as I first
feared, but it definitely helped to build it up one step at a time.
Testing showed that the second method was too slow for my particular need
(bursty updates) but it might work for you.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2003-08-29 09:06:27 | Re: SQL Command - To List Tables ? |
Previous Message | Alex | 2003-08-29 07:43:29 | Re: Fast Table Replication / Mirroring |
From | Date | Subject | |
---|---|---|---|
Next Message | Laurent Patureau | 2003-08-29 10:41:57 | Select Match on PostgreSQL. |
Previous Message | Anuradha Ratnaweera | 2003-08-29 05:50:56 | Unique constraints for a list |