From: | Peter Childs <blue(dot)dragon(at)blueyonder(dot)co(dot)uk> |
---|---|
To: | |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: PK and FK relation ship |
Date: | 2003-09-11 07:26:36 |
Message-ID: | Pine.LNX.4.44.0309110816240.27174-100000@RedDragon.Childs |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Thu, 11 Sep 2003 shyamperi(at)davlin(dot)co(dot)in wrote:
> Can any one tell me when would a primary key be refered to as foreign key in
> its own table.
>
Simple Trees.
If you need a parent child relationship the simplest way of
expressing it is to have a parent columnn and store the parent key in it.
If its null it must be the root.
Its really quite good for finding parents and children of a
record. (Children are "SELECT * from table where parent=<n.id>`;" parent
is "SELECT * from table where id=<n.parent>;")
Could also be used for storing a linked list or double linked
list.
Find any standard algorithims book and try and implement the lot
in a database. (Its not easy as SQL has a lot of missing features that
even C, C++ or even VB has!)
Peter Childs
From | Date | Subject | |
---|---|---|---|
Next Message | Donald Fraser | 2003-09-11 10:15:02 | Views |
Previous Message | shyamperi | 2003-09-11 06:45:59 | PK and FK relation ship |