From: | Ken Corey <ken(at)kencorey(dot)com> |
---|---|
To: | Chad Thompson <chad(at)weblinkservices(dot)com> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Database Structure |
Date: | 2002-08-07 21:06:49 |
Message-ID: | 1028754410.27171.337.camel@kenlinux.bithub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wed, 2002-08-07 at 16:31, Chad Thompson wrote:
> I have 3 tables. Clients, Projects, and Lists. There is a one to many relation between Clients and Projects, and Clients and Lists.
> That is to say that a client can have multiple projects and these projects can use any or all of his lists.
>
> This works fine, the wrinkle comes in when i have a client, who has clients who have their own lists.
> I treat this just as a client with different projects, but the lists now need to be associated with this project only, and no longer with every project that this client has.
>
> Should I create another table to handle these exceptions? or is there a more elegant way.
If you will only ever have two levels of indirection, you could have a
'client' column and a 'client parent' column, and perform your selects
appropriately.
However, this seems like a kludge in that you're measuring two different
types of relationships using a single table.
One relationship is between a client and a project.
The other relationship is between a client's client and a project (you
don't mention whether it's useful to know the super-parent for a given
project, but I'll assume that it is).
Something tells me to describe the relationship in different tables:
client (id, name, ...)
projects (id, description, ...)
client_projects (client_id, projects_id)
client_cust (client_id, customer_client_id)
So, the client_projects table relates the clients to projects. There's
no reason why a single project might be 'owned' by several clients, and
you could query either the client's client, or by the client.
The client_cust table describes the relationship between your clients,
and their clients.
Thoughts?
-Ken
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-08-08 02:12:20 | Re: Permissions problem on new install |
Previous Message | eric soroos | 2002-08-07 18:45:35 | Effective limit on size of text type? |