Network |
Monday, 1st December 2003 |
How to model a
a network
of nodes and connections?
Two associations: from and to?
It seems easy enough with just two entities:
Each connection has associations with two nodes, a 'from' node and a 'to' node.
A node can have many 'from' and 'to' connections.
One association with a fixed cardinality of two?
Hmm, the double associations trouble me.
'From' and 'to' are relative in the given example.
The products flow right to lef.
The money flows the other way.
- So, does that make direction unimportant?
- Shouldn't there be a differenc between from and to?
- Get rid of the two seperate associations?
Should I turn it around?
A connection is always between two nodes, irrespective of the direction?
So, a one-to-many cardinality of 2 and nothing but 2?
Hmm, I like the simplicity of the alternative.
Yet, the model does not match reality.
A node can have
more than one
node, such as 'shop owner' in the example.
A role model
A more complex model is required to facilitate the many, directed connections per node.
- The direction from from to to is important.
- Connection does not have attributes, does not need to be an entity.
It is an association between a startpoint and an endpoint.
- Startpoint and endpoint are similar, have a common superclass.
- A node can have many
roles
as start and endpoints.
Shop-owner for example acts once as endpoint and twice as startpoint.
A few weeks to go...
until I'll personally can test the hawker network with a mee-soup for breakfast somewhere in nice tropical highlands.
I'm looking forward to it.
Till
next nut,
Nut