Hi all,
Please help me model this scenario with many-to-many relations:
I am trying to model a directed graph. My objects are nodes: n1...nk,
and I have a bunch of directed edges: n1 --> n3, n5 --> n6, n6 --> n2
and so on. From reading the documentation, I know that the nodes will
probably be one table, and edges will probably be defined as a
"secondary" table in a relation. The examples in the documentation
however assume that the relationship is between two tables (left and
right) whereas all I have is nodes. My intuition was to define an edge
table like this:
edges = Table(...... Column(source, Integer, ForeignKey('Nodes.id')),
Column(target, Integer, ForeignKey('Nodes.id')))
but I could not figure out how to turn this into a relation. How can I
design a Nodes table which would give me the following two relations:
n.incoming ==> The list of nodes such that there exists an edge where
n = target
n.outgoing ==> The list of nodes such that there exists an edge where
n = source
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---