### Build Composable TypeQL Query Patterns with Pattern Matching Source: https://github.com/typedb/typeql/blob/master/README.md Demonstrates TypeQL's composable pattern matching syntax for querying data. Patterns start with simple entity matching and progressively add constraints including attribute filtering and relationship matching. Each constraint can be added independently while maintaining query validity. ```typeql match $user isa user; match $user isa user; $user has email "john@typedb.com"; match $user isa user; $user has email "john@typedb.com"; (team: $team, member: $user) isa team-membership; match $user isa user; $user has email "john@typedb.com"; (team: $team, member: $user) isa team-membership; $team has name "Engineering"; ``` -------------------------------- ### Build Queries with Ease in TypeQL Source: https://github.com/typedb/typeql/blob/master/README.md This snippet demonstrates building TypeQL queries using its natural and declarative syntax. It shows a combination of a `match` clause to retrieve data and an `insert` clause to add new data, including entities and relations with attributes. ```typeql match $kevin isa user, has email "kevin@typedb.com"; insert $chloe isa full-time-employee, has full-name "ChloƩ Dupond", has email "chloe@typedb.com", has employee-id 185, has weekly-hours 35; (employee: $chloe, ceo: $kevin) isa hiring, has date 2023-09-27; ``` -------------------------------- ### Define Types, Inheritance, and Interfaces in TypeQL Source: https://github.com/typedb/typeql/blob/master/README.md This snippet demonstrates how to define attributes, entities, and relations in TypeQL, showcasing the use of subtyping for inheritance and interfaces. It illustrates the structure of the Polymorphic Entity-Relation-Attribute (PERA) model. ```typeql define attribute id value string; attribute email sub id; attribute path sub id; attribute name sub id; entity user, owns email @unique, plays permission:subject, plays request:requestee; entity file, owns path, plays permission:object; entity action, owns name, plays permission:action; relation permission, relates subject, relates object, relates action, plays request:target; relation request, relates target, relates requestee; ``` -------------------------------- ### Write Polymorphic Database Queries in TypeQL Source: https://github.com/typedb/typeql/blob/master/README.md This snippet illustrates how to write polymorphic queries in TypeQL. It shows how to query common supertypes to retrieve matching data of various subtypes, and how to variablize queries to return types, roles, and data. ```typeql # This returns all users of any type match $user isa user, has full-name $name, has email $email; # This returns only users who are employees match $user isa employee, has full-name $name, has email $email, has employee-id $id; # This returns all users and their type match $user-type sub user; $user isa $user-type, has full-name $name, has email $email; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.