Lesson 3: Reading data

In this lesson, we’ll learn how to read pre-inserted data in the sample database using Fetch queries. We’ll begin by seeing how we can retrieve entities and relations in a similar way to how we do with relational databases. We’ll then see how we can retrieve data in unique ways using TypeDB: by writing declarative polymorphic queries, by leveraging functions, and by retrieving types from the schema. Finally, we’ll look at a few examples of type inference at work by seeing how TypeDB validates queries.

  • You should complete Lesson 2 before starting this lesson.

Lesson contents

Learn how to retrieve the attributes of entities and relations.

Learn how to retrieve data with polymorphic queries.

Learn how to invoke functions for modularization and recursion.

Learn how to retrieve typing information from the schema.

Learn about how queries are validated against the schema.

TypeQL keywords introduced

  • match

  • fetch

  • attribute

  • isa

  • has

  • entity

  • relation

  • isa!

  • sub

  • sub!

  • owns

  • relates

  • plays