How to translate this simple DGraph schema?


#1

Hey - how do I do something like this DGraph schema in Cayley ?

Its super simple - I assume there is something as easy in Cayley…

mutation {
schema {
type: int @index .
id: int @index .
name: string @index .
exit_status: int @index .
exit_ts: int @index .
forked: uid @reverse .
execed: uid @reverse .
contains: uid @reverse .
}
}


#2

@gosha1128 Sorry for the long wait.

Cayley does not enforce schema currently. We assume that client’s code will enforce it on validation. But we have a full support for typed values and fields. Depending on your use case, you can either write data using some data format or use our Go ORM lib to write entire data structures to graph. For data format I would recommend JSON-LD, since it follows tree-like structure and looks like ordinary JSON object with some type annotations.


#3

Excellent. I care more about declaring types to ensure efficient storage ( i.e., ints stored as ints and not strings) and less so about validation, at the moment.

Right now my benchmarks show that Cayley is 8-10x bigger on-disk that Dgraph for the same graph data. I presume it’s mostly because I can tell Dgraph the types of data (many fields are ints)…and I presume Cayley has stored everything as strings ( I used the NQUAD format).

Can you point me to the right place to get started for writing GO queries against Cayley ? I’ll rerun my benchmarks and post the results here.


#4

This topic answers this question:

Also, try using bolt2 backed if you currently using bolt. It’s more storage-efficient and much faster.