Graph databases are used to store structures based on data from graph theory. Graph databases have a concept of nodes that are entries and edges that connect one node to another. Typically, graph databases are used to determine data that is closely related, as in the following image:
This recipe shows how to use, store, and traverse a simple graph database.
Create a keyspace and column family to store the graph data and insert some sample data into it.
[default@unknown] connect localhost/9160; [default@unknown] create keyspace graph; [default@unknown] use graph; [default@graph] create column family graph; [default@graph] set graph['a']['b']=''; [default@graph] set graph['a']['c']=''; [default@graph] set graph['c']['d']=''; [default@graph] set graph['d']['a']=''; [default@graph] set graph['c']['e']='';