SlideShare a Scribd company logo
TypeDB Academy | Schema Design
Schema Design
• Motivation for schema
• Conceptual schema of TypeDB, and its relationship to the enhanced ER-Diagram
• How to write schema in TypeQL
Coming to terms with schema-less
To better understand the value that schema plays in our ability to be
expressive and efficient in working with a database, we need to come to
terms with what we already know about using NoSQL databases. . .
Coming to terms with schema-less
In the chat, drop your answer to the below:
How would we go about implementing logical
consistency to your data in a schema-less database?
Motivation for the schema
Schema declares the permissible structure of your data. We do this using
expressive schema constructs, which can constrain our data without
getting in the way.
• logical integrity at insertion-time: constraints on the data inserted
• knowledge representation: expressive querying in near natural language
• store domain context: enables rule based inference
• true-to-life representation of the domain: understanding context
TypeDB allows you to model your domain based on logical and object-oriented
principles. Composed of entity, relationship, and attribute types, as well as type
hierarchies, roles, and rules.
TypeDB’s Data Model
TypeDB is a database with a rich and logical type system, based on the Enhanced
Entity Relationship Model.
The model embeds context with:
• typing: entities, attributes, relations, roles
• type inheritance: single, not multiple
• fully labeled hyper-relations: including composition via named rules
Concept architecture
As entities, relations, attributes are all
sub-types of thing, we should sub-type
each to build a schema for our domain.
These schema concepts define our
types, which can then be instantiated by
our data.
Therefore, we refer to data model and
schema interchangeably.
Terminology:
• type: refers to a sub-type of entity, attribute or relation, as defined
by a a schema
• thing: refers to an instance of any type
• concept: refers to any thing or type
Example
Nomenclature
When visually representing
TypeQL, we use:
• rectangle for entity
• oval for attribute
• diamond for relation
person company
organisation
document
name
content
employment
person company
organisation
document
name
content
employment
Example
Nomenclature
When visually representing
TypeQL, we use:
• owns to declare ownership
of an attribute
• sub for subtypes
• <role-type name> for role-
players in a relation
sub
owns
owns
employee
employer
contract
owns
Visualise the model for our domain
Having seen the TypeDB model, how would you translate this to your domain?
Exercise- 6 minutes:
1) Thinking about your domain and use case, begin to visually map out your
model based on the TypeDB Knowledge Model.
2) What are the entities and their attributes - then what relations between
the data do you recognise or foresee?
3) Draw your model on a scrap piece of paper or an online modelling tool,
we’ll turn it into TypeDB schema next.
person company
organisation
document
name
content
employment
Example Nomenclature
When visually representing
TypeQL, we use:
• owns to declare ownership
of an attribute
• sub for subtypes
• <role-type name> for role-
players in a relation
sub
owns
owns
employee
employer
contract
owns
Visualise the model for our domain
Let’s share what we came up with and see what
differences we found between us.
entity – a thing with a distinct existence in the domain
syntax:
The keyword define is used to precede declarations of our schema. We can
define schema as many times as we want, not just once .
Here person is the entity type. We have declared that we want this type to
inherit from entity using sub . We can refer to the type itself using its type-
name, in this case person.
Defining schema types
define
person sub entity;
relation – describes how two or more things are connected to each other
syntax:
define
employment sub relation,
relates employer,
relates employee;
person sub entity,
plays employment:employee;
company sub entity,
plays employment:employer;
Watch Out!
A role must be declared for a
type to play it, either: inside a
relation; or explicitly, outside
a relation
Defining schema types
relation – in general, any type can be defined to play a role
<schema-type> could be entity , relation , attribute , or your own subtype of one of these. Therefore, relations
can relate anything. These are very useful constructs for building schemas that reflect the real domain well.
We scope the <role-type> a particular <schema-type> can play, in <my-relation-type>. This allows for a
more simple and efficient model, which we can make use of once we begin to query the database.
syntax:
Defining schema types
define
my-schema-type sub <schema-type>,
plays <my-relation-type>:<role-type>;
attribute – a piece of information, describing a property of a thing in a domain
syntax:
Attribute values
long, double, string, Boolean, date – the specifications for these are the same as in Java
Defining schema types
define
full-name sub attribute,
value string;
person sub entity,
owns full-name;
attribute – can only be instantiated at the leaves
Any time we create a new sub-type of an existing <my-attribute-type>, the parent type must be abstract and
defined as such in the schema.
attribute, is already abstract and so sub-types of attribute can be instantiated.
syntax:
Defining schema types
define
name sub attribute,
abstract,
value string;
full-name sub name;
type hierarchies – ”type Y is a subtype of type X, if and only if, every Y is necessarily an X”
syntax:
This means that any charity, company, and university is necessarily an organisation and inherits all
attributes and role-types from the parent.
define
organisation sub entity,
owns name;
charity sub organisation,
plays <relation-type>:group;
company sub organisation,
plays <relation-type>:employer;
university sub organisation,
plays <relation-type>:employer;
:: watch out ::
When sub-typing an
attribute, the parent
must be abstract.
Defining schema types
Defining schema types
Also…
syntax:
define
person sub entity,
owns email @key;
organisation sub entity,
abstract;
request sub relation,
abstract,
relates requestor;
friendship sub request,
relates friend as requester;
:: sneak peak ::
All roles defined to relate
to the parent relation
must also be defined to
relate to the child relation
using the as keyword.
Visualise the model for our domain
Now, let’s build off our “hand-made” model….
Exercise- 10 minutes individually:
1) Iterate on the model you drew and take a run at writing your schema in
TypeQL.
2) Define the entity(s), relation(s), and attribute(s), for your own domain or
use case
3) Once you have gotten to a ”complete” spot, drop your response to:
What was most challenging about this? What caught you up?
Schema syntax reminders
• start with define
• a sub b to subtype a from b
• value string to declare the datatype of an attribute
• owns to declare something can own an attribute
• relates to declare a role in a relation
• plays to declare something can play a role within a specific relation-type
• abstract to declare a <schema-type> to be abstract
• Commas between properties, and semicolon to end a statement
Define
role hierarchies – as is used to sub-type a role inside a relation
syntax:
define
ownership sub relation,
relates owner,
relates owned;
group-ownership sub ownership,
relates group-owner as owner,
relates owned-group as owned;
person sub entity,
plays group-ownership:group-owner;
social-group sub entity,
plays group-ownership:owned-group;
:: note ::
To be able to use both
the sub-type role and the
parent role, we need to
redeclare the parent role.
Schema flexibility
Schema file (.tql) – schema can be added to trivially, at any point.
and then later…
define
person sub entity;
name sub attribute,
value string;
define
person owns name;
## OR
person sub entity,
owns name;
Undefine schema types
Order of undefining – first no instances of that type (to protect our data)
syntax:
It's important to note that undefine [label] sub [type] owns [attribute's label]; undefines the label itself,
rather than its association with the attribute.
undefine
<my-schema-type> sub <schema-type>;
person owns social-handle;
rule co-workers;
employment sub relation;
commit
TypeQL keywords
define – Declare that a statement will create schema types
undefine – Declare that a statement will delete schema types
sub – Declare a subtype
owns – Attaches an attribute type to a type
relates – Declares a role to be involved in a relation (creates the role if it isn’t
otherwise defined)
plays – Declares that a type can be connected through a role’
as – Subtypes a role inside a relation
@key – Declares an attribute to be used as a unique identifier for a type
abstract – Declares that a type cannot have instances
Iterative modelling approach
You can create you schema by writing a TypeQL file.
1) Write/update your .tql file. This can contain define statements, and also
insert and match...insert statements (the latter two are to add example data)
2) Load the .tql file into your database
3) Identify the flaws in your model by:
- Trying to query the model for the insights you need. If the insights cannot be found
correctly, then try to understand why your model is limited. Assessing whether the data you
have can be stored in the model.
4) Clean the database
5) Go back to step (1.) and repeat
Thank you!!

