Hi,

I habe a table where we store tree-ish data using a self-referential
mapper (same setup as within the SA docs using an id for the nodes
and a pointer back to the parent node given by its id)...this works
without a problem.

Now comes the tricky part: a node from one tree can point to a node
within another tree for sharing a common subtree. In this example tree 2
is something like a "master" tree and tree 1 derives the subtree 'N' from tree 2. The link between to nodes is a dedicated 'share_id' where in this particular case the row for node 'C' contains the id of node 'N' as 'share_id'.


  Tree 1              Tree 2

    A                    M
   / \                  / \
  B   C ----------->   N   O
 / \                  /\
D   E                P  Q


I am using this model since some years for the application (hand-made Python code/SQL queries) but now I want to adopt it to SA.

The basic question is how I would extend the configuration for the self-referential mapper in order to make Tree 1 appear as:

    A
   / \
  B   N
/ |   |\
D  E   P Q

To make it more clear: when obtaining the list of children for node 'A'
I want to get hold of the rows for the nodes 'B' and 'N', not 'B' and 'C'.
So the node 'C' should be replaced with the node 'N' and its subtree.

Any idea how to model this in a sane way using SA?

Tnx,
Andreas


Attachment: pgp8wdoCUqrR1.pgp
Description: PGP signature

Reply via email to