Where should the Reverse notation go?

From the documentation:

Reverse predicates can also be included inside a type definition. For example, the following schema, declares that a node of type Child may have a ~children inverse relationship.

children: [uid] @reverse .
name: string @index(term) .

type Parent {
  name
  children
}
type Child {
  name
  <~children>
}

Would it be wrong to create the schema in this way:

children: [uid] .
name: string @index(term) .
IsChildOf: uid @reverse .

type Parent {
  name
  children
}
type Child {
  name
  IsChildOf
}

Or perhaps the @reverse in the different place makes sense depending on how I plan to do my queries?

I have implemented my version and it does seem to be working.

@SunSparc , you are right. Selecting the predicate representing your main directed edge and using the reverse edge is a design decision.
One element that can help you decide is how you get the data and ingest it in Dgraph.
You cannot write a mutation to set a reverse edge directly.
For example, if using a mutation in RDF format (JSON is also supported!) you will be able to set

_:p1 <name> "Luke" .
_:p1 <isChildOf> "Anakin" .

You cannot set the predicate <~children> directly.

Hope this helps in your design.

1 Like

Thank you for the confirmation. I like how flexible Dgraph schema design is.