More Related Content

What's hot

JSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked DataJSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked Data
Gregg Kellogg
 
JSON-LD and MongoDB
JSON-LD and MongoDBJSON-LD and MongoDB
JSON-LD and MongoDB
Gregg Kellogg
 
How to Create a Golden Ontology
How to Create a Golden OntologyHow to Create a Golden Ontology
How to Create a Golden Ontology
Mike Bennett
 
Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020
Ontotext
 
The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...
The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...
The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...
Neo4j
 
Tesla sf tm
Tesla sf tmTesla sf tm
Tesla sf tm
Frédéric Lambert
 
Neptune, the Graph Database | AWS Floor28
Neptune, the Graph Database | AWS Floor28Neptune, the Graph Database | AWS Floor28
Neptune, the Graph Database | AWS Floor28
Amazon Web Services
 
Rego Deep Dive
Rego Deep DiveRego Deep Dive
Rego Deep Dive
Torin Sandall
 
Boost Your Neo4j with User-Defined Procedures
Boost Your Neo4j with User-Defined ProceduresBoost Your Neo4j with User-Defined Procedures
Boost Your Neo4j with User-Defined Procedures
Neo4j
 
Neo4j Training Series - Spring Data Neo4j
Neo4j Training Series - Spring Data Neo4jNeo4j Training Series - Spring Data Neo4j
Neo4j Training Series - Spring Data Neo4j
Neo4j
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
Markus Lanthaler
 
