-
Notifications
You must be signed in to change notification settings - Fork 1
User guide
This guide will teach you to use this database in the easiest way possible. After reading this guide, you would never be required to see its Javadoc.
Initialization of this is as simple as creating a File
object.
CloroGraph dB = new CloroGraph(directory);
directory is the location where you want to create the database. On android, use context.getDataDir()
or context.getFileDir()
Now through this dB object, we can:-
- Create or open graphs or trees
- Save or delete graphs or trees
Basically, this class is responsible for the transaction to the database while the other classes of the database are just data structures which hold data.
To store the data, first, we need to know how to construct the data. I first recommend reading this article about these data structures.
The SimpleGraph
databases uses 2D array matrix, while the RelationalGraph
uses LinkedList with HashMap (for faster performance). So you can read this article to decide which suits best in what condition.
Trees are special types of graph which holds data in a hierarchy. It is best to represent a family. Trees don't have edges, the nodes which are of the same parent are considered to be related (mostly as siblings).
There is only one type of tree in this database. That is the N-Array tree. This tree can have n-number of children in its node.
Because this is a graph database, it can only store data in the form of a Graph
or Tree
. Hope you have already learnt to create the tree and graph, if not yet go and learn them first.
Here are some of the ways you can create/open data structures.
db.saveGraph(graph);
db.saveTree("demoTree",tree);
Tree<Person> tree = (Tree<Person>) db.openTree("demoTree");
Graph<Person> graph = db.openGraph("demoGraph");
- It could be either a
SimpleGraph
orRelationalGraph
.
To write data to a database, first, structure it in a Tree
or a Graph
.
Graph
RelationalGraph<Person> graph = new RelationalGraph<>();
...
...
...
db.saveGraph(graph); // or graph.commit(db)
or with Tree
Tree<Person> tree = new Tree<>(root);
...
...
...
db.saveTree("familyTree",tree);
var initialGraph = new RelationalGraph<Person>();
... // setting up graph for the first time
RelationalGraph<Person> graph = db.createOrOpenGraph("familyTree",initialGraph);
... // update the graph
... // remove or insert some data
db.saveGraph(graph); // then again save it
In this example, the database will create the graph (initialGraph) if it is not already there.
The same is for Tree
also.
That's all that you need to know about this database. If you have any doubts, please see the issues.
Thank you, have a nice day :-)