Re: modeling a network in an rdbms

From: Troels Arvin <troels_at_arvin.dk>
Date: Thu, 10 Nov 2005 20:49:26 +0100
Message-ID: <pan.2005.11.10.19.49.25.665311_at_arvin.dk>


On Thu, 10 Nov 2005 06:01:22 -0800, TrueBlue wrote:

> I'm having a tough time finding a simple answer to this conundrum.
> I have an RDBMS, no technology change allowed. Can anyone suggest a
> relational model to structure a network? The key goal would be to draw
> n relationships between nodes in an ever-increasing node number.

Have a table with nodes:

CREATE TABLE node (node_id WHATEVERTYPE PRIMARY KEY,...); CREATE TABLE edge
(
  node1 WHATEVERTYPE REFERENCES node,
  node2 WHATEVERTYPE REFERENCES node,
  PRIMARY KEY(node1,node2)
);

If needed, you may add an optimization-table with pre-computed paths, i.e. a transitive closure table. Inspiration:

-- 
Greetings from Troels Arvin
Received on Thu Nov 10 2005 - 20:49:26 CET

Original text of this message