Transforming Intelligence Analysis with Knowledge Graphs
Transforming Intelligence Analysis with Knowledge GraphsTransforming Intelligence Analysis with Knowledge Graphs
Transforming Intelligence Analysis with Knowledge Graphs
Neo4j
 
Building Identity Graphs over Heterogeneous Data
Building Identity Graphs over Heterogeneous DataBuilding Identity Graphs over Heterogeneous Data
Building Identity Graphs over Heterogeneous Data
Databricks
 
Introduction to Knowledge Graphs with Grakn and Graql
Introduction to Knowledge Graphs with Grakn and Graql Introduction to Knowledge Graphs with Grakn and Graql
Introduction to Knowledge Graphs with Grakn and Graql
Vaticle
 
A Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security KnowledgeA Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security Knowledge
Vaticle
 
GraphQL
GraphQLGraphQL
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
Neo4j
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDB
Vaticle
 
Gremlin's Anatomy
Gremlin's AnatomyGremlin's Anatomy
Gremlin's Anatomy
Stephen Mallette
 
Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)
Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)
Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)
Sergey Karayev
 

What's hot (20)

JSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked DataJSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked Data
 
JSON-LD and MongoDB
JSON-LD and MongoDBJSON-LD and MongoDB
JSON-LD and MongoDB
 
How to Create a Golden Ontology
How to Create a Golden OntologyHow to Create a Golden Ontology
How to Create a Golden Ontology
 
Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020
 
The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...
The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...
The perfect couple: Uniting Large Language Models and Knowledge Graphs for En...
 
Tesla sf tm
Tesla sf tmTesla sf tm
Tesla sf tm
 
Neptune, the Graph Database | AWS Floor28
Neptune, the Graph Database | AWS Floor28Neptune, the Graph Database | AWS Floor28
Neptune, the Graph Database | AWS Floor28
 
Rego Deep Dive
Rego Deep DiveRego Deep Dive
Rego Deep Dive
 
Boost Your Neo4j with User-Defined Procedures
Boost Your Neo4j with User-Defined ProceduresBoost Your Neo4j with User-Defined Procedures
Boost Your Neo4j with User-Defined Procedures
 
Neo4j Training Series - Spring Data Neo4j
Neo4j Training Series - Spring Data Neo4jNeo4j Training Series - Spring Data Neo4j
Neo4j Training Series - Spring Data Neo4j
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
 
Transforming Intelligence Analysis with Knowledge Graphs
Transforming Intelligence Analysis with Knowledge GraphsTransforming Intelligence Analysis with Knowledge Graphs
Transforming Intelligence Analysis with Knowledge Graphs
 
