Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to implement link list

Re: How to implement link list

From: Allen Kirby <akirby_at_att.com>
Date: 1997/01/02
Message-ID: <32CBD391.6937@att.com>#1/1

Wong Ming Ho wrote:
>
> Hello All,
>
> Does there any way to implement link list inside Oracle?
> Thanks for advance
>
> :O
>
>
> csmhwong_at_cs.ust.hk

I think what you are referring to is a table which references itself recursively with a previous and next pointer, or just a next depending on the type of list. The safe way to do this is to simply add foreign keys to reference the previous and next rows. That way you are independent of physical data changes since your links are at the logical level. The other (not suggested) way to do it is to store the links as rowids instead of foreign keys. You'll gain a little in retrieval time but every time a row moves you'll have update nightmares. Please note, however, that you'll have to do a query to get the next or previous row each time, unless you read the entire table into memory and access each row yourself (if you're doing that, why use a relational db at all?). You can cut down the queries by doing joins but this complicates the access.

e.g.

Mytable



Primary key is Mfr,Make,Model
Mfr		varchar(20)
Make		varchar(20)
Model		varchar(20)
Stuff		varchar(20)
NextMfr		varchar(20
NextMake	varchar(20)
NextModel	varchar(20)
PrevMfr		varchar(20
PrevMake	varchar(20)
PrevModel	varchar(20)
-- 
---
Allen Kirby			AT&T ITS Production Services
akirby_at_att.com			Alpharetta, GA.
Received on Thu Jan 02 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US