SlideShare a Scribd company logo
1 of 28
Download to read offline
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

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 KnowledgeVaticle
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring DataArturs Drozdovs
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...jexp
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4jNeo4j
 
Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...
Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...
Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...bitnineglobal
 
Graph & Amazon Neptune: Database Week SF
Graph & Amazon Neptune: Database Week SFGraph & Amazon Neptune: Database Week SF
Graph & Amazon Neptune: Database Week SFAmazon Web Services
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDBVaticle
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph DatabasesMax De Marzi
 
Neo4j Drivers Best Practices
Neo4j Drivers Best PracticesNeo4j Drivers Best Practices
Neo4j Drivers Best PracticesNeo4j
 
Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례
Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례 Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례
Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례 bitnineglobal
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshellFabien Gandon
 
Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...
Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...
Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...Amazon Web Services
 
On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018
On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018
On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018Amazon Web Services
 
Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...
Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...
Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...Databricks
 
201804 neo4 j_cypher_guide
201804 neo4 j_cypher_guide201804 neo4 j_cypher_guide
201804 neo4 j_cypher_guideJunyi Song
 

What's hot (20)

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
 
Graph and Amazon Neptune
Graph and Amazon NeptuneGraph and Amazon Neptune
Graph and Amazon Neptune
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring Data
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
 
Gremlin's Anatomy
Gremlin's AnatomyGremlin's Anatomy
Gremlin's Anatomy
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...
Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...
Graph Database Meetup in Korea #8. Graph Database 5 Offerings_ DecisionTutor ...
 
Graph & Amazon Neptune: Database Week SF
Graph & Amazon Neptune: Database Week SFGraph & Amazon Neptune: Database Week SF
Graph & Amazon Neptune: Database Week SF
 
Python and MongoDB
Python and MongoDBPython and MongoDB
Python and MongoDB
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDB
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
Neo4j Drivers Best Practices
Neo4j Drivers Best PracticesNeo4j Drivers Best Practices
Neo4j Drivers Best Practices
 
Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례
Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례 Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례
Graph Database Meetup in Korea #4. 그래프 이론을 적용한 그래프 데이터베이스 활용 사례
 
Rego Deep Dive
Rego Deep DiveRego Deep Dive
Rego Deep Dive
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshell
 
Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...
Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...
Work Backwards to Your Graph Data Model & Queries with Amazon Neptune (DAT330...
 
On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018
On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018
On-Ramp to Graph Databases and Amazon Neptune (DAT335) - AWS re:Invent 2018
 
Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...
Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...
Graph Features in Spark 3.0: Integrating Graph Querying and Algorithms in Spa...
 
201804 neo4 j_cypher_guide
201804 neo4 j_cypher_guide201804 neo4 j_cypher_guide
201804 neo4 j_cypher_guide
 

Similar to TypeDB Academy- Getting Started with Schema Design

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 diagramdddgh
 
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 eraApex 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.pdfSadiaSharmin40
 
Learn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsLearn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsEng Teong Cheah
 
George McGeachie's Favourite PowerDesigner features
George McGeachie's Favourite PowerDesigner featuresGeorge McGeachie's Favourite PowerDesigner features
George McGeachie's Favourite PowerDesigner featuresGeorge McGeachie
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server IIINodeXperts
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdffikadumola
 
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 modellingg30162363
 
Summary data modelling
Summary data modellingSummary data modelling
Summary data modellingNovita 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
 
enhanced er diagram
enhanced er diagramenhanced er diagram
enhanced er diagram
 
27 f157al5enhanced er diagram
27 f157al5enhanced er diagram27 f157al5enhanced er diagram
27 f157al5enhanced 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 DiscoveryVaticle
 
Loading Huge Amounts of Data
Loading Huge Amounts of DataLoading Huge Amounts of Data
Loading Huge Amounts of DataVaticle
 
Natural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge GraphNatural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge GraphVaticle
 
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 - CausalityVaticle
 
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 GraphVaticle
 
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.pdfVaticle
 
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.pdfVaticle
 
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.pdfVaticle
 
Beyond SQL - Comparing SQL to TypeQL
Beyond SQL - Comparing SQL to TypeQLBeyond SQL - Comparing SQL to TypeQL
Beyond SQL - Comparing SQL to TypeQLVaticle
 
Comparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDBComparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDBVaticle
 
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 EngineVaticle
 
Strongly Typed Data for Machine Learning
Strongly Typed Data for Machine LearningStrongly Typed Data for Machine Learning
Strongly Typed Data for Machine LearningVaticle
 
Open World Robotics
Open World RoboticsOpen World Robotics
Open World RoboticsVaticle
 
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 TransformationVaticle
 
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 GraphVaticle
 
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
 
Power of the Run Graph
Power of the Run GraphPower of the Run Graph
Power of the Run GraphVaticle
 
Increase Self Awareness on Robotic Systems
Increase Self Awareness on Robotic SystemsIncrease Self Awareness on Robotic Systems
Increase Self Awareness on Robotic SystemsVaticle
 
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 BaseVaticle
 

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
 
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
 
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
 
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 meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Recently uploaded (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

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