# TypeQL

**URL:** https://forum.typedb.com/c/typeql/18.md

[Latest](https://forum.typedb.com/latest.md) · [Categories](https://forum.typedb.com/categories.md) · [Tags](https://forum.typedb.com/tags.md)

---

## [About the TypeQL category](https://forum.typedb.com/t/about-the-typeql-category/28)

<div class="topic-metadata">

**Author:** [@alex](https://forum.typedb.com/u/alex)\
**Replies:** 0

</div>

TypeQL discussion category

---

## [Derive Macro for rust](https://forum.typedb.com/t/derive-macro-for-rust/701)

<div class="topic-metadata">

**Author:** [@sevki](https://forum.typedb.com/u/sevki)\
**Replies:** 0\
**Last updated:** [14 August 2025 15:05 UTC](https://forum.typedb.com/t/derive-macro-for-rust/701 "2025-08-14T15:05:29Z")

</div>

Hi folks, I’m Sevki, I’m new here. I have been searching for a more rusty™️ way to generate schemas. something like, #\[derive(Relation)\] enum Employment { #\[role\] Employee, #\[role\] Employer, } // Rust…

---

## [Mysterious syntax error in \`get\` clause of \`match\` expression](https://forum.typedb.com/t/mysterious-syntax-error-in-get-clause-of-match-expression/678)

<div class="topic-metadata">

**Author:** [@Jeff\_Brown](https://forum.typedb.com/u/Jeff_Brown)\
**Replies:** 2\
**Last updated:** [9 April 2025 15:05 UTC](https://forum.typedb.com/t/mysterious-syntax-error-in-get-clause-of-match-expression/678 "2025-04-09T15:05:09Z")

</div>

(I believe that answering this question does not require understanding Rust.) My Rust program is choking on the following query: let query = format!( r#"match $container isa node, has id $container\_id; …

---

## [How to create integrity constraints?](https://forum.typedb.com/t/how-to-create-integrity-constraints/592)

<div class="topic-metadata">

**Author:** [@elviejo79](https://forum.typedb.com/u/elviejo79)\
**Replies:** 1\
**Last updated:** [15 November 2024 09:40 UTC](https://forum.typedb.com/t/how-to-create-integrity-constraints/592 "2024-11-15T09:40:03Z")

</div>

Let’s suppose I have an Instance: Invoice with Total 100 usd. And I want to also insert the items of the invoice: item A: 33usd item B: 33usd item C: 34usd… So the constraint is that the Sum of the itemized items mu…

---

## [Regex constraints in abstract attributes](https://forum.typedb.com/t/regex-constraints-in-abstract-attributes/578)

<div class="topic-metadata">

**Author:** [@zelit](https://forum.typedb.com/u/zelit)\
**Replies:** 2\
**Last updated:** [23 September 2024 15:19 UTC](https://forum.typedb.com/t/regex-constraints-in-abstract-attributes/578 "2024-09-23T15:19:34Z")

</div>

Hello, Consider the query insert $r isa resource, has hex "00t"; This query is correctly validated (and the data not inserted) in the schema define hex sub attribute, value string, regex "^(\[0-9a-f\]{2})+$"; resou…

---

## [Fetch Query to get the attributes directly](https://forum.typedb.com/t/fetch-query-to-get-the-attributes-directly/565)

<div class="topic-metadata">

**Author:** [@nico\_bondarenco](https://forum.typedb.com/u/nico_bondarenco)\
**Replies:** 2\
**Last updated:** [9 September 2024 12:52 UTC](https://forum.typedb.com/t/fetch-query-to-get-the-attributes-directly/565 "2024-09-09T12:52:21Z")

</div>

I’m using Java SDK, and I’m executing a fetch query, everyting runs perfectly, but is there a way (a little easier) to parse/map the fetch result to a POJO? The thing is, I’m using this schema and data: Parent without c…

---

## [Parent without children does not get returned](https://forum.typedb.com/t/parent-without-children-does-not-get-returned/561)

<div class="topic-metadata">

**Author:** [@nico\_bondarenco](https://forum.typedb.com/u/nico_bondarenco)\
**Replies:** 3\
**Last updated:** [3 September 2024 11:04 UTC](https://forum.typedb.com/t/parent-without-children-does-not-get-returned/561 "2024-09-03T11:04:03Z")

</div>

I’m trying to create a schema for user and groups, both with roles, so my schema is this (roles can be an array on both entities, but from what I know, it will be a 3.0 feature): define id sub attribute, value string; …

---

## [Given the iid of something in the graph, how to retrieve it?](https://forum.typedb.com/t/given-the-iid-of-something-in-the-graph-how-to-retrieve-it/558)

<div class="topic-metadata">

**Author:** [@Jeff\_Brown](https://forum.typedb.com/u/Jeff_Brown)\
**Replies:** 5\
**Last updated:** [21 August 2024 14:51 UTC](https://forum.typedb.com/t/given-the-iid-of-something-in-the-graph-how-to-retrieve-it/558 "2024-08-21T14:51:43Z")

</div>

I recently asked, in the thread here: https://forum.typedb.com/t/how-to-get-the-unique-identifier-of-a-thing-in-the-graph/554/8 “How to get the unique identifier of a thing in the graph?” Now I have the inverse questio…

---

## [Question: Expressing paths in TypeQL](https://forum.typedb.com/t/question-expressing-paths-in-typeql/523)

<div class="topic-metadata">

**Author:** [@matto](https://forum.typedb.com/u/matto)\
**Replies:** 7\
**Last updated:** [21 June 2024 10:56 UTC](https://forum.typedb.com/t/question-expressing-paths-in-typeql/523 "2024-06-21T10:56:42Z")

</div>

Hi all, does TypeQL have a path language as,f or example in SPARQL or in CYPHER ? Can you express paths of variable length? I couldn’t find this in the documentation. If not, are there alternatives to express similar que…

---

## [Can TypeDB sort on (ideally multiple) transitive partially-applied relationships?](https://forum.typedb.com/t/can-typedb-sort-on-ideally-multiple-transitive-partially-applied-relationships/521)

<div class="topic-metadata">

**Author:** [@Jeff\_Brown](https://forum.typedb.com/u/Jeff_Brown)\
**Replies:** 2\
**Last updated:** [17 June 2024 08:54 UTC](https://forum.typedb.com/t/can-typedb-sort-on-ideally-multiple-transitive-partially-applied-relationships/521 "2024-06-17T08:54:52Z")

</div>

Consider a graph with four entities A, B, C and J, the relation “\_ judges \_ to be more important than \_”, and the following two instances of that relation: “J judges A to be more important than B” “J judges B to be mor…

---

## [Define or undefine parent element](https://forum.typedb.com/t/define-or-undefine-parent-element/499)

<div class="topic-metadata">

**Author:** [@c-lare](https://forum.typedb.com/u/c-lare)\
**Replies:** 1\
**Last updated:** [1 June 2024 21:38 UTC](https://forum.typedb.com/t/define-or-undefine-parent-element/499 "2024-06-01T21:38:28Z")

</div>

Hi all, I could not find any documentation on how to define or undefined parent types, e.g., remove the parent attribute so that it inherits from the attribute or add another attribute as a parent. Same for entities and…

---

## [Regex Constrains within the attributes of entities and relations](https://forum.typedb.com/t/regex-constrains-within-the-attributes-of-entities-and-relations/495)

<div class="topic-metadata">

**Author:** [@c-lare](https://forum.typedb.com/u/c-lare)\
**Replies:** 2\
**Last updated:** [1 June 2024 06:05 UTC](https://forum.typedb.com/t/regex-constrains-within-the-attributes-of-entities-and-relations/495 "2024-06-01T06:05:20Z")

</div>

Hi all, according to the documentation, regex constraints can be applied within the owning definition of entities and relations. Documentation Example: define full-name sub attribute, value string; office-location sub …

---

## [How do I use rules in TypeQL to determine the subset relationship between sets？](https://forum.typedb.com/t/how-do-i-use-rules-in-typeql-to-determine-the-subset-relationship-between-sets/403)

<div class="topic-metadata">

**Author:** [@gavin](https://forum.typedb.com/u/gavin)\
**Replies:** 5\
**Last updated:** [20 October 2023 01:22 UTC](https://forum.typedb.com/t/how-do-i-use-rules-in-typeql-to-determine-the-subset-relationship-between-sets/403 "2023-10-20T01:22:55Z")

</div>

I have two entity type, one is ‘person’ and the other is ‘hobby’. I want to use a rule to create a new relation. This relation should satisfy the condition: it should determine whether the hobbies of any one person are a…

---

## [Schemas and propositional logic rules](https://forum.typedb.com/t/schemas-and-propositional-logic-rules/380)

<div class="topic-metadata">

**Author:** [@Newone](https://forum.typedb.com/u/Newone)\
**Replies:** 15\
**Last updated:** [15 August 2023 13:27 UTC](https://forum.typedb.com/t/schemas-and-propositional-logic-rules/380 "2023-08-15T13:27:59Z")

</div>

How do I define this? And any idea on how to make rules for these, on the assumption that I can have an external application like Rasa.

---

## [How do I express a many-to-many relation in a TypeQL schema?](https://forum.typedb.com/t/how-do-i-express-a-many-to-many-relation-in-a-typeql-schema/73)

<div class="topic-metadata">

**Author:** [@alex](https://forum.typedb.com/u/alex)\
**Replies:** 6\
**Last updated:** [11 August 2023 23:43 UTC](https://forum.typedb.com/t/how-do-i-express-a-many-to-many-relation-in-a-typeql-schema/73 "2023-08-11T23:43:37Z")

</div>

Given a set of Authors and a set of Publications, I want to model an N…N (many-to-many) relationship between Authors and Publications, such that one publication may have many authors, and one author may have many publica…

---

## [List of key or reserved words?](https://forum.typedb.com/t/list-of-key-or-reserved-words/364)

<div class="topic-metadata">

**Author:** [@pdurusau](https://forum.typedb.com/u/pdurusau)\
**Replies:** 1\
**Last updated:** [17 July 2023 23:05 UTC](https://forum.typedb.com/t/list-of-key-or-reserved-words/364 "2023-07-17T23:05:39Z")

</div>

Working on a schema and when I enter: type sub attribute, value string; displays red, I think signaling it is a keyword. When trying to run the query I got a "extraneous input ‘type’ expecting. Is there a quick refer…

---

## [Modularisation and namespacing in schemas](https://forum.typedb.com/t/modularisation-and-namespacing-in-schemas/340)

<div class="topic-metadata">

**Author:** [@jameswhiteside](https://forum.typedb.com/u/jameswhiteside)\
**Replies:** 5\
**Last updated:** [25 May 2023 15:35 UTC](https://forum.typedb.com/t/modularisation-and-namespacing-in-schemas/340 "2023-05-25T15:35:54Z")

</div>

Several community members have struggled to manage and maintain large schema files. It would be very powerful to implement a way to modularise schema files according to the following requirements: The schema files shal…

---

## [Easy way to define new attributes to entity after initial schema definition](https://forum.typedb.com/t/easy-way-to-define-new-attributes-to-entity-after-initial-schema-definition/287)

<div class="topic-metadata">

**Author:** [@alan\_wu](https://forum.typedb.com/u/alan_wu)\
**Replies:** 1\
**Last updated:** [19 January 2023 08:52 UTC](https://forum.typedb.com/t/easy-way-to-define-new-attributes-to-entity-after-initial-schema-definition/287 "2023-01-19T08:52:59Z")

</div>

Hi, In SQL, we can “ALTER TABLE my\_table ADD new\_column varchar;” to add a new column to an existing table. Can we do the similar in TypeDB? After initially defining the schema, I realised I wanted to define a new attr…

---

## [Support for Right to Left languages? Query/Sort](https://forum.typedb.com/t/support-for-right-to-left-languages-query-sort/275)

<div class="topic-metadata">

**Author:** [@pdurusau](https://forum.typedb.com/u/pdurusau)\
**Replies:** 4\
**Last updated:** [13 January 2023 11:21 UTC](https://forum.typedb.com/t/support-for-right-to-left-languages-query-sort/275 "2023-01-13T11:21:48Z")

</div>

Does TypeQL support query/sort of right-to-left languages? In particular, interested in biblical (also known as pointed) Hebrew (not modern Hebrew). If not, are there plans for such support in the future?

---

## [What is a the right way to model a table-fields meta schema structure?](https://forum.typedb.com/t/what-is-a-the-right-way-to-model-a-table-fields-meta-schema-structure/271)

<div class="topic-metadata">

**Author:** [@KrishnaPG](https://forum.typedb.com/u/KrishnaPG)\
**Replies:** 1\
**Last updated:** [8 December 2022 15:38 UTC](https://forum.typedb.com/t/what-is-a-the-right-way-to-model-a-table-fields-meta-schema-structure/271 "2022-12-08T15:38:34Z")

</div>

I need to model the concept of: “table has multiple fields, each field can have different validation rules based on its type”. Not sure what is the best way to achieve this. I have this to start with: storageType sub a…

---

## [Open source TypeQL \<-\> AST \<-\> GraphQL parser](https://forum.typedb.com/t/open-source-typeql-ast-graphql-parser/82)

<div class="topic-metadata">

**Author:** [@Loic](https://forum.typedb.com/u/Loic)\
**Replies:** 1\
**Last updated:** [23 October 2022 10:58 UTC](https://forum.typedb.com/t/open-source-typeql-ast-graphql-parser/82 "2022-10-23T10:58:56Z")

</div>

Hello all! I’m planing on building a flexible parser in typescript (that we could pack it in a AWS lambda for example) that would translate directly graphql into typeQL and viceversa. Would be nice to know if some of y…

---

## [Retrieving Full Graph - Python Client](https://forum.typedb.com/t/retrieving-full-graph-python-client/217)

<div class="topic-metadata">

**Author:** [@alejp1998](https://forum.typedb.com/u/alejp1998)\
**Replies:** 5\
**Last updated:** [18 October 2022 11:41 UTC](https://forum.typedb.com/t/retrieving-full-graph-python-client/217 "2022-10-18T11:41:50Z")

</div>

Hey, I am trying to query the whole graph to turn it into a networkx graph and be able to analyze it in more detail. To get the whole graph, I’m running the query: match $x isa thing; As far as I know, this is the fa…

---

## [Querying an instance based on the values of all its related instances properties](https://forum.typedb.com/t/querying-an-instance-based-on-the-values-of-all-its-related-instances-properties/202)

<div class="topic-metadata">

**Author:** [@timidak](https://forum.typedb.com/u/timidak)\
**Replies:** 7\
**Last updated:** [21 September 2022 11:50 UTC](https://forum.typedb.com/t/querying-an-instance-based-on-the-values-of-all-its-related-instances-properties/202 "2022-09-21T11:50:09Z")

</div>

Hi there, I want to query an instance of a concept (concept-a) which has multiple relations to instances of concept-b. The query should only return the instance of concept-a if the all the properties “is-active” of the…

---

## [Checking for role equality in type inference](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197)

<div class="topic-metadata">

**Author:** [@thayne](https://forum.typedb.com/u/thayne)\
**Replies:** 4\
**Last updated:** [7 September 2022 16:41 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197 "2022-09-07T16:41:58Z")

</div>

I have several two-way relations in my schema. I want to get both roles from all relations where at least one role has a specific type. Here’s my query: match $relation relates $role1; $relation relates $role2; $ent ty…

---

## [Is there a way to get the entities with all the attributes in one query?](https://forum.typedb.com/t/is-there-a-way-to-get-the-entities-with-all-the-attributes-in-one-query/194)

<div class="topic-metadata">

**Author:** [@mike](https://forum.typedb.com/u/mike)\
**Replies:** 3\
**Last updated:** [7 September 2022 14:45 UTC](https://forum.typedb.com/t/is-there-a-way-to-get-the-entities-with-all-the-attributes-in-one-query/194 "2022-09-07T14:45:00Z")

</div>

Hey team, I’m struggling to get all the relations with attributes and without them in one query. Now it looks like I really need two: match $x sub relation; , match $x sub relation; $x owns $attr; and union them in the…

---

## [How to include in the query, from what super-type the attribute came from?](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196)

<div class="topic-metadata">

**Author:** [@mike](https://forum.typedb.com/u/mike)\
**Replies:** 3\
**Last updated:** [7 September 2022 09:28 UTC](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196 "2022-09-07T09:28:42Z")

</div>

Hi, During schema introspection I need to know from what super-type (if any) every field came from. E.g. define name sub attribute, value string; description sub attribute, value string; supertype sub entity, o…

---

## [Schema for Entity with to many attributes to define](https://forum.typedb.com/t/schema-for-entity-with-to-many-attributes-to-define/191)

<div class="topic-metadata">

**Author:** [@Newone](https://forum.typedb.com/u/Newone)\
**Replies:** 1\
**Last updated:** [5 September 2022 08:28 UTC](https://forum.typedb.com/t/schema-for-entity-with-to-many-attributes-to-define/191 "2022-09-05T08:28:28Z")

</div>

Is there a way to define an entity that has an undefined number of attributes and new attributes are added as they come? Like: person sub entity owns atribute 1 owns atribute 2 . . . owns attribute n //and then …

---

## [Escape hell: handling string values](https://forum.typedb.com/t/escape-hell-handling-string-values/166)

<div class="topic-metadata">

**Author:** [@priamai](https://forum.typedb.com/u/priamai)\
**Replies:** 12\
**Last updated:** [5 September 2022 07:22 UTC](https://forum.typedb.com/t/escape-hell-handling-string-values/166 "2022-09-05T07:22:15Z")

</div>

Hi there, I am ingesting a large corpus of data which contains a field of type string which contains ASCII text. The text contains a lot of variety and includes all sort of commas, quotes, double quotes, back/forwarded …

---

## [Best way to represent nested JSON data](https://forum.typedb.com/t/best-way-to-represent-nested-json-data/185)

<div class="topic-metadata">

**Author:** [@sjpritchard](https://forum.typedb.com/u/sjpritchard)\
**Replies:** 0\
**Last updated:** [26 August 2022 03:35 UTC](https://forum.typedb.com/t/best-way-to-represent-nested-json-data/185 "2022-08-26T03:35:40Z")

</div>

I would like to implement a deeply nested 3rd-party JSON schema in TypeDB, and struggling to determine the best way to do it. I would like to conform to the JSON schema as closely as possible, and avoid things like flatt…

---

## [Handling Date Attribute Types](https://forum.typedb.com/t/handling-date-attribute-types/178)

<div class="topic-metadata">

**Author:** [@alejp1998](https://forum.typedb.com/u/alejp1998)\
**Replies:** 1\
**Last updated:** [19 August 2022 14:05 UTC](https://forum.typedb.com/t/handling-date-attribute-types/178 "2022-08-19T14:05:03Z")

</div>

Hey! I would like to know if it is possible to do queries that focus on only one part of a DateTime attribute, such as obtaining the people that were born in April, or looking at what events are taking place between 18:…

[Next page](https://forum.typedb.com/c/typeql/18.md?page=1)
