Re: Foreign keys? - Mailing list pgsql-general

From Richard Huxton
Subject Re: Foreign keys?
Date
Msg-id 00b701c10b7c$b3a3ef00$1001a8c0@archonet.com
Whole thread Raw
In response to Re: Foreign keys?  (Jason Earl <jdearl@yahoo.com>)
Responses Re: Foreign keys?  (Jason Earl <jdearl@yahoo.com>)
List pgsql-general
From: "Jason Earl" <jdearl@yahoo.com>

> However, if you are going to do a lot of joins on your
> user table along the lines of:
>
> SELECT user.name, object.description FROM user, object
> WHERE user.number = object.owner;
>
> Then you might be better off simplifying just a bit to
> give you something like:
>
> CREATE TABLE user (
>        name VARCHAR(400) PRIMARY KEY
> );
>
> CREATE TABLE object (
>        owner VARCHAR(400) REFERENCES user NOT NULL,
>        description VARCHAR(200)
> );
>
> That would save you having to join the table to find
> the user.name at the expense of using more hard drive
> space.

I'm curious - are you speaking from a performance viewpoint here, or just
about simplifying queries (in which case I'd just slap a view on top)?

- Richard Huxton


pgsql-general by date:

Previous
From: "Richard Huxton"
Date:
Subject: Re: \df+ and pg_proc query
Next
From: Micah Yoder
Date:
Subject: Re: Re: Pg7.2 (was: vacuum and 24/7 uptime)