Building a mySQL database to model a graph

So I'm trying to build a database using mySQL to represent a generic directed graph. This means I need to use directed arcs going from one node to the other and represent it in SQL. Graphs in SQL aren't too difficult but I'm not exactly sure how to model directions.

Any ideas on how to model this kind of database?

Upvotes: 0

Views: 477

Answers (1)

Matthew Pope
Matthew Pope

Reputation: 7679

I believe you can use a primary key of sourceNode, destinationNode. If you do this, all of the arcs are inherently directed.

Upvotes: 1

Related Questions