pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Johan Henselmans <johan@netsense.nl>
Cc: pgsql-sql@postgresql.org
Subject: Re: grouping a many to many relation set
Date: Wed, 1 Dec 2004 19:45:56 -0700
Message-ID: <20041202024556.GA40090@winnie.fuhr.org> (raw)
In-Reply-To: <cojmh2$2iht$1@news.hub.org>
References: <EA79F36B-4244-11D9-97F6-000D9328C5BC@netsense.nl>
	<41AC3C7E.10201@archonet.com>
	<cojmh2$2iht$1@news.hub.org>

On Wed, Dec 01, 2004 at 06:57:54AM +0100, Johan Henselmans wrote:
> Richard Huxton wrote:
>
> > I think what's missing here is the explicit statement of which group 
> > these belong in. Without a value to sort/group by, there's nothing for 
> > your queries to "get a grip on".
> >
> > So - add a "group_id" column to the bank-book and receipt tables. Create 
> > a sequence to generate group id's on demand.
>
> Thanks for the reply. Adding a group_id column would defeat the whole 
> purpose of the relational model. I do not want to add a grouping 
> beforehand.

How is an application going to know which records belong to which
groups without a group ID?  Or is a group ID acceptable as long as
it's not part of the data, but rather generated by the query or
function that does the grouping?

> The grouping should take place according to certain criteria, in
> this case: group all the records that have at least one of two
> attributes in common.

What about chains like this:

 bankbookdetid | receiptid
---------------+-----------
           100 |         1
           100 |         2
           101 |         2
           101 |         3
           102 |         3
           102 |         4

Should 1 be grouped with 2, 3, and 4 since 1 has an attribute in
common with 2, 2 has an attribute in common with 3, and 3 has an
attribute in common with 4?  Or doesn't your model permit this
situation?

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (5+ messages)  latest in thread

Message-ID: <20041202024556.GA40090@winnie.fuhr.org>
Permalink:  ../20041202024556.GA40090@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20041202024556.GA40090@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, johan@netsense.nl
  Subject: Re: grouping a many to many relation set
  In-Reply-To: <20041202024556.GA40090@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox