T
TypeDB•8mo ago
georgii

querying typedb schema

You're probably looking for the statements docs! It has match examples on the individual pages. For example, match user sub $t; will return all the transitive supertypes of user (including supertypes of its supertype) match user sub! $t; will return only defined supertypes of user You can also try match $t sub user; for the reversed purpose!
16 Replies
dhruvrajan
dhruvrajan•8mo ago
Oh awesome! Managed to get
## Running>
match entity $x; $t sub! $x; select $t, $x;

## Result> Success.
$t | type company
$x | type organization
--------
$t | type university
$x | type organization
--------
## Completed
## Running>
match entity $x; $t sub! $x; select $t, $x;

## Result> Success.
$t | type company
$x | type organization
--------
$t | type university
$x | type organization
--------
## Completed
I think it'd be super useful to add a dedicated section to the schema docs to tell users how to dump the current schema of the database (with some modifications to include any annotations / constraints / etc.); always helps to be able to fetch the source of truth for the schema as it's pretty easy to lose track of queries that have been run. Might help to meet in the middle with regards to the old type browser functionality.
georgii
georgiiOP•8mo ago
You're right, thanks! We'll be working on docs for additions and refinements for quite some time, so all questions and suggestions are always welcome. The manual is not yet complete (but will be ready next week). We have a dedicated manual section for Reads, and these examples from the TypeQL docs can have a good representation over there, too 🙂 cc @Joshua @christoph.dorn We are also working on the best ways to retrieve schemas, so we'll keep you updated
marcpj
marcpj•8mo ago
Doesn't seem to work in TypeDB Studio
## Error> INF5
[INF5] Type-inference derived an empty-set for some variable
Caused: [QUA1] Type inference error while compiling query annotations.
Caused: [QEX8] Error analysing query.
## Error> INF5
[INF5] Type-inference derived an empty-set for some variable
Caused: [QUA1] Type inference error while compiling query annotations.
Caused: [QEX8] Error analysing query.
dhruvrajan
dhruvrajan•8mo ago
^ I just ran that in the latest typedb studio with typedb 3.0.2, on the schema from crash course @georgii good stuff thanks! Look forward to reading it.
georgii
georgiiOP•8mo ago
Btw, select is unnecessary in your case as you only have these two variables. It will make the query shorter 🙂 You probably don't have any entity types in your schema
marcpj
marcpj•8mo ago
I've one entity for sure
georgii
georgiiOP•8mo ago
Sorry, you don't have entities or subs between them Empty sets in type inference are considered errors in 3.0.2, but it may change to 0 answers in the future
marcpj
marcpj•8mo ago
I've tested with the most simple schema:
define entity employee;
define entity employee;
georgii
georgiiOP•8mo ago
Yes, and this schema does not have subs. In 3.0, the entity employee declaration does not produce any subtyping
marcpj
marcpj•8mo ago
but this works:
match entity $x;
select $x;
match entity $x;
select $x;
yes
georgii
georgiiOP•8mo ago
entity, relation, attribute are now kinds definition keywords So your schema is empty by default, no strange abstract entity entities and stuff 🙂
marcpj
marcpj•8mo ago
So what is the best commands to get the schema ? Empty or not ?
georgii
georgiiOP•8mo ago
Please follow the get started section with the crash course to get a better feeling of 3.0, I'm sure everything will get clearer! https://typedb.com/docs/home/get-started For now, you're unable to get the whole schema with everything declared in it. But you can use match to get entity types, relation types, attribute types, role types (relates, type traits (owns, plays), subtyping information (sub), value types of the attribute types (value), etc. Unfortunately, not a single line
marcpj
marcpj•8mo ago
ok... and select is not recognized as a typeql keyword btw
georgii
georgiiOP•8mo ago
@alex Haven't we updated TypeQL in Studio?
alex
alex•8mo ago
let's discuss in person when you're available?

Did you find this page helpful?