Building Identity Graphs over Heterogeneous Data
Building Identity Graphs over Heterogeneous DataBuilding Identity Graphs over Heterogeneous Data
Building Identity Graphs over Heterogeneous Data
 
Introduction to Knowledge Graphs with Grakn and Graql
Introduction to Knowledge Graphs with Grakn and Graql Introduction to Knowledge Graphs with Grakn and Graql
Introduction to Knowledge Graphs with Grakn and Graql
 
A Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security KnowledgeA Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security Knowledge
 
GraphQL
GraphQLGraphQL
GraphQL
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDB
 
Gremlin's Anatomy
Gremlin's AnatomyGremlin's Anatomy
Gremlin's Anatomy
 
Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)
Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)
Lecture 6: Infrastructure & Tooling (Full Stack Deep Learning - Spring 2021)
 

Similar to TypeDB Academy- Getting Started with Schema Design

database1
database1database1
database1
Monika Sharma
 
Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4
Vibrant Technologies & Computers
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spacesAndrea Saltarello
 
27 f157al5enhanced er diagram
27 f157al5enhanced er diagram27 f157al5enhanced er diagram
27 f157al5enhanced er diagram
dddgh
 
How publishing works in the digital era
How publishing works in the digital eraHow publishing works in the digital era
How publishing works in the digital era
Apex CoVantage
 
ER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdfER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdf
SadiaSharmin40
 
Learn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsLearn C# Programming - Structure & Enums
Learn C# Programming - Structure & Enums
Eng Teong Cheah
 
DBMS Class 3
DBMS Class 3DBMS Class 3
George McGeachie's Favourite PowerDesigner features
George McGeachie's Favourite PowerDesigner featuresGeorge McGeachie's Favourite PowerDesigner features
George McGeachie's Favourite PowerDesigner features
George McGeachie
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server III
NodeXperts
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdf
fikadumola
 
Cn presentation on the topic called as re modelling
Cn presentation on the topic called as re modellingCn presentation on the topic called as re modelling
Cn presentation on the topic called as re modelling
g30162363
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
VisnuDharsini
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
Rupali Rana
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
Raghu Bright
 
Summary data modelling
Summary data modellingSummary data modelling
Summary data modelling
Novita Sari
 

Similar to TypeDB Academy- Getting Started with Schema Design (20)

database1
database1database1
database1
 
Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spaces
 
27 f157al5enhanced er diagram
27 f157al5enhanced er diagram27 f157al5enhanced er diagram
27 f157al5enhanced er diagram
 
enhanced er diagram
enhanced er diagramenhanced er diagram
enhanced er diagram
 
How publishing works in the digital era
How publishing works in the digital eraHow publishing works in the digital era
How publishing works in the digital era
 
ER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdfER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdf
 
Chap08
Chap08Chap08
Chap08
 
Learn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsLearn C# Programming - Structure & Enums
Learn C# Programming - Structure & Enums
 
DBMS Class 3
DBMS Class 3DBMS Class 3
DBMS Class 3
 
George McGeachie's Favourite PowerDesigner features
George McGeachie's Favourite PowerDesigner featuresGeorge McGeachie's Favourite PowerDesigner features
George McGeachie's Favourite PowerDesigner features
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server III
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdf
 
Ooad ch 3
Ooad ch 3Ooad ch 3
Ooad ch 3
 
Cn presentation on the topic called as re modelling
Cn presentation on the topic called as re modellingCn presentation on the topic called as re modelling
Cn presentation on the topic called as re modelling
 
Mca 504 dotnet_unit4
Mca 504 dotnet_unit4Mca 504 dotnet_unit4
Mca 504 dotnet_unit4
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 
Summary data modelling
Summary data modellingSummary data modelling
Summary data modelling
 

More from Vaticle

Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug DiscoveryBuilding Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
Vaticle
 
Loading Huge Amounts of Data
Loading Huge Amounts of DataLoading Huge Amounts of Data
Loading Huge Amounts of Data
Vaticle
 
