Skip to content

Instantly share code, notes, and snippets.

View flyingsilverfin's full-sized avatar

Joshua Send flyingsilverfin

View GitHub Profile
@flyingsilverfin
flyingsilverfin / inference_in_typedb_social_network_schema.tql
Created November 29, 2022 11:44
Inference in TypeDB blog: social network schema
View inference_in_typedb_social_network_schema.tql
define
person sub entity,
plays friendship:friend,
plays following:follower,
plays family:member,
plays ownership:owner;
page sub entity,
plays following:followed,
plays ownership:owned,
plays parent-page:parent,
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_match_inference_2.tql
Created November 28, 2022 17:04
Strong Typing in TypeDB blog: match inference 2
View strong_typing_in_typedb_match_inference_2.tql
match
(buyer: $b, seller: $s) isa contract;
$b has charity-id $cid;
===== after type inference =====
$b may be [non-profit]
$s may be [for-profit, non-profit, person]
relation may be [resource-ownership]
$cid may be [charity-id]
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_match_unsatisfiable.tql
Created November 28, 2022 17:03
Strong Typing in TypeQL blog: unsatisfiable match
View strong_typing_in_typedb_match_unsatisfiable.tql
match $p isa person, has org-id $id;
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_match_org_contractors_inference.tql
Created November 28, 2022 17:02
Strong Typing in TypeDB blog: match contractors inference
View strong_typing_in_typedb_match_org_contractors_inference.tql
match
$org isa organisation;
(buyer: $org, seller: $contracted) isa contract;
$contracted has name $name;
===== after type inference =====
$org may be [non-profit, for-profit]
$contracted may be [non-profit, for-profit, person]
$name may be [name]
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_match_org_contractors.tql
Created November 28, 2022 17:01
Strong Typing in TypeDB blog: match organisation contractors
View strong_typing_in_typedb_match_org_contractors.tql
match
$org isa organisation;
(buyer: $org, seller: $contracted) isa contract;
$contracted has name $name;
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_example_data.tql
Last active November 30, 2022 10:33
String Typing in TypeDB blog: example data
View strong_typing_in_typedb_example_data.tql
insert
// entity with two attributes
$for-profit isa for-profit, has for-profit-id 99, has name "Google";
// entity with two attributes
$charity isa non-profit, has charity-id 10, has name "Greenpeace";
// entity with one explicitly declared attribute
$name isa name; $name = "Billy Joel";
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_example_schema.tql
Last active November 28, 2022 16:49
Strong Typing in TypeDB blog: example schema
View strong_typing_in_typedb_example_schema.tql
define
organisation sub entity,
abstract,
owns name,
owns org-id,
plays contract:buyer,
plays contract:seller;
for-profit sub organisation,
owns for-profit-id as org-id;
non-profit sub organisation,
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_lpg_in_typeql.tql
Created November 28, 2022 16:38
Implementing labelled property graphs in TypeQL
View strong_typing_in_typedb_lpg_in_typeql.tql
define
vertex sub entity,
owns label,
plays undirected-edge:end,
plays directed-edge:from,
plays directe-edge:to;
undirected-edge sub relation,
owns label,
@flyingsilverfin
flyingsilverfin / strong_typing_in_typedb_java_subtyping.java
Last active November 28, 2022 16:11
Strong Typing in TypeDB blog: Java subtyping
View strong_typing_in_typedb_java_subtyping.java
// it's redundant but not wrong in Java to declare 'extends Object' explictly
public class Page extends Object {
public Page() {
// constructor
}
}
@flyingsilverfin
flyingsilverfin / rules_in_typedb_permission_shortcut_rules.tql
Last active December 8, 2022 10:44
Rules in TypeDB blog: permission shortcut rules
View rules_in_typedb_permission_shortcut_rules.tql
rule permission-write-read:
when { $access isa write-access; }
then { $access has permission "read"; };
rule permission-read:
when { $access isa read-access; }
then { $access has permission "read"; };
rule permission-write:
when { $access isa write-access; }