New ACM paper, free-tier cloud, and open-source license

Quickstart

This Quickstart guide shows how to set up a TypeDB database and run queries using TypeDB Studio.

TypeDB & TypeQL are in the process of being rewritten in Rust. There will be significant refinement to the language, and minor breaks in backwards compatibility. Learn about the changes on our roadmap issue on GitHub. The biggest change to TypeDB 3.0 will be our storage data structure and architecture that significantly boosts performance. We’re aiming to release 3.0 in the summer this year, along with preliminary benchmarks of TypeDB.

Run TypeDB

To start TypeDB, select the TypeDB edition below and follow the instructions.

  • Cloud

  • Core

Log in to TypeDB Cloud and create a new deployment on the Deployments page.

For self-hosted TypeDB Cloud installation and setup, see the Self-hosted deployment page.

TypeDB Core needs to be installed first.

To start a local TypeDB Core server:

$ typedb server

To create and run a new Docker container with TypeDB Core server:

$ docker run --name typedb -d -v typedb-data:/opt/ -p 1729:1729 --platform linux/amd64 vaticle/typedb:latest

Connect to TypeDB

There are several ways to connect to a running TypeDB server. In this quickstart guide we will use TypeDB Studio, a standalone TypeDB Client with GUI that needs to be installed and launched separately from a TypeDB server.

Find the TypeDB Studio binary and run it. Click Connect to TypeDB on the right side of the top toolbar.

  • Cloud

  • Core

TypeDB Studio connect window
  1. Click Connect to TypeDB on the right side of the top toolbar.

  2. Switch the Server field drop-down to TypeDB Cloud.

  3. Click Manage Cloud Addresses button.

  4. Add address and port for at least one server from your TypeDB Cloud deployment. Close the Address management window.

  5. Fill in the Username and Password fields with valid user credentials.

  6. Turn on the Enable TLS option and leave the CA Certificate field empty.
    For self-hosted deployments, encryption parameters may vary.

  7. Click Connect.

On your first login you will be asked to change the password for the admin account. A TypeDB Cloud deployment will refuse queries until the password is changed from its default value.

TypeDB Studio connect window
  1. Click Connect to TypeDB on the right side of the top toolbar.

  2. Make sure the TypeDB Core option is selected in the Server field.

  3. Enter the address and port of the server to connect to (e.g., localhost:1729).

  4. Click Connect.

Select a project folder

To enable TypeDB Studio’s IDE functionality, you now need to select a project folder to store your project files. Select a project folder by clicking either Open Project in the Project panel or project Open Project Directory button in the top toolbar.

Create a new database

Create a database to play with:

  1. Click the database icon (database) in the top toolbar.

  2. Enter a name for a new database, for example, typedb-1, and click Create.

  3. Select the new database from the dropdown to the right of the database icon.

Define a schema

A new database needs a schema before we can load any data:

  1. Ensure the Session toggle (schema / data) is set to schema and the Transaction toggle (write / read) is set to write.

  2. Open a new tab and copy-paste the following Define query:

    define
    id sub attribute, abstract, value string;
    email sub id, value string;
    name sub id, value string;
    path sub id, value string;
    username sub id, value string;
    size-kb sub attribute, value long;
    updated sub attribute, value datetime;
    permission sub relation,
        owns updated,
        relates object,
        relates subject,
        relates action;
    action sub entity,
        owns name @key,
        plays permission:action;
    file sub entity,
        owns path @key,
        owns size-kb,
        plays permission:object;
    person sub entity, owns name;
    user sub person,
        owns username @key,
        owns email @unique,
        plays permission:subject;
  3. Click the Run query Run Query button.

  4. When the query has completed, click Commit Transaction (commit).

Now that the schema has been defined, data can be inserted into the database.

Load data

Now let’s insert some sample data into the newly created database to be able to query in future steps:

  1. Ensure the Session toggle is set to data and the Transaction toggle is set to write.

  2. Open a new tab and copy-paste the following Insert queries:

    insert
    $p isa person, has name "Charlie";
    $u1 isa user,
        has name "Bob",
        has username "bob_93",
        has email "bob@typedb.com";
    $u2 isa user, has name "Alex", has username "al-capucino";
    $f1 isa file, has path "README.md";
    $f2 isa file,
        has path "docs/quickstart-guide.adoc",
        has size-kb 3458761;
    $full isa action, has name "full";
    $write isa action, has name "write";
    $read isa action, has name "read";
    $p1(subject:$u1, object:$f1, action:$full) isa permission, has updated 2023-10-27T12:04:36;
    $p2(subject:$u2, object:$f2, action:$write) isa permission;
  3. Execute all queries in the file by clicking the Run query Run Query button.

  4. When the queries have completed, click Commit Transaction (commit).

Assuming there were no errors in the process, the data is persisted in the database.

Finish

Congratulations on completing the TypeDB quickstart guide! Now you can try sending your first queries to the database.

To learn about TypeDB’s advanced and unique features such as polymorphic queries, type inference, type inheritance, rule-based reasoning, and n-ary relations, we recommend you check the Learn more section.

Learn more

Here are some options for your next steps with TypeDB.

Continue this quickstart guide and learn the basics of TypeDB.

A comprehensive learning course for TypeDB comprising several individual lessons.

A collection of practice-oriented how-to guides for TypeDB.

Information on language-specific TypeDB drivers with native API.

Provide Feedback