Re: Querying same lookup table with multiple columns based on another view

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Killian Driscoll <killiandriscoll(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Querying same lookup table with multiple columns based on another view
Date: 2015-11-17 16:11:44
Message-ID: 564B51C0.1010200@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 17/11/2015 16:07, Killian Driscoll wrote:
>
> >
> > In terms of database structure and typing efficiency, it might be better
> > to restructure the lookup tables and create a new lookup table for each
> > of the three columns instead of one combined one?
>
> [Please keep you replies on-list - thanks!]
>
>
> Sorry! Didn't mean that....
>
>
> You'd better show us your table structures - we're only guessing
> otherwise. However, I think typing efficiency isn't important, but
> rather what your application needs to do with the data - you only type
> the query once. :-)
>
>
> In terms of structure I'm going to go with separate lookup tables as
> they are and should be distinct really.
>
> I'm using pstgresql 9.3. I have set up the new lookup tables and now
> want to alter the fk constraints but keep the data already there (the
> new lookup tables with maintain the old pks). Below is one of the
> constraints:
>
> CONSTRAINT macro_lookupg_macroscopic FOREIGN KEY (grain_id)
> REFERENCES irll.macro_lookup (macro_lookup_id) MATCH SIMPLE
> ON UPDATE CASCADE ON DELETE RESTRICT.
>
> In 9.3 is there an alter constraint option or do I have to drop the
> constraint and add the new one?

I just had a quick look at the docs for 9.3:

http://www.postgresql.org/docs/9.3/static/sql-altertable.html

I don't see ALTER CONSTRAINT in there, so it looks as if you need to
drop and re-create it.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2015-11-17 16:12:03 Re: Querying same lookup table with multiple columns based on another view
Previous Message Killian Driscoll 2015-11-17 16:07:12 Re: Querying same lookup table with multiple columns based on another view