Visualizing Schema as a graph

I am new to TypeDB Studio. I have created a schema and committed it to my database. Is there a way to visualize the graph for the schema in Studio, before adding any data? I am working on the latest version (2.17.0) for macOS. Alternatively, is there any other compatible tool or client that can be used to visualize the schema?

Thanks,
Aparna

Sure! Use the following query:

match $x sub thing;

This will provide you with a graph of the schema.

2 Likes

Cool! That worked. Thank you so much!

Somehow this doesn’t work for me.

I’ve created a clean new database, wrote the Quickstart schema example to database and tried out your query. I get this error:

## Error> [TQL03] TypeQL Error: There is a syntax error at line 1:
match $x sub thing;
                  ^
no viable alternative at input 'match $x sub thing;'

If I add the instance data from the quickstart as well and try out some basic example queries, that does work. But then still I cannot query the schema it seems.

Can anyone help me out? (Perhaps I should create a new topic)

Thanks

Hi @bartkl
Since the introduction of fetch, TypeQL requires a match statement to be followed by either a get or a fetch.

Here, you should just need to add a get

match $x sub thing; get;
1 Like

Ah, thanks, that works :slight_smile:. I’m new to the framework, and very excited for it!

Hi all, how does the query look like for TypeDB 3? match $x sub thing; get; does not work any more? Thank you!

Should be match $x sub thing; without the get.
Note that the 3.x versions of studio do not have visualisation

@krishnan we don’t have thing as a type anymore in 3.0!

If you want entity types:

match entity $t;

relations/attribute follow: match relation $t or match attribute $a

Oopsies. I forgot we did that.
match $t sub $_; might also work?

Great, that works indeed! Thank you very much.
the $_ is not documented anywhere yet, right? And are there plans to add the visualisation back again? It was really appealing and convenient in v2. Thank you again!

Might not be documented. It’s just a variable without a name. Now that I think about it, The best way to do this might be to write
match $t sub $t;

$t sub $_ will work only if there is an existing subtyping for a type. However, it won’t match emails and names (names are abstract, so whatever, but we do care about emails) in this schema:

define 
  attribute name @abstract, value string;
  attribute first-name sub name;
  attribute email value string;

There is no short equivalent of isa thing anymore, because all types are split to kinds more explicitly. @joshua gave the correct answer. In general, it’s like

match
  { entity $t; } or { relation $t; } or { attribute $t; }; $x isa $t;

This might be blocked by multiple rebindings of $t in 3.0, but should be available in 3.1 (RC is coming out this week).

$t sub $_ will work only if there is an existing subtyping for a type.

I don’t think this is true because a sub matches the type itself. It’s like the difference between sub* instead of sub+ in regex.

It worked fine for me here:

query-schema::read> match $sub sub $sup;
                    
Finished validation and compilation...
Streaming answers...

   ----------
    $sub | type parent
    $sup | type parent
   ----------

You’re actually right. I guess I got too deep into the Concept layer in the recent weeks, my bad.

(so actually that does not work ;))

[REX3] Error creating iterator from sub_reverse instruction.

Ah, thanks for reporting.
I’ve filed that as a bug so we fix it.

URGENT!! Thanks for sharing $_.
How can I visualize graph now in TypeDB Studio? It has been discontinued lately in V3+.

Responded in: Graph Visualizer discontinued from V3+. What is the alternative?