Document storage


Can Cayley be used for storing documents? What is the max size for an object in a triple? How would you architect a database for both graph and document storage? Should I put documents in mongo and store their keys in my cayley graph?


The short answer is that the Cayley is not optimized for storing documents as blobs.

I always keep this in feature in mind because it’s something I will benefit from as well. But if you think about implementing it, it’s the same complexity as having a separate database and storing IDs in Cayley. But in addition to that we will force some API restrictions on what you can and can’t do this your documents.

So I will suggest to run a Mongo instance and generate IDs for each document. You can have some specific format for those IDs to easily distinguish them (<blob:mongo-id-here>), or use type edges for the same purpose (<some-id> <type> <Blob>).

But if you have other thoughts how we can integrate it - please share them. We are always open for new ideas :slight_smile:

As a side note, you can also implement a service in Go that hides all of this and embeds Cayley. This is the whole point of Cayley - to be embedable and customizable.


Keep in mind that documents can be easily integrated to the graph if you make them small changes.
You can use the write API to write JSON-LD documents to Cayley.
For example:
MongoDB (BSON):
Users Collection:
{ “_id”: ObjectId(), “givenName”: “Bob” }
In Cayley (JSON-LD):
Main Graph:
{ “@id”: “users/507f1f77bcf86cd799439011”, “schema:givenName”: “Bob” }