What is the difference between a resources and an entity?


I do not get it: if resources can play roles, can have resources of their own AND get access to the nice “has” syntax, why would I ever want to use an entity?


Hi Andrew,

Functionally the biggest difference between the two is that resources are unique to their type while entities are not. That’s why in the Java API a resource is added by putResource(Value, ResourceType) while an entity is added by addEntity(EntityType) and putEntity(Id, EntityType). If you notice there is no option of just adding a resource.

What does this mean ? It means that when you create a resource type say birthdate = graph.putResourceType("Birthdate") any instances of this resource type with the same value are the same. So for

resource1 = graph.putResource("9th October 1988", birthdate);
resource2 = graph.putResource("9th October 1988", birthdate);

resource1 and resource2 are the same. This makes things like “Who are all the people born on the 9th of October” easier to do. With entities this is only the case if you specify the id (which we getting rid of anyway).

Conceptually an entity is meant to represent a thing, any thing really, in terms of SQL tables you could think of it like a row with infinite columns. On the other hand, resources are used to represent a value or literal, so imagine the columns of your table in this case. This means that entities are characterized by their resources.

Going back SQL, when you have an empty row the only thing you know is that this piece of data belongs to a table. Similarly, with an entity with no resources the only thing we know is it’s type. It’s the resources (columns) and relations which define an entity.

This is one of the most interesting points of our stack so please feel free to probe further. It actually took us quite a while to make these realisations ourselves.


Hi Filipe,

Thanks for the detailed answer. I think I more or less understand it from a conceptual point of view, but from a functional one, isn’t a resource just an entity where the value coincides with the ID? Are there performance differences in using one instead of the other?


Hi Andrew,

where the value coincides with the ID? Not really sure what you mean by this. If you asking if the value of a resource is the same as the id of an entity then no, that is not the case. Values can be anything Strings, Longs, Doubles, Booleans, etc . . . The id of a entity can only ever be a string.

With regards to performance. No there is no difference between them.