Natural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge GraphNatural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge Graph
Vaticle
 
The Next Big Thing in AI - Causality
The Next Big Thing in AI - CausalityThe Next Big Thing in AI - Causality
The Next Big Thing in AI - Causality
Vaticle
 
Building a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge GraphBuilding a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge Graph
Vaticle
 
Knowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdfKnowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdf
Vaticle
 
Building a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdfBuilding a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdf
Vaticle
 
Enabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdfEnabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdf
Vaticle
 
Beyond SQL - Comparing SQL to TypeQL
Beyond SQL - Comparing SQL to TypeQLBeyond SQL - Comparing SQL to TypeQL
Beyond SQL - Comparing SQL to TypeQL
Vaticle
 
Comparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDBComparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDB
Vaticle
 
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning EngineReasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
Vaticle
 
Intro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed databaseIntro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed database
Vaticle
 
Strongly Typed Data for Machine Learning
Strongly Typed Data for Machine LearningStrongly Typed Data for Machine Learning
Strongly Typed Data for Machine Learning
Vaticle
 
Open World Robotics
Open World RoboticsOpen World Robotics
Open World Robotics
Vaticle
 
Combining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital TransformationCombining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital Transformation
Vaticle
 
How can we complete a Knowledge Graph?
How can we complete a Knowledge Graph?How can we complete a Knowledge Graph?
How can we complete a Knowledge Graph?
Vaticle
 
Text-Mined Data in a Knowledge Graph
Text-Mined Data in a Knowledge GraphText-Mined Data in a Knowledge Graph
Text-Mined Data in a Knowledge Graph
Vaticle
 
Power of the Run Graph
Power of the Run GraphPower of the Run Graph
Power of the Run Graph
Vaticle
 
Increase Self Awareness on Robotic Systems
Increase Self Awareness on Robotic SystemsIncrease Self Awareness on Robotic Systems
Increase Self Awareness on Robotic Systems
Vaticle
 
Grounding Conversational AI in a Knowledge Base
Grounding Conversational AI in a Knowledge BaseGrounding Conversational AI in a Knowledge Base
Grounding Conversational AI in a Knowledge Base
Vaticle
 

More from Vaticle (20)

Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug DiscoveryBuilding Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
 
Loading Huge Amounts of Data
Loading Huge Amounts of DataLoading Huge Amounts of Data
Loading Huge Amounts of Data
 
Natural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge GraphNatural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge Graph
 
The Next Big Thing in AI - Causality
The Next Big Thing in AI - CausalityThe Next Big Thing in AI - Causality
The Next Big Thing in AI - Causality
 
Building a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge GraphBuilding a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge Graph
 
Knowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdfKnowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdf
 
Building a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdfBuilding a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdf
 
Enabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdfEnabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdf
 
Beyond SQL - Comparing SQL to TypeQL
Beyond SQL - Comparing SQL to TypeQLBeyond SQL - Comparing SQL to TypeQL
Beyond SQL - Comparing SQL to TypeQL
 
Comparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDBComparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDB
 
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning EngineReasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
 
Intro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed databaseIntro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed database
 
Strongly Typed Data for Machine Learning
Strongly Typed Data for Machine LearningStrongly Typed Data for Machine Learning
Strongly Typed Data for Machine Learning
 
Open World Robotics
Open World RoboticsOpen World Robotics
Open World Robotics
 
Combining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital TransformationCombining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital Transformation
 
How can we complete a Knowledge Graph?
How can we complete a Knowledge Graph?How can we complete a Knowledge Graph?
How can we complete a Knowledge Graph?
 
Text-Mined Data in a Knowledge Graph
Text-Mined Data in a Knowledge GraphText-Mined Data in a Knowledge Graph
Text-Mined Data in a Knowledge Graph
 
Power of the Run Graph
Power of the Run GraphPower of the Run Graph
Power of the Run Graph
 
Increase Self Awareness on Robotic Systems
Increase Self Awareness on Robotic SystemsIncrease Self Awareness on Robotic Systems
Increase Self Awareness on Robotic Systems
 
