Re: Hierarchical Query Question (PHP)

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: Hierarchical Query Question (PHP)
Дата
Msg-id 5633ED70.6090701@iol.ie
обсуждение исходный текст
Ответ на Re: Hierarchical Query Question (PHP)  (David Blomstrom <david.blomstrom@gmail.com>)
Ответы Re: Hierarchical Query Question (PHP)
Список pgsql-general
On 30/10/2015 22:10, David Blomstrom wrote:
> Just so I understand what's going on, I can create a lookup table by
> pasting this code...
>
> create table taxon (
>   taxonid serial,
>   descr text
> );
> create table gz_life_mammals (
>   id serial,
>   taxonid integer, -- use the lookup table
>   parentid integer -- use the lookup table
> );
>
> ...into pgAdmin III, right? (I can't use the shell/terminal at the
> moment, and it will be at least a few weeks before I can get it fixed.)
> And this script will create TWO tables - gz_life_mammals and a matching
> "lookup table"?

Yes, it will. I haven't seen, what went before in this thread so may
have missed stuff, but you should also add a foreign key constraint
between the tables (for taxonid anyway, dunno what parentid refers to):

create table gz_life_mammals (
   id serial,
   taxonid integer, -- use the lookup table
   parentid integer, -- use the lookup table

  constraint mammals_taxon_fk foreign key (taxonid) references
taxon(taxonid)

);


If parentid also references taxon.taxonid, add a similar constraint for
it too,

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie


В списке pgsql-general по дате отправления:

Предыдущее
От: Rob Sargent
Дата:
Сообщение: Re: Hierarchical Query Question (PHP)
Следующее
От: David Blomstrom
Дата:
Сообщение: Re: Hierarchical Query Question (PHP)