Re: Hierarchical Query Question (PHP) - Mailing list pgsql-general

From David Blomstrom
Subject Re: Hierarchical Query Question (PHP)
Date
Msg-id CAA54Z0iST+DSah5UAkTCn2uKqx5tT7B+zNdHRU-wGwn6DWYQfQ@mail.gmail.com
Whole thread Raw
In response to Re: Hierarchical Query Question (PHP)  (Rob Sargent <robjsargent@gmail.com>)
Responses Re: Hierarchical Query Question (PHP)  (David Blomstrom <david.blomstrom@gmail.com>)
List 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?

pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: Hierarchical Query Question (PHP)
Next
From: David Blomstrom
Date:
Subject: Re: Hierarchical Query Question (PHP)