Re: SQL Intersect like problem

From: Dinesh Visweswaraiah <dinesh(at)trailblazingsolutions(dot)com>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Dinesh Visweswaraiah <dinesh(at)trailblazingsolutions(dot)com>, pgsql-novice(at)postgresql(dot)org, Bruno Wolff III <bruno(at)wolff(dot)to>
Subject: Re: SQL Intersect like problem
Date: 2003-02-06 15:17:15
Message-ID: jUsT.aNoTheR.mEsSaGe.iD.104454548526934@trailblazingsolutions.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Oliver,

Actually the story is a little different. I used Invoice and Product
and Quantity because everybody understands those. Reality is that
this is a table that has AuthorizationSetId, UserId and Privileges.
Objects in my application have a set of authorizations with specified
userid and privileges, specifying who is permitted to do what. The
Idea is to identify a AuthorizationSetId so that when the set of
UserId and Privileges change, I can reuse a AuthorizationSetId rather
than create a new one. In fact without reuse, there is no point
in having a AuthorizationSetId in the first place.

There will be some sets that get discarded and will be lying in the
database. I was planning on having a periodic (say weekly) cleanup
process that will delete these unused sets.

Since these details were auxilliary to the real problem I thought
maybe I can avoid confusing people. I ended up doing exactly that
:-(

To paraphrase the situation-
Given a Master/Detail relationship. How to find a Master from the
Details. Which is the reverse of what is usually done. Given a
Master we find Details.

Hope this clarifies things.

Thanks,
Dinesh
At 06 February 2003, Oliver Elphick <olly(at)lfix(dot)co(dot)uk> wrote:

>On Wed, 2003-02-05 at 16:39, Bruno Wolff III wrote:
>> On Wed, Feb 05, 2003 at 10:17:09 -0500,
>> Dinesh Visweswaraiah <dinesh(at)trailblazingsolutions(dot)com> wrote:
>> > Bruno,
>> >
>> > I am sorry for being very clear. The need is to identify an
InvoiceId
>> > from a *set* of ProductId and Quantity values. A simple join will
>> > not work because it is not one value of ProductId and one value of
>> > Quantity.
>
>Unless you are clearing these tables very frequently, it seems to
me you
>will very soon find duplicate combinations. It is very likely (perhaps
>not in your case?) that customers will repeat an order with the same
>products and quantities as before, or that more than one customer will
>send in the same order.
>
>Why do you not add the invoiceid to the table with the products and
>quantities? This is the standard way to identify invoice lines
with the
>invoice.
>
>--
>Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
>Isle of Wight, UK http://www.lfix.co.
uk/oliver
>GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
> ========================================
> "He hath not dealt with us after our sins; nor rewarded
> us according to our iniquities. For as the heaven is
> high above the earth, so great is his mercy toward
> them that fear him. As far as the east is from the
> west, so far hath he removed our transgressions from
> us." Psalms 103:10-12
>
>---------------------------(end of broadcast)-------------------
--------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>message can get through to the mailing list cleanly
>

Dinesh
Cell:703-725-4153
Email:dinesh(at)trailblazingsolutions(dot)com
Web Site:http://www.trailblazingsolutions.com/dinesh

The significant problems we face cannot be solved by the same level
of thinking that created them - Albert Einstein

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Steve_Miller 2003-02-06 15:24:51 Favorite Linux Editor for PostgreSQL Scripts?
Previous Message Tom Lane 2003-02-06 14:49:17 Re: how can I tell it's postgresql data?