SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler 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!!

Mais conteúdo relacionado

Mais procurados

ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)Amazon Web Services Japan
 
Cloudflare로 DDoS 방어하기 실전편
Cloudflare로 DDoS 방어하기 실전편Cloudflare로 DDoS 방어하기 실전편
Cloudflare로 DDoS 방어하기 실전편Jean Ryu
 
はじめてのDynamoDBスキーマ設計
はじめてのDynamoDBスキーマ設計はじめてのDynamoDBスキーマ設計
はじめてのDynamoDBスキーマ設計Yoichi Toyota
 
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3 データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3 Hiroshi Ito
 
MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法Tetsutaro Watanabe
 
コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)
コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)
コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)NTT DATA Technology & Innovation
 
Spring Boot + Netflix Eureka
Spring Boot + Netflix EurekaSpring Boot + Netflix Eureka
Spring Boot + Netflix Eureka心 谷本
 
20190821 AWS Black Belt Online Seminar AWS AppSync
20190821 AWS Black Belt Online Seminar AWS AppSync20190821 AWS Black Belt Online Seminar AWS AppSync
20190821 AWS Black Belt Online Seminar AWS AppSyncAmazon Web Services Japan
 
Laravelの検索機能の実装方法
Laravelの検索機能の実装方法Laravelの検索機能の実装方法
Laravelの検索機能の実装方法yoshitaro yoyo
 
Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)Scott Wlaschin
 
これからのネイティブアプリにおけるOpenID Connectの活用
これからのネイティブアプリにおけるOpenID Connectの活用これからのネイティブアプリにおけるOpenID Connectの活用
これからのネイティブアプリにおけるOpenID Connectの活用Masaru Kurahayashi
 
文字コードに起因する脆弱性とその対策(増補版)
文字コードに起因する脆弱性とその対策(増補版)文字コードに起因する脆弱性とその対策(増補版)
文字コードに起因する脆弱性とその対策(増補版)Hiroshi Tokumaru
 
開発チーム管理で役立ったVSCode拡張機能
開発チーム管理で役立ったVSCode拡張機能開発チーム管理で役立ったVSCode拡張機能
開発チーム管理で役立ったVSCode拡張機能Masaki Suzuki
 
インターネット広告の概要とシステム設計
インターネット広告の概要とシステム設計インターネット広告の概要とシステム設計
インターネット広告の概要とシステム設計MicroAd, Inc.(Engineer)
 
MVCになぞらえて理解するReact
MVCになぞらえて理解するReactMVCになぞらえて理解するReact
MVCになぞらえて理解するReactiPride Co., Ltd.
 
202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤
202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤
202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤Amazon Web Services Japan
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011H Iseri
 
AWSではじめるMLOps
AWSではじめるMLOpsAWSではじめるMLOps
AWSではじめるMLOpsMariOhbuchi
 

Mais procurados (20)

ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
 
Cloudflare로 DDoS 방어하기 실전편
Cloudflare로 DDoS 방어하기 실전편Cloudflare로 DDoS 방어하기 실전편
Cloudflare로 DDoS 방어하기 실전편
 
はじめてのDynamoDBスキーマ設計
はじめてのDynamoDBスキーマ設計はじめてのDynamoDBスキーマ設計
はじめてのDynamoDBスキーマ設計
 
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3 データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
 
MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法
 
コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)
コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)
コレクションフレームワーク関連セッション(JavaOne & Devoxx報告会 2022 発表資料)
 
Spring Boot + Netflix Eureka
Spring Boot + Netflix EurekaSpring Boot + Netflix Eureka
Spring Boot + Netflix Eureka
 
20190821 AWS Black Belt Online Seminar AWS AppSync
20190821 AWS Black Belt Online Seminar AWS AppSync20190821 AWS Black Belt Online Seminar AWS AppSync
20190821 AWS Black Belt Online Seminar AWS AppSync
 
Laravelの検索機能の実装方法
Laravelの検索機能の実装方法Laravelの検索機能の実装方法
Laravelの検索機能の実装方法
 
GraphQL入門 (AWS AppSync)
GraphQL入門 (AWS AppSync)GraphQL入門 (AWS AppSync)
GraphQL入門 (AWS AppSync)
 
Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)
 
これからのネイティブアプリにおけるOpenID Connectの活用
これからのネイティブアプリにおけるOpenID Connectの活用これからのネイティブアプリにおけるOpenID Connectの活用
これからのネイティブアプリにおけるOpenID Connectの活用
 
文字コードに起因する脆弱性とその対策(増補版)
文字コードに起因する脆弱性とその対策(増補版)文字コードに起因する脆弱性とその対策(増補版)
文字コードに起因する脆弱性とその対策(増補版)
 
開発チーム管理で役立ったVSCode拡張機能
開発チーム管理で役立ったVSCode拡張機能開発チーム管理で役立ったVSCode拡張機能
開発チーム管理で役立ったVSCode拡張機能
 
インターネット広告の概要とシステム設計
インターネット広告の概要とシステム設計インターネット広告の概要とシステム設計
インターネット広告の概要とシステム設計
 
MVCになぞらえて理解するReact
MVCになぞらえて理解するReactMVCになぞらえて理解するReact
MVCになぞらえて理解するReact
 
202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤
202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤
202106 AWS Black Belt Online Seminar 小売現場のデータを素早くビジネス に活用するAWSデータ基盤
 
DevOps with Database on AWS
DevOps with Database on AWSDevOps with Database on AWS
DevOps with Database on AWS
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011
 
AWSではじめるMLOps
AWSではじめるMLOpsAWSではじめるMLOps
AWSではじめるMLOps
 

Semelhante a Schema Design in TypeDB

TypeDB Academy | Modelling Principles
TypeDB Academy | Modelling PrinciplesTypeDB Academy | Modelling Principles
TypeDB Academy | Modelling PrinciplesVaticle
 
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
 

Semelhante a Schema Design in TypeDB (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
 
TypeDB Academy | Modelling Principles
TypeDB Academy | Modelling PrinciplesTypeDB Academy | Modelling Principles
TypeDB Academy | Modelling Principles
 
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
 

Mais de 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
 
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
 
Unifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & Knowledge GraphUnifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & 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
 
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
 
Graph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphsGraph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphsVaticle
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDBVaticle
 
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
 

Mais de 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
 
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
 
Unifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & Knowledge GraphUnifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & 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
 
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
 
Graph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphsGraph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphs
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDB
 
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
 

Último

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Último (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Schema Design in TypeDB

  • 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