How do I create a MYSQL Schema to represent a Graph Database?

Viewed 6780

Looking for some advice on how to map out my table schema to represent a current bi-directional graph.

I have a list of nodes, let's say they are worldwide airports (SFO, LAX, CDG, HKG, etc). The nodes are connected with bi-directional edges with different weights.

For example, SFO->LAX edge may be 10, but LAX->SFO is 8.

The weights change daily, and I want the mysql database to store all the nodes, edges, and weights per day.

This is my current idea, but is there any better method to approach this? Should I use multiple tables?

DATE, SOURCE, DESTINATION, WEIGHT
12/01 LAX     SFO          8
12/01 SFO     LAX          10
12/01 ...     ...          ...
12/02 LAX     SFO          15
12/02 SFO     LAX          9
12/02 ...     ...          ...
...   ...     ...          ...
2 Answers
Related