Mental model of the full database

Hi,

Although I want to use dgraph on a regular basis there is one thing that I find difficult to get over. In relational databases it is relatively easy (most of the time) to load into your mind a mental model of the database simply by inspecting the data that it contains using one of many clients. (i.e. small number of types where you can see examples of each and inspect relations through foreign keys)

However, I find it difficult to have confidence that I will be able to do the same with dgraph viewing the database strictly as a set of relations. I love the idea of making relations the primary focus but I would also like to understand comprehensively and at a high level “what’s in my database?” and I’m not sure how to do that with dgraph + ratel. Especially in the situation where one relation is part of multiple types, it makes it difficult to grok the whole thing. With the addition of types, it feels like this should be possible.

Some time ago, I made a toy UI for dgraph trying to address this, but I am wondering what the community thinks about this?

I believe this will made easier using the GraphQL endpoint as schema introspection is enabled in that endpoint.

For an instance of Dgraph, this becomes harder as the flexibility of Dgraph makes it difficult to make assertions about the data. Some things that can help.

  1. Use types and make sure every node has at least one type.
  2. If a piece of data (e.g name) does not need to be shared or queried among types, split it into multiple predicates. For example, if types Person and Company have a name attribute, you could split it into predicates person_name and company_name.
  3. Run Dgraph in strict mode, which will disable new predicates from being created and reject all mutations that have unknown predicates instead of trying to create them as in the default mode.

Thanks for all of the tips!

I will keep them in mind. I may pick up the toy UI experiment again in the future and will refer to this.

Hey @apyro,

Do you have a link to the toy UI? We’d definitely like to take a look! We appreciate community projects, even if they are partly done, because we know it will help other users. Send us a link :-).

Hi @gja, I have posted about it previously. Here is a link to the video. The code is messy, incomplete, and for a previous version of dgraph, but I’m happy to open source it as well.

1 Like

Wow, that’s really cool. Please do open source it, I’ll see if we can feature it somehow. :slight_smile:

Sorry for the delay. Here is the code. It’s a django-channels project.

honey.tar.gz (3.0 MB)

1 Like