schemaentitiesvaticle-typedb

Does an entity in TypeDB (formerly Grakn) need always a unique identifier?


I'm defining a schema for different persons in my graph knowledge base. A person entity is of course unique in its constellation of attributes. However, suppose just theoretically that we would have two people with the same name ("John Doe") and everything else the same, age, birthplace etc. Would TypeDB treat them as the same person if I do not insert a person-id? I'm trying to understand how TypeDB is differentiating the different entities in its data structure. If for example the two people who just be different in one single attribute, would then TypeDB have two different instances of the John Doe?


Solution

  • You would get two instances of John Doe. It's pretty-easy to verify; each entity in TypeDB has an internal identifier (called an iid). If you open console and execute this insert statement (assuming a compatible schema) twice you'll get back two entities with different iids:

    insert $p isa person, has first_name "John";

    Result:

    db-name::data::write*> insert $p isa person, has first_name "John";
    
    { $p iid 0x826e80097ffffffffffffffd isa person; $_0 "John" isa first_name; }
    answers: 1, total (with concept details) duration: 12 ms
    db-name::data::write*> insert $p isa person, has first_name "John";
    
    { $p iid 0x826e80097ffffffffffffffc isa person; $_0 "John" isa first_name; }
    answers: 1, total (with concept details) duration: 8 ms