Edge direction confusion / Practical implementation

Hi,

As a veteran SQL user that for the first time approach graph DB, I have some difficulties deciding the edge direction.

For example:
Lets assume I have the following nodes:

  • user - A user!
  • track - holds geolocation data
  • journal - holds many tracks of one or more users.

How to connect them?

user -> tracks -> track
Or maybe
track -> author -> user

And the journal

track -> journal -> journal
jounral -> tracks -> track

Other thought I had:

  • Should I keep the father node agnostic as possible? meaning children will point to him rather than him refer to 10k child.
  • Is there any loss performance if a node has 10k edges? (journal -> track)

Thanks

you can create a relation using uids. Like

User node

query user (func: has(name)){
     name
     age
     has_tracks {
            name_track
            somenumber
            views
            geo
                    }
         }

So, “has_tracks” is a predicate with the uid from the “owner” is like that the connection between nodes. If you need it to be reverse read this https://docs.dgraph.io/query-language/#reverse-edges

For more details about geo read this Geolocation List AND most important this https://docs.dgraph.io/query-language/#geolocation

Hey @mbn18

I’d say you can have

<user_id>  <tracks> <track_id>
<journal_id> <tracks> <track_id>

As @MichelDiz suggested you might also want to have some reverse edges but that depends on the kind of queries you want to perform.

In a SQL DB, a child table has a link back to the parent table using a foreign id. You don’t need to do that in Dgraph. You parent node can point to the child node. So, its ok for a parent node to have 10k children.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.