Doubts: Grakn vs relational


#1

Hi,
I’m working on migration from MySQL to Grakn, but I have a “conceptual” doubt. I have modeled something like that:

language sub attribute, datatype string,
  has languageName;

languageName sub attribute,
    datatype string;

pos sub attribute, datatype string,
  has entry;

uid sub attribute,
    datatype string;

name sub attribute,
    datatype string;

baseEntity sub entity, abstract,
	key uid;

lexeme sub baseEntity,
	has name,
	has pos,
	has language;

In MySQL I have tables for Language and POS (just to store the code and the description), but in Grakn I’ve modeled as attributes with attributes, for example language=‘en’, languageName=‘English’ and so on.
I insert records for Lexeme entity with:

insert $lexeme isa lexeme; $lexeme has uid "cjvn84fiu0uribokvqb29w20y"; $lexeme has pos "N";$lexeme has language "en"; $lexeme has name "word";

My doubt is: there no “foreign key”, but Grakn “knows” that the attribute language (=‘en’) in Lexeme is the ‘same’ recorded before? this is, is there just one record for language=‘en’, internally? Or are the records duplicated? My concern is because Lexeme entity has 300,000 instances…
And: is necessary to create the uid attribute? Or Grakn has some kind of field for act as key?
Thanks,
Ely


#2

Hi @elymatos,

  • Grakn knows that the attribute is the same so you will have only one node for attribute language with value en . All the lexemes with language en will be connected to that same node.

  • Grakn has the concept of key (you can see an example here https://dev.grakn.ai/docs/schema/concepts#assign-an-attribute-to-a-relation-as-a-unique-identifier)
    but also it looks like you’re using it already.

  • Grakn generates unique IDs for each node in the graph so you could use that instead. The difference between internal Grakn ID and a key that you define is that you cannot set the internal ID but you can define the value of every key. This might be useful when migrating or exporting/importing for example.


#3

Thanks for clear answers!