Overview
This section features a step-by-step guide to getting started with TypeDB using a simple social network that includes people, friendships, employments, and organizations. You will not need to install anything - run TypeDB server in the cloud for free, and interact with it via the web-based TypeDB Studio.
It is intended to give a quick rundown of the main interactions you’ll have with TypeDB, such as database management, schema definition, data loading, and composing multi-step queries.
Mini-guide
The following outline serves both as an example of the main things you’ll do with TypeDB and a quick outline of the following Get Started guide - if you just want to speed through right here, you can, though we recommend following the full guide!
-
-
Sign up & launch a free TypeDB instance on TypeDB Cloud account.
-
Follow the instructions from the cluster to open TypeDB Studio.
-
-
-
Create a database called
get_started
. -
Execute a query to create the social network schema using a schema transaction:
#!test[schema] define attribute username, value string; attribute start-date, value datetime; attribute status, value string; attribute student-count, value integer; entity user, owns status @card(0..), owns username @key, plays enrolment:student, plays friendship:friend; entity organization, owns status, owns username, plays friendship:friend; entity company, sub organization; entity university, sub organization, owns student-count, plays enrolment:university; relation friendship, relates friend @card(2..2), owns start-date @card(0..1); relation enrolment, relates student, relates university;
-
-
-
Run a series of pure inserts using a write transaction:
#!test[write] insert $u0 isa user, has username "alice";
#!test[write] insert $u1 isa user, has username "bob"; $u2 isa user; $u2 has username "charlene"; # can split `isa` and `has` across different statements
#!test[write] insert $u3 isa user, has username "delta"; $u4 isa user, has username "echo"; $u5 isa user, has username "fizzbuzz"; friendship (friend: $u3, friend: $u4); friendship (friend: $u3, friend: $u5);
-
Run a read-write query:
#!test[write, count=1] match $x isa user, has username "alice"; $y isa user, has username "bob"; insert friendship (friend: $x, friend: $y), has start-date 2015-01-01T00:00:00;
-
-
Use your loaded schema and data to write aggregation queries, compose query pipelines, and create functions in Query composition