Reputation: 1
Im working on a project in my student job in which im using yfiles as the library for building custom graphs and icons, all in java using eclipse as IDE.
the plan is to use an embedded db to save the user files created, here is where i have doubts about how would be the best way to accomplish that.
They have an example on how to create graphs from data stored in a db, the library has support for several db engines including mysql, hsqldb, db1, oracle, derby and even CSV-JDBC. Now in their files there's no example or anything pointing that storing info from a graph to a database is possible and i would like to ask if someone who have use this library before knows how to take information from a graph (including icons and shapes) to be stored in any of these database engines.
the files created by this library are named graphml, and its basically an xml file.
My idea was to store the xml in the database as a blob and retrieve it when needed, but since they've got demos of creating graphs from information in a db i thought about asking here for anyone who knows this library about doing the reverse process of saving the elements in a db without using blob fields for storing a whole xml file into it.
I will appreciate any help for this case, i apologize if it was not pretty clear, feel free to ask anything.
Upvotes: 0
Views: 793
Reputation: 24372
You can store graphs in a relational database as nodes and edges. One table contains a list of nodes, the other table contains the list of edges. If the graph is weighted, each edge has a weight column as well. In the example below a simple graph with 4 nodes and 4 edges is defined. If the graph is directed, then each edge is directed from the node in the first column to the node in the second column.
NODES_TABLE
node1
node2
node3
node4
...
EDGES_TABLE
node1,node2
node2,node3
node3,node4
node4,node1
...
Upvotes: 2