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 rule inference, 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.
Recommended prerequisites
-
You should complete Lesson 2 before starting this lesson.
Running examples
To run a Fetch query, make sure to use a data session and read transaction. The examples and exercises featured in this lesson are annotated with one of the following instructions to indicate how they should be run.
- Run
-
Run this query. Read transactions do not need to be committed.
- Try running
-
Run this query to see the error generated.
For information on how to control sessions, transactions, and queries using TypeDB Studio, refer back to Lesson 2.2.