Grounding Conversational AI in a Knowledge Base
Grounding Conversational AI in a Knowledge BaseGrounding Conversational AI in a Knowledge Base
Grounding Conversational AI in a Knowledge Base
 

Recently uploaded

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 

Recently uploaded (20)

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

TypeDB Academy- Getting Started with Schema Design

  • 1. TypeDB Academy | Schema Design
  • 2. Schema Design • Motivation for schema • Conceptual schema of TypeDB, and its relationship to the enhanced ER-Diagram • How to write schema in TypeQL
  • 3. Coming to terms with schema-less To better understand the value that schema plays in our ability to be expressive and efficient in working with a database, we need to come to terms with what we already know about using NoSQL databases. . .
  • 4. Coming to terms with schema-less In the chat, drop your answer to the below: How would we go about implementing logical consistency to your data in a schema-less database?
  • 5. Motivation for the schema Schema declares the permissible structure of your data. We do this using expressive schema constructs, which can constrain our data without getting in the way. • logical integrity at insertion-time: constraints on the data inserted • knowledge representation: expressive querying in near natural language • store domain context: enables rule based inference • true-to-life representation of the domain: understanding context
  • 6. TypeDB allows you to model your domain based on logical and object-oriented principles. Composed of entity, relationship, and attribute types, as well as type hierarchies, roles, and rules.
  • 7. TypeDB’s Data Model TypeDB is a database with a rich and logical type system, based on the Enhanced Entity Relationship Model. The model embeds context with: • typing: entities, attributes, relations, roles • type inheritance: single, not multiple • fully labeled hyper-relations: including composition via named rules
  • 8. Concept architecture As entities, relations, attributes are all sub-types of thing, we should sub-type each to build a schema for our domain. These schema concepts define our types, which can then be instantiated by our data. Therefore, we refer to data model and schema interchangeably. Terminology: • type: refers to a sub-type of entity, attribute or relation, as defined by a a schema • thing: refers to an instance of any type • concept: refers to any thing or type
  • 9. Example Nomenclature When visually representing TypeQL, we use: • rectangle for entity • oval for attribute • diamond for relation person company organisation document name content employment
  • 10. person company organisation document name content employment Example Nomenclature When visually representing TypeQL, we use: • owns to declare ownership of an attribute • sub for subtypes • <role-type name> for role- players in a relation sub owns owns employee employer contract owns
  • 11. Visualise the model for our domain Having seen the TypeDB model, how would you translate this to your domain? Exercise- 6 minutes: 1) Thinking about your domain and use case, begin to visually map out your model based on the TypeDB Knowledge Model. 2) What are the entities and their attributes - then what relations between the data do you recognise or foresee? 3) Draw your model on a scrap piece of paper or an online modelling tool, we’ll turn it into TypeDB schema next.
  • 12. person company organisation document name content employment Example Nomenclature When visually representing TypeQL, we use: • owns to declare ownership of an attribute • sub for subtypes • <role-type name> for role- players in a relation sub owns owns employee employer contract owns
  • 13. Visualise the model for our domain Let’s share what we came up with and see what differences we found between us.
  • 14. entity – a thing with a distinct existence in the domain syntax: The keyword define is used to precede declarations of our schema. We can define schema as many times as we want, not just once . Here person is the entity type. We have declared that we want this type to inherit from entity using sub . We can refer to the type itself using its type- name, in this case person. Defining schema types define person sub entity;
  • 15. relation – describes how two or more things are connected to each other syntax: define employment sub relation, relates employer, relates employee; person sub entity, plays employment:employee; company sub entity, plays employment:employer; Watch Out! A role must be declared for a type to play it, either: inside a relation; or explicitly, outside a relation Defining schema types
  • 16. relation – in general, any type can be defined to play a role <schema-type> could be entity , relation , attribute , or your own subtype of one of these. Therefore, relations can relate anything. These are very useful constructs for building schemas that reflect the real domain well. We scope the <role-type> a particular <schema-type> can play, in <my-relation-type>. This allows for a more simple and efficient model, which we can make use of once we begin to query the database. syntax: Defining schema types define my-schema-type sub <schema-type>, plays <my-relation-type>:<role-type>;
  • 17. attribute – a piece of information, describing a property of a thing in a domain syntax: Attribute values long, double, string, Boolean, date – the specifications for these are the same as in Java Defining schema types define full-name sub attribute, value string; person sub entity, owns full-name;
  • 18. attribute – can only be instantiated at the leaves Any time we create a new sub-type of an existing <my-attribute-type>, the parent type must be abstract and defined as such in the schema. attribute, is already abstract and so sub-types of attribute can be instantiated. syntax: Defining schema types define name sub attribute, abstract, value string; full-name sub name;
  • 19. type hierarchies – ”type Y is a subtype of type X, if and only if, every Y is necessarily an X” syntax: This means that any charity, company, and university is necessarily an organisation and inherits all attributes and role-types from the parent. define organisation sub entity, owns name; charity sub organisation, plays <relation-type>:group; company sub organisation, plays <relation-type>:employer; university sub organisation, plays <relation-type>:employer; :: watch out :: When sub-typing an attribute, the parent must be abstract. Defining schema types
  • 20. Defining schema types Also… syntax: define person sub entity, owns email @key; organisation sub entity, abstract; request sub relation, abstract, relates requestor; friendship sub request, relates friend as requester; :: sneak peak :: All roles defined to relate to the parent relation must also be defined to relate to the child relation using the as keyword.
  • 21. Visualise the model for our domain Now, let’s build off our “hand-made” model…. Exercise- 10 minutes individually: 1) Iterate on the model you drew and take a run at writing your schema in TypeQL. 2) Define the entity(s), relation(s), and attribute(s), for your own domain or use case 3) Once you have gotten to a ”complete” spot, drop your response to: What was most challenging about this? What caught you up?
  • 22. Schema syntax reminders • start with define • a sub b to subtype a from b • value string to declare the datatype of an attribute • owns to declare something can own an attribute • relates to declare a role in a relation • plays to declare something can play a role within a specific relation-type • abstract to declare a <schema-type> to be abstract • Commas between properties, and semicolon to end a statement
  • 23. Define role hierarchies – as is used to sub-type a role inside a relation syntax: define ownership sub relation, relates owner, relates owned; group-ownership sub ownership, relates group-owner as owner, relates owned-group as owned; person sub entity, plays group-ownership:group-owner; social-group sub entity, plays group-ownership:owned-group; :: note :: To be able to use both the sub-type role and the parent role, we need to redeclare the parent role.
  • 24. Schema flexibility Schema file (.tql) – schema can be added to trivially, at any point. and then later… define person sub entity; name sub attribute, value string; define person owns name; ## OR person sub entity, owns name;
  • 25. Undefine schema types Order of undefining – first no instances of that type (to protect our data) syntax: It's important to note that undefine [label] sub [type] owns [attribute's label]; undefines the label itself, rather than its association with the attribute. undefine <my-schema-type> sub <schema-type>; person owns social-handle; rule co-workers; employment sub relation; commit
  • 26. TypeQL keywords define – Declare that a statement will create schema types undefine – Declare that a statement will delete schema types sub – Declare a subtype owns – Attaches an attribute type to a type relates – Declares a role to be involved in a relation (creates the role if it isn’t otherwise defined) plays – Declares that a type can be connected through a role’ as – Subtypes a role inside a relation @key – Declares an attribute to be used as a unique identifier for a type abstract – Declares that a type cannot have instances
  • 27. Iterative modelling approach You can create you schema by writing a TypeQL file. 1) Write/update your .tql file. This can contain define statements, and also insert and match...insert statements (the latter two are to add example data) 2) Load the .tql file into your database 3) Identify the flaws in your model by: - Trying to query the model for the insights you need. If the insights cannot be found correctly, then try to understand why your model is limited. Assessing whether the data you have can be stored in the model. 4) Clean the database 5) Go back to step (1.) and repeat