A gym tool Holochain Gym Concepts Developers What's next Glossary of Terms Toggle darkmode Give us Feedback!

Concepts: Entry Graph

TLDR: you can think of data stored in the DHT as a graph database, with entries as nodes and links defining relationships between entries.

Entry Graph

What does shared data in the DHT look like?

The easiest way you can think about how data is structured in a Holochain application is like a graph database.

From all the actions taken from all the Source Chains, each neighbor in the DHT aggregates them distributedly to form an Entry Graph.

There are two main primitives that build this graph:

  • Entries: an entry is a node in the graph.
  • Links: a link connects two entries together. They are directed: they go from a base entry hash to a target entry hash.

Try it!

You can try creating some entries:

  1. Select the create_entry function, set a parameter and click execute.
    • See how an entry gets created in the entry graph.
  2. Click on the entry.
    • See how the entry's contents are displayed.
  3. Create a second entry.
    • Watch out! The content for the second entry has to be different than the first one if you want the entries to be different - entries are hashed!
  4. Select the create_link function.
  5. Copy the hash of one of the entries from the Entry Contents panel, and paste it as the base parameter of the create_link function.
  6. Select the other entry, and copy its hash to the target parameter of the create_link function.
  7. Click Execute.
    • See how the two entries are now linked together.

Thinking about data in your hApp

One of the most important steps that you have to take when designing your hApp is think about your entry relationship graph. Normally, you would expose zome functions that do multiple things, instead of creating just one entry.

This is an example design for a forum app. In this case, we have chosen to have a create_post function, that creates the post entry, creates a global "all_posts" entry, and creates a link from that global entry to the post entry.

Try to create some posts and look at how the graph of entries is created and grows with each post.