# Visualizing Schema as a graph

**URL:** <https://forum.typedb.com/t/visualizing-schema-as-a-graph/333>\
**Category:** Studio\
**Tags:** macos, schema-design\
**Created:** [28 April 2023 17:04 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333 "2023-04-28T17:04:37Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamagog](https://avatars.discourse-cdn.com/v4/letter/i/97f17d/32.png) [@iamagog](https://forum.typedb.com/u/iamagog)\
**Post date:** [28 April 2023 17:04 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/1 "2023-04-28T17:04:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![james.williams](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/james.williams/32/49_2.png) [@james.williams](https://forum.typedb.com/u/james.williams)\
**Post date:** [28 April 2023 17:07 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/2 "2023-04-28T17:07:42Z")

</div>

Sure! Use the following query:

```auto
match $x sub thing;

```

This will provide you with a graph of the schema.

---

<div class="post-metadata">

**Author:** ![iamagog](https://avatars.discourse-cdn.com/v4/letter/i/97f17d/32.png) [@iamagog](https://forum.typedb.com/u/iamagog)\
**Post date:** [28 April 2023 17:18 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/3 "2023-04-28T17:18:12Z")

</div>

> [@james.williams](#):
>
> `match $x sub thing;`

Cool! That worked. Thank you so much!

---

<div class="post-metadata">

**Author:** ![bartkl](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bartkl](https://forum.typedb.com/u/bartkl)\
**Post date:** [13 December 2023 12:37 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/4 "2023-12-13T12:37:54Z")

</div>

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:

```auto
## 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

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [13 December 2023 12:40 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/5 "2023-12-13T12:40:07Z")

</div>

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`

```auto
match $x sub thing; get;

```

---

<div class="post-metadata">

**Author:** ![bartkl](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bartkl](https://forum.typedb.com/u/bartkl)\
**Post date:** [13 December 2023 12:53 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/6 "2023-12-13T12:53:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![acib](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@acib](https://forum.typedb.com/u/acib)\
**Post date:** [1 March 2025 17:39 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/7 "2025-03-01T17:39:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [1 March 2025 19:27 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/8 "2025-03-01T19:27:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joshua](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/joshua/32/28_2.png) [@joshua](https://forum.typedb.com/u/joshua)\
**Post date:** [1 March 2025 22:21 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/9 "2025-03-01T22:21:55Z")

</div>

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

If you want entity types:

```auto
match entity $t;

```

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

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [2 March 2025 10:38 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/10 "2025-03-02T10:38:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![acib](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@acib](https://forum.typedb.com/u/acib)\
**Post date:** [2 March 2025 17:38 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/11 "2025-03-02T17:38:36Z")

</div>

> [@krishnan](#):
>
> match $t sub $\_;

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!

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [2 March 2025 18:38 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/12 "2025-03-02T18:38:36Z")

</div>

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;`

---

<div class="post-metadata">

**Author:** ![georgii](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/georgii/32/182_2.png) [@georgii](https://forum.typedb.com/u/georgii)\
**Post date:** [3 March 2025 10:42 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/13 "2025-03-03T10:42:58Z")

</div>

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

```auto
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

```auto
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).

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [3 March 2025 10:52 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/14 "2025-03-03T10:52:09Z")

</div>

> `$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:

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

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

```

---

<div class="post-metadata">

**Author:** ![georgii](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/georgii/32/182_2.png) [@georgii](https://forum.typedb.com/u/georgii)\
**Post date:** [3 March 2025 10:55 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/15 "2025-03-03T10:55:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![acib](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@acib](https://forum.typedb.com/u/acib)\
**Post date:** [9 March 2025 17:50 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/16 "2025-03-09T17:50:12Z")

</div>

(so actually that does not work ;))

```auto
[REX3] Error creating iterator from sub_reverse instruction.

```

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [9 March 2025 18:18 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/17 "2025-03-09T18:18:51Z")

</div>

Ah, thanks for reporting.  
I’ve [filed that as a bug](https://github.com/typedb/typedb/issues/7384) so we fix it.

---

<div class="post-metadata">

**Author:** ![samarth.agarwal](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@samarth.agarwal](https://forum.typedb.com/u/samarth.agarwal)\
**Post date:** [14 March 2025 03:12 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/18 "2025-03-14T03:12:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/alex/32/148_2.png) [@alex](https://forum.typedb.com/u/alex)\
**Post date:** [14 March 2025 09:57 UTC](https://forum.typedb.com/t/visualizing-schema-as-a-graph/333/19 "2025-03-14T09:57:39Z")

</div>

Responded in: [Graph Visualizer discontinued from V3+. What is the alternative?](https://forum.typedb.com/t/graph-visualizer-discontinued-from-v3-what-is-the-alternative/669)
