Re: Hierarchical Query Question (PHP)

From: David Blomstrom <david(dot)blomstrom(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Hierarchical Query Question (PHP)
Date: 2015-10-30 23:09:19
Message-ID: CAA54Z0iST+DSah5UAkTCn2uKqx5tT7B+zNdHRU-wGwn6DWYQfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sorry, I don't think I specified that at the beginning.

My original/master table has several fields, four of which are relevant to
this hierarchical stuff - id, taxon, parent, parent_id.

The first is a numerical key, from 1 to probably somewhere around 8,000 for
mammals, 1 to 10,000 for birds, etc. The field taxon holds the names of
taxons (e.g. 'Mammalia', 'Canis-lupus'). The field parent holds the names
of each taxon's parent. The field parent_id is just a series of numerals
matching each taxonomic level. The value is 1 for Mammalia, 2 for each
mammal order, 3 for each family, 4 for genera and 5 for species. It looks
something like this:

ID | TAXON | PARENT | PARENT_ID
1 | Mammalia | Chordata | 1
2 | Carnivora | Mammalia | 2
3 | Canidae | Carnivora | 3
4 | Canis | Canidae | 4
5 | Canis-lupus | Canis | 5
6 | Canis-latrans | Canis | 5

I wonder if that's what you had in mind with taxonid. Should I just rename
parent_id to taxon_id?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Blomstrom 2015-10-30 23:38:00 Re: Hierarchical Query Question (PHP)
Previous Message Rob Sargent 2015-10-30 23:02:23 Re: Hierarchical Query Question (PHP)