Re: Efficient sorting the results of a join, without denormalization - Mailing list pgsql-general

From Glen M. Witherington
Subject Re: Efficient sorting the results of a join, without denormalization
Date
Msg-id 1433047405.880573.282526153.009601AE@webmail.messagingengine.com
Whole thread Raw
In response to Re: Efficient sorting the results of a join, without denormalization  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Efficient sorting the results of a join, without denormalization
List pgsql-general


On Sat, May 30, 2015, at 11:33 PM, David G. Johnston wrote:
> This is one problem with using made up surrogate keys...
>
> The PK of A is a component of both the PK of B and the PK of C but you throw that information away by using serial
fieldsfor PKs instead.  You should have unique indexes on B and C that incorporate the ID from A 

That is quite a strange schema, though isn't it? If you imagine it as
emails:

C = Emails
B = Folder
A = User

Now you're suggesting that even though an email belongs to to a folder,
which belongs to a user ... each email should also contain contain a
reference to a user? I guess that's fine, but seems unideal from a
redundancy perspective

>
> All that said you really should put indexes on the foreign keys...

Yeah, of course. I purposely left that out, as I was asking which
indexes would need to be created to support that query


Thanks for your help!


pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Efficient sorting the results of a join, without denormalization
Next
From: Rishi Gokhale
Date:
Subject: date type changing to timestamp without time zone in postgres 9.4