16 Matching Annotations
  1. Feb 2020
    1. code below instantiates a client, opens a session, and runs an insertion query

      Start by instantiating a client and opening a session. Afterwards, you can begin to run queries

    2. We just created a Grakn keyspace experiment and defined its schema.

      It's good to have a single Grakn keyspace per application (outermost container for data in a Grakn knowledge graph, corresponding closely to a relational database)

    3. Now that we have the schema ready, the next step is to load it into Grakn.

      After defining schema, it needs to be loaded into Grakn:

      1) Place schema.gql in the container volume, such as db/schema.gql.

      2) Run:

      docker exec -ti grakn bash -c '/grakn-core-all-linux/grakn console --keyspace experiment --file /grakn-core-all-linux/server/db/schema.gql'
      

      3) Observe a similar result:

      Loading: /grakn-core-all-linux/server/db/schema.gql
      ...
      {}
      Successful commit: schema.gql
      
    4. An attribute can be abstract if you never assign it directly and use it only as a parent type. Entities can be abstract, too, if they are never instantiated.

      Attributes and entities can be abstract

    5. There's just one more step – defining the attribute types

      Don't forget to define attribute types, such as:

      name sub attribute,
          datatype string;
      
      address sub attribute,
          datatype string;
      
      timestamp sub attribute, abstract,
          datatype date;
      
          created sub timestamp;
          last-modified sub timestamp;
          last-accessed sub timestamp;
          penalty-until sub timestamp;
      
      url sub attribute,
          datatype string;
      

      ...

    6. We've ended up with three entities: user, badge and location. How to glue them together? Using relations.

      Use of relations to glue different entities:

      location-of-user sub relation,
          relates located-user,
          relates user-location;
      
      achievements sub relation,
          has score,
          relates contributor,
          relates award;
      
    7. Some things are common to multiple users, like a location (e.g. Austin, TX, USA) or the types of badges they've been awarded (bronze, silver, gold). We'll model locations and badges as separate entities.

      Modelling separate entities:

      location sub entity,
          key address,
          plays user-location;
      
      badge sub entity,
          key color,
          plays award;