Re: Recursive Arrays 101 - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Recursive Arrays 101
Date
Msg-id 562D2191.4030404@aklaver.com
Whole thread Raw
In response to Re: Recursive Arrays 101  (David Blomstrom <david.blomstrom@gmail.com>)
Responses Re: Recursive Arrays 101  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general
On 10/25/2015 11:12 AM, David Blomstrom wrote:
> I'm sorry, I don't know exactly what you mean by "definitions." The
> fields Taxon and Parent are both varchar, with a 50-character limit.
> ParentID is int(1).

By definition I meant the schema, so from the below:

CREATE TABLE t (
  N INT(6) default None auto_increment,
  Taxon varchar(50) default NULL,
  Parent varchar(25) default NULL,
  NameCommon varchar(50) default NULL,
  Rank smallint(2) default 0
  PRIMARY KEY (N)
) ENGINE=MyISAM

>
> Here's a discussion that describes the table in a little more detail --
> http://stackoverflow.com/questions/33248361/hierarchical-query-in-mysql-ii
>
> And this is the discussion where someone suggested I check out
> PostgreSQL --
> http://stackoverflow.com/questions/33313021/displaying-simple-counts-from-stored-procedure
>

Seems to me it would be easier to use what already exists:

Kingdom, Phylum, Class, Order, Family, Genus, and Species.

So.

Kingdom table <--> Phylum table <--> Class table <-->, on down the line.

Where the tables are linked by Foreign Keys(something not possible with
MyISAM).

See:

http://www.postgresql.org/docs/9.5/static/sql-createtable.html

"REFERENCES reftable [ ( refcolumn ) ] [ MATCH matchtype ] [ ON DELETE
action ] [ ON UPDATE action ] (column constraint)
FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn
[, ... ] ) ] [ MATCH matchtype ] [ ON DELETE action ] [ ON UPDATE action
] (table constraint)"

--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: David Blomstrom
Date:
Subject: Re: Recursive Arrays 101
Next
From: Alban Hertroys
Date:
Subject: Re: Recursive Arrays 101