Referring to predicates or classes as you do to nodes

Is it possible in DGraph to refer to items from the metamodel just like any other nodes? By that I mean does DGraph support models like this one (written in RDF)?

:Car a owl:Class .
:SkodaCar a owl:Class ;
    rdfs:subClassOf Car .
:my-skoda-car a :SkodaCar ;
    :boughtAt :my-car-distributor .

:my-car-distributor a :CarDistributor ;
    :sellsBrand :SkodaCar .

or

:sellsBrand a rdf:Property .
:mySchema :hasProperty :sellsBrand .

The Dgraphā€™s RDF is a simple NQuad RDF. Thereā€™s no support for other types of RDF. No OWL for example.

Michel, thanks for the answer. That however is not what I was asking about. My point is: in RDF (or other paradigms like the one in TypeDB), you can refer to elements of the schema (classes, properties), just like you do to instances. In particular, they can be used as an object of possibly any (other) relation. This is what my example is trying to demonstrate. Itā€™s not about OWL, RDFS or formats.

The answer to those questions is no. And this example you have shared is pure OWL.

In theory, you can do whatever other Graph DB can do. But not in the same way and you have to learn DQL pretty well. However, you wonā€™t have any easy life to mimicate those characteristics.

Cheers.

Thanks! And can you ask DQL queries like ā€œgive me all the outgoing/incoming links from/to the given node?ā€ I could find expand(_all_) but from what I understood, it only gives you nodes, not edges. Is there a way to also get the edges / edge names?

it is impossible in dql to ask ā€˜give me all fields and edges ā€œonā€ a nodeā€™ because you have to ask for everything you want to access. Storage is organized by predicate, not by node - so you cannot grab a ā€˜whole nodeā€™. Using expand() with the type system can help organize and auto-fill those fields, but does not mean some other field could not exist ā€˜onā€™ that node that is not within your types. This can be enforced in application code though.

Expand actually does give you edges as well, but only ones defined in the type system.

so given

type MyType {
  id
  myfield 
  myedge
}

the query

{q(func: eq(id,"blah")){
  expand(MyType) {
    expand(MyType)
    uid
  }
}}

is equivalent to:

{q(func: eq(id,"blah")){
  id
  myfield
  myedge {
    uid
    id
    myfield
  }
}}

when using expand(_all_) it basically looks up the values of dgraph.type on the nodes in question, and applies every type listed there to expand(). Note expand can be used with specified types without recording those type in dgraph.type

2 Likes

Thanks for the explanation!