Re: Querying all documents for a company and its projects etc

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Querying all documents for a company and its projects etc
Date: 2014-04-16 08:11:39
Message-ID: OfficeNetEmail.9c.cf530626f9893b14.14569930676@prod2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

På mandag 14. april 2014 kl. 21:55:26, skrev David G Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com <mailto:david(dot)g(dot)johnston(at)gmail(dot)com>>: A couple of
thoughts:

1) The "union" really only pertains to the entity table rows; once you
"union all" those (duplicates should not matter and probably will not even
be present so using "all" avoids an unnecessary sort) you can join that
sub-query to the document_usage table.

2) Since every entity must have an associated company moving the company_id
field to the entity table will allow a direct search for company objects
using entity alone and remove the need to perform the union.  The "company"
table omits the implicit self-referencing company_id but it is still there
in reality.

David J.     Thanks for having a look at it.   I'm afraid I don't understand
what you mean in 1); Can you give an example of the query you're suggesting,
joining "that subquery"?   2) Note that I need the names of the company owning
each entity(person, project etc.), and the details about those entities (name
and ID), and in my real app there are more entities which are not directly
related to company, but indirectly thru a project (ie. a task) and I want to be
able to list those entities' documents too.   Do you have a suggestion for a
better $subject for this kind of problem?   thanks.   --
Andreas Joseph Krogh <andreak(at)officenet(dot)no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc  

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dev Kumkar 2014-04-16 08:48:04 Heartbleed Impact
Previous Message Alberto Cabello Sánchez 2014-04-16 06:52:25 Re: Trouble installing Slony 2.0