SlideShare a Scribd company logo
1 of 31
Download to read offline
TypeDB Academy | Modelling Principles
Modelling Principles
• The modelling philosophy, principles and techniques of TypeDB
• Best practices for designing your domain model
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.
Domain modeling – best practices
Here we set out the best practice guidelines for creating a TypeDB
schema. It is possible to create a successful model that does not conform
to the guidelines.
These guidelines aim to help maximise:
• true-to-domain modelling
• flexibility
• and extensibility
Importance of modeling choices
We want to carefully choose our data model, that is, choosing what should be an entity, a relation,
or an attribute.
We want this model to closely reflect the domain. In this way we can know that if new data
becomes available in the domain it will fit into the data model.
With this schema, when later we find
there is information regarding a
person’s employment, how can we add
it?
If the domain is modelled true-to-life,
then extra schema (and therefore data)
is added trivially.
person company
document
owns
employment
end-date
start-date
employee employer
owns
contract
person company
employee
X
✓
Importance of modeling choices
Naming and choosing your entities, relations and attributes are two issues that
are tied together.
The naming should closely link to typical domain terminology, since natural
language is the means to describe the domain. Using the expected domain
terminology is important, this lets another others working with you to easily:
• understand your model
• maintain it
• extend it
• adapt it.
Focussing on terminology to determine
structure is a typical approach for
software architecture in general, not just
for TypeDB schema
Naming - formatting
• naming is in all lower case
• use hyphens
• indent on newlines after declaring a type e.g.
define
person sub entity,
owns full-name;
Naming - Types
A type name should:
• ideally be a noun (except for attributes)
• be singular, the presence of more than one instance lends to plurality
• be as context-specific as possible, using the exact word that describes the
concept in-context
• if you can’t find a noun specific enough then try concatenating two or more
nouns by hyphenating them:
• these can quickly become verbose, so try and find a balance between
specificity and verbosity.
define
location-hierarchy sub relation,
relates subordinate,
relates superior;
Type names
Continued…
• if a noun can’t be found, then use a present participle or past-participle of a
verb as an adjective, to capture the context. Combine this with a context non-
specific noun.
• e.g. below we use authored-content, since content would be too generic,
and authored-book would be too specific (as it would rule out other types
of content):
• also consider using prepositions i.e.: to, from, by, of
authorship sub relation,
relates author,
relates authored-content;
Let’s iterate on our schema
Now that we’ve talked through some of the ways to name things, how would
you iterate on your schema?
Exercise- 6 minutes individually:
1) Review current naming choices.
2) Where would you make changes – make them.
3) Be prepared so share at least one change you made and why.
Modelling decisions – entities
“An entity may be defined as a thing capable of an independent existence that
can be uniquely identified. An entity is an abstraction from the complexities of a
domain. When we speak of an entity, we normally speak of some aspect of the
real world that can be distinguished from other aspects of the real world.”
Modelling decisions – entities
Good choices for entities are:
• Any physical thing in the real world should be modelled as an entity (e.g. animal,
person, device, building)
• Anything that exists logically but doesn’t require involvement of other things in
order to exist: organisation, school
• Use concrete/proper/common/abstract/collective nouns:
• concrete – person, tree, car
• proper – homo sapiens (sometimes the attribute name of an instance)
• abstract – religion, pain, principle
• collective – family, government, team, orchestra, set
• To specialise a general noun, use in combination with another noun – social group
Modelling decisions – relations
It is easy to say for certain that a concept is definitely an entity, e.g. car.
It is harder, the more conceptual a thing is, to decide whether it should be an entity or
a relation.
One way to decipher this, is to start by examining the potential relation as a binary
relation – relations that must either have the property or anti-property for each of
the following cases
Symmetric – relation is the same in both directions
Transitive– relation can be chained
Reflexive – role-player can be related to itself through the relation
Modelling decisions – relations
Example
An employment relation, that relates employee and employer role-players, is anti-
symmetric, anti-transitive, and anti-reflexive.
Therefore we can logically call this type a relation.
Example
Religion as a relation however, is not symmetric or anti-symmetric, transitive or anti-
transitive, nor reflexive or anti-reflexive.
Therefore we can conclude that a religion, is not binary and either an entity or a
ternary/n-ary relation.
Modelling decisions – relations
In general, relations shouldn’t make sense without their roles. For example, a
marriage can’t logically exist without at least one spouse/husband/wife.
Ideally, we are looking for the concept that connects two things, not a direct
connection (often those are the role names, like employee).
• for instance, below we can see that we don’t use “owns” as the type-name, but
instead we use the verbal noun of owns: ownership
ownership sub relation,
relates owner,
relates property;
Modelling decisions – relations
Gather together domain terminology that sounds similar to the concept you want to
model. Then determine which are candidate relation, role, and entity names
(determining and naming attributes is often not too hard).
Remember that a role describes how a thing behaves in the scope of a relation.
Examples with role-player my-schema-type, role, relation :
• a car behaves like property in an ownership
• a station behaves as a stop along a train-route
• a person behaves as an employee in an employment
Modelling decisions – relations
Relation names could describe membership to a grouping/collection of things
(component, group-membership), an action/ongoing state (marriage, comparison,
authorship, participation), or a description of a direct interrelation between two or
more things (friendship, parenthood, association, drug-protein-interaction)
group-membership sub relation,
relates member,
relates group;
drug-protein-interaction sub relation,
relates inhibitor,
relates antagonist
relates blocker,
relates target-protein;
Modelling decisions – relations
A relation is defined such that an instance should not be able to exist without
relating at least one instance for one of its roles. This is the idea that a relation is
dependent upon the existence of one or more role-players.
• A relation should still make sense even if any number of it’s role-players are
missing
• The roles and role-players should make logical sense to be connected in any
combination
Modelling decisions – relations
You should find that you choose names from these categories:
• abstract nouns
• transitive verbs that can accept 2 or more arguments – decide, agree, marry
• their verbal nouns are preferable – decision, agreement, marriage
Modelling decisions – roles
Nouns, verbs, prepositions
location-of sub relation,
abstract
relates located,
relates location;
direction sub relation,
relates from,
relates to;
ownership sub relation,
relates owner,
relates property;
Modelling decisions – relations
Wherever possible, relations should be named in such a way that the name doesn’t
include a ‘reference’ to one of its role-players in particular.
Parenthood is an example of a fairly unavoidable case, where the relation naming
refers more to the role of parent than the role of child .
An example of the ideal case would be:
hierarchy sub relation,
relates superior,
relates subordinate;
Let’s iterate on our schema
Discussion
Looking specifically at your relations, what would you change or what do you
imagine needing to put more thought to?
Modelling decisions – attributes
Usually the easiest to identify, as they are the direct description of a set of values
that we want to model.
Naming an attribute:
• The name of an attribute should refer to a literal value.
• Make attributes context-specific – by concatenating words or ending with a
noun
• Abstract nouns e.g. colour
• Adjectives e.g. friendly
• Intransitive verbs (no direct objects, can’t be followed by “who” or “what”) e.g.
is-raining, graduated
Benefits of inheritance – scoping queries
Wide scope: get all the posts
post
status-update
sub
comment media
photo video
sub sub
sub sub
Intermediate scope: get all media
match $m isa media;
post sub entity,
status-update sub post;
comment sub post;
media sub post;
video sub media;
photo sub media;
match $p isa post;
match $c isa comment;
Narrow scope: get all comments
Benefits of inheritance – constraints
person
ownership
owner
owned
However, we can see a problem. Based on this schema, a person
can own an office and a company can own a social-group.
company
office
social-group
owner
owned
ownership sub relation,
relates owner,
relates owned;
company sub entity,
plays ownership:owner;
office sub entity,
plays ownership:owned;
social-group sub entity,
plays ownership:owner;
person sub entity,
plays ownership:owned;
Benefits of inheritance – constraints
person
ownership
social-group
owned-group
group-ownership office-ownership
group-owner
company office
owned-office
office-owner
owned
ownership sub relation,
abstract,
relates owner,
relates owned;
office-ownership sub ownership,
relates office-owner as owner,
relates owned-office as owner;
owned
Composition vs. inheritance
Composition replaces the temptation of multiple inheritance.
“Entity type Y is a subtype (subclass) of an entity type X if and only if every Y is necessarily an X”
(https:/en.wikipedia.org/wiki/Enhanced_entity%C3%A2%C2%80%C2%93relationship_model)
Therefore define customer sub person; is a bad idea, since:
• An organisation could be a customer, therefore customer is a behaviour (a role)
• A person who plays the role of a customer could play the role of many other things, e.g. teacher
Mindset Shift
View using roles as composition for behaviours of a concept
Try putting names in a context like this:
A [relation] has a [role] in the form of a [thing]
Ternary and n-ary Relations
To help us see the use of ternary relations, consider someone buying a product
vendor
product
owns
Start with only binary relations Ternary – since we have 3 role-players in one relation
transaction
product
company person
custom
er
customer
purchase
sale
product
company person
Where do we add value for the sale? Here, value, can be added trivially
value
Nested relations
vendor
product
owns
Now we can refer to the transaction in other
relations.
Note that this can be favourable over adding
another role to the existing relation.
This is better for:
• Consistency across schema
• Versatility, we can add more information to
either of the two relations
transaction
product
company person
customer
value
place
located
location
location-of-
transaction
Optimisation
Schema design impacts query performance.
Use context-specific relation and role names, this allows the query planner to
find a good path (otherwise all data is homogeneous, it all looks the same).
Thank you!!

More Related Content

What's hot

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
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQLOpen Data Support
 
Apache Kylin - Balance Between Space and Time
Apache Kylin - Balance Between Space and TimeApache Kylin - Balance Between Space and Time
Apache Kylin - Balance Between Space and TimeDataWorks Summit
 
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
 
GraphFrames: Graph Queries In Spark SQL
GraphFrames: Graph Queries In Spark SQLGraphFrames: Graph Queries In Spark SQL
GraphFrames: Graph Queries In Spark SQLSpark Summit
 
Convertir Diagrama Entidad-Relacion a Modelo Relacional.
Convertir Diagrama Entidad-Relacion a Modelo Relacional.Convertir Diagrama Entidad-Relacion a Modelo Relacional.
Convertir Diagrama Entidad-Relacion a Modelo Relacional.Erivan Martinez Ovando
 
Using Knowledge Graphs to Predict Customer Needs and Improve Quality
Using Knowledge Graphs to Predict Customer Needs and Improve QualityUsing Knowledge Graphs to Predict Customer Needs and Improve Quality
Using Knowledge Graphs to Predict Customer Needs and Improve QualityNeo4j
 
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
 
The Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageThe Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageMarko Rodriguez
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFSNilesh Wagmare
 
Rdf data-model-and-storage
Rdf data-model-and-storageRdf data-model-and-storage
Rdf data-model-and-storage灿辉 葛
 
Base de datos itfip ortegon y triana
Base de datos itfip ortegon y trianaBase de datos itfip ortegon y triana
Base de datos itfip ortegon y trianasecangry
 
ESWC 2017 Tutorial Knowledge Graphs
ESWC 2017 Tutorial Knowledge GraphsESWC 2017 Tutorial Knowledge Graphs
ESWC 2017 Tutorial Knowledge GraphsPeter Haase
 
Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...
Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...
Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...Amazon Web Services
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshellFabien Gandon
 
SPARQL 사용법
SPARQL 사용법SPARQL 사용법
SPARQL 사용법홍수 허
 

What's hot (20)

Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 
Graph & Amazon Neptune: Database Week SF
Graph & Amazon Neptune: Database Week SFGraph & Amazon Neptune: Database Week SF
Graph & Amazon Neptune: Database Week SF
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQL
 
Graph and Amazon Neptune
Graph and Amazon NeptuneGraph and Amazon Neptune
Graph and Amazon Neptune
 
Apache Kylin - Balance Between Space and Time
Apache Kylin - Balance Between Space and TimeApache Kylin - Balance Between Space and Time
Apache Kylin - Balance Between Space and Time
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
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
 
GraphFrames: Graph Queries In Spark SQL
GraphFrames: Graph Queries In Spark SQLGraphFrames: Graph Queries In Spark SQL
GraphFrames: Graph Queries In Spark SQL
 
Convertir Diagrama Entidad-Relacion a Modelo Relacional.
Convertir Diagrama Entidad-Relacion a Modelo Relacional.Convertir Diagrama Entidad-Relacion a Modelo Relacional.
Convertir Diagrama Entidad-Relacion a Modelo Relacional.
 
Using Knowledge Graphs to Predict Customer Needs and Improve Quality
Using Knowledge Graphs to Predict Customer Needs and Improve QualityUsing Knowledge Graphs to Predict Customer Needs and Improve Quality
Using Knowledge Graphs to Predict Customer Needs and Improve Quality
 
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...
 
The Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageThe Gremlin Graph Traversal Language
The Gremlin Graph Traversal Language
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 
Rdf data-model-and-storage
Rdf data-model-and-storageRdf data-model-and-storage
Rdf data-model-and-storage
 
Base de datos itfip ortegon y triana
Base de datos itfip ortegon y trianaBase de datos itfip ortegon y triana
Base de datos itfip ortegon y triana
 
ESWC 2017 Tutorial Knowledge Graphs
ESWC 2017 Tutorial Knowledge GraphsESWC 2017 Tutorial Knowledge Graphs
ESWC 2017 Tutorial Knowledge Graphs
 
Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...
Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...
Connecting the dots - How Amazon Neptune and Graph Databases can transform yo...
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshell
 
SPARQL 사용법
SPARQL 사용법SPARQL 사용법
SPARQL 사용법
 
SHACL by example
SHACL by exampleSHACL by example
SHACL by example
 

Similar to TypeDB Academy | Modelling Principles

Grakn academy | Knowledge Modelling Principles
Grakn academy | Knowledge Modelling PrinciplesGrakn academy | Knowledge Modelling Principles
Grakn academy | Knowledge Modelling PrinciplesDaniel Crowe
 
Assignment structureNote You are asked to analyse an organiza.docx
Assignment structureNote You are asked to analyse an organiza.docxAssignment structureNote You are asked to analyse an organiza.docx
Assignment structureNote You are asked to analyse an organiza.docxssuser562afc1
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsqueenpressman14
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsqueenpressman14
 
. The assignment is to write 2 essays of 2 pages each, for a tot.docx
. The assignment is to write 2 essays of 2 pages each, for a tot.docx. The assignment is to write 2 essays of 2 pages each, for a tot.docx
. The assignment is to write 2 essays of 2 pages each, for a tot.docxhoney725342
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptxsandeep54552
 
GLIT 6757 (PEI) Winter 2012: Seminar 2
GLIT 6757 (PEI) Winter 2012: Seminar 2GLIT 6757 (PEI) Winter 2012: Seminar 2
GLIT 6757 (PEI) Winter 2012: Seminar 2Michele Knobel
 
GLIT mississauga, Seminar 2
GLIT  mississauga, Seminar 2GLIT  mississauga, Seminar 2
GLIT mississauga, Seminar 2Michele Knobel
 
Friday 5th primero medio.pptx
Friday 5th primero medio.pptxFriday 5th primero medio.pptx
Friday 5th primero medio.pptxyari310256
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsqueenpressman14
 
Instructions for all worksMake sure you follow this instruction.docx
Instructions  for all worksMake sure you follow this instruction.docxInstructions  for all worksMake sure you follow this instruction.docx
Instructions for all worksMake sure you follow this instruction.docxnormanibarber20063
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsqueenpressman14
 
Examples A definition essay may try and define ..docx
Examples A definition essay may try and define ..docxExamples A definition essay may try and define ..docx
Examples A definition essay may try and define ..docxelbanglis
 
Podcast Lecture 6What words or phrases are ambiguousWhat ar.docx
Podcast Lecture 6What words or phrases are ambiguousWhat ar.docxPodcast Lecture 6What words or phrases are ambiguousWhat ar.docx
Podcast Lecture 6What words or phrases are ambiguousWhat ar.docxLeilaniPoolsy
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsqueenpressman14
 

Similar to TypeDB Academy | Modelling Principles (20)

Grakn academy | Knowledge Modelling Principles
Grakn academy | Knowledge Modelling PrinciplesGrakn academy | Knowledge Modelling Principles
Grakn academy | Knowledge Modelling Principles
 
Pattern of Paragraph Development
Pattern of Paragraph DevelopmentPattern of Paragraph Development
Pattern of Paragraph Development
 
Mind the Semantic Gap
Mind the Semantic GapMind the Semantic Gap
Mind the Semantic Gap
 
Assignment structureNote You are asked to analyse an organiza.docx
Assignment structureNote You are asked to analyse an organiza.docxAssignment structureNote You are asked to analyse an organiza.docx
Assignment structureNote You are asked to analyse an organiza.docx
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKills
 
chapter 1a.pptx
chapter 1a.pptxchapter 1a.pptx
chapter 1a.pptx
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKills
 
Database design
Database designDatabase design
Database design
 
. The assignment is to write 2 essays of 2 pages each, for a tot.docx
. The assignment is to write 2 essays of 2 pages each, for a tot.docx. The assignment is to write 2 essays of 2 pages each, for a tot.docx
. The assignment is to write 2 essays of 2 pages each, for a tot.docx
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptx
 
GLIT 6757 (PEI) Winter 2012: Seminar 2
GLIT 6757 (PEI) Winter 2012: Seminar 2GLIT 6757 (PEI) Winter 2012: Seminar 2
GLIT 6757 (PEI) Winter 2012: Seminar 2
 
GLIT mississauga, Seminar 2
GLIT  mississauga, Seminar 2GLIT  mississauga, Seminar 2
GLIT mississauga, Seminar 2
 
Friday 5th primero medio.pptx
Friday 5th primero medio.pptxFriday 5th primero medio.pptx
Friday 5th primero medio.pptx
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKills
 
Instructions for all worksMake sure you follow this instruction.docx
Instructions  for all worksMake sure you follow this instruction.docxInstructions  for all worksMake sure you follow this instruction.docx
Instructions for all worksMake sure you follow this instruction.docx
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKills
 
670-11 Analysis of Urban Conversations 675-5
670-11 Analysis of Urban Conversations 675-5670-11 Analysis of Urban Conversations 675-5
670-11 Analysis of Urban Conversations 675-5
 
Examples A definition essay may try and define ..docx
Examples A definition essay may try and define ..docxExamples A definition essay may try and define ..docx
Examples A definition essay may try and define ..docx
 
Podcast Lecture 6What words or phrases are ambiguousWhat ar.docx
Podcast Lecture 6What words or phrases are ambiguousWhat ar.docxPodcast Lecture 6What words or phrases are ambiguousWhat ar.docx
Podcast Lecture 6What words or phrases are ambiguousWhat ar.docx
 
Senior High School Reading and Writing SKills
Senior High School Reading and Writing SKillsSenior High School Reading and Writing SKills
Senior High School Reading and Writing SKills
 

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
 
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
 
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
 
TypeDB Academy | Inference with Rules
TypeDB Academy | Inference with RulesTypeDB Academy | Inference with Rules
TypeDB Academy | Inference with RulesVaticle
 
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
 
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
 

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
 
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
 
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
 
TypeDB Academy | Inference with Rules
TypeDB Academy | Inference with RulesTypeDB Academy | Inference with Rules
TypeDB Academy | Inference with Rules
 
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
 
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
 

Recently uploaded

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Recently uploaded (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

TypeDB Academy | Modelling Principles

  • 1. TypeDB Academy | Modelling Principles
  • 2. Modelling Principles • The modelling philosophy, principles and techniques of TypeDB • Best practices for designing your domain model
  • 3. 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.
  • 4. Domain modeling – best practices Here we set out the best practice guidelines for creating a TypeDB schema. It is possible to create a successful model that does not conform to the guidelines. These guidelines aim to help maximise: • true-to-domain modelling • flexibility • and extensibility
  • 5. Importance of modeling choices We want to carefully choose our data model, that is, choosing what should be an entity, a relation, or an attribute. We want this model to closely reflect the domain. In this way we can know that if new data becomes available in the domain it will fit into the data model. With this schema, when later we find there is information regarding a person’s employment, how can we add it? If the domain is modelled true-to-life, then extra schema (and therefore data) is added trivially. person company document owns employment end-date start-date employee employer owns contract person company employee X ✓
  • 6. Importance of modeling choices Naming and choosing your entities, relations and attributes are two issues that are tied together. The naming should closely link to typical domain terminology, since natural language is the means to describe the domain. Using the expected domain terminology is important, this lets another others working with you to easily: • understand your model • maintain it • extend it • adapt it. Focussing on terminology to determine structure is a typical approach for software architecture in general, not just for TypeDB schema
  • 7. Naming - formatting • naming is in all lower case • use hyphens • indent on newlines after declaring a type e.g. define person sub entity, owns full-name;
  • 8. Naming - Types A type name should: • ideally be a noun (except for attributes) • be singular, the presence of more than one instance lends to plurality • be as context-specific as possible, using the exact word that describes the concept in-context • if you can’t find a noun specific enough then try concatenating two or more nouns by hyphenating them: • these can quickly become verbose, so try and find a balance between specificity and verbosity. define location-hierarchy sub relation, relates subordinate, relates superior;
  • 9. Type names Continued… • if a noun can’t be found, then use a present participle or past-participle of a verb as an adjective, to capture the context. Combine this with a context non- specific noun. • e.g. below we use authored-content, since content would be too generic, and authored-book would be too specific (as it would rule out other types of content): • also consider using prepositions i.e.: to, from, by, of authorship sub relation, relates author, relates authored-content;
  • 10. Let’s iterate on our schema Now that we’ve talked through some of the ways to name things, how would you iterate on your schema? Exercise- 6 minutes individually: 1) Review current naming choices. 2) Where would you make changes – make them. 3) Be prepared so share at least one change you made and why.
  • 11. Modelling decisions – entities “An entity may be defined as a thing capable of an independent existence that can be uniquely identified. An entity is an abstraction from the complexities of a domain. When we speak of an entity, we normally speak of some aspect of the real world that can be distinguished from other aspects of the real world.”
  • 12. Modelling decisions – entities Good choices for entities are: • Any physical thing in the real world should be modelled as an entity (e.g. animal, person, device, building) • Anything that exists logically but doesn’t require involvement of other things in order to exist: organisation, school • Use concrete/proper/common/abstract/collective nouns: • concrete – person, tree, car • proper – homo sapiens (sometimes the attribute name of an instance) • abstract – religion, pain, principle • collective – family, government, team, orchestra, set • To specialise a general noun, use in combination with another noun – social group
  • 13. Modelling decisions – relations It is easy to say for certain that a concept is definitely an entity, e.g. car. It is harder, the more conceptual a thing is, to decide whether it should be an entity or a relation. One way to decipher this, is to start by examining the potential relation as a binary relation – relations that must either have the property or anti-property for each of the following cases Symmetric – relation is the same in both directions Transitive– relation can be chained Reflexive – role-player can be related to itself through the relation
  • 14. Modelling decisions – relations Example An employment relation, that relates employee and employer role-players, is anti- symmetric, anti-transitive, and anti-reflexive. Therefore we can logically call this type a relation. Example Religion as a relation however, is not symmetric or anti-symmetric, transitive or anti- transitive, nor reflexive or anti-reflexive. Therefore we can conclude that a religion, is not binary and either an entity or a ternary/n-ary relation.
  • 15. Modelling decisions – relations In general, relations shouldn’t make sense without their roles. For example, a marriage can’t logically exist without at least one spouse/husband/wife. Ideally, we are looking for the concept that connects two things, not a direct connection (often those are the role names, like employee). • for instance, below we can see that we don’t use “owns” as the type-name, but instead we use the verbal noun of owns: ownership ownership sub relation, relates owner, relates property;
  • 16. Modelling decisions – relations Gather together domain terminology that sounds similar to the concept you want to model. Then determine which are candidate relation, role, and entity names (determining and naming attributes is often not too hard). Remember that a role describes how a thing behaves in the scope of a relation. Examples with role-player my-schema-type, role, relation : • a car behaves like property in an ownership • a station behaves as a stop along a train-route • a person behaves as an employee in an employment
  • 17. Modelling decisions – relations Relation names could describe membership to a grouping/collection of things (component, group-membership), an action/ongoing state (marriage, comparison, authorship, participation), or a description of a direct interrelation between two or more things (friendship, parenthood, association, drug-protein-interaction) group-membership sub relation, relates member, relates group; drug-protein-interaction sub relation, relates inhibitor, relates antagonist relates blocker, relates target-protein;
  • 18. Modelling decisions – relations A relation is defined such that an instance should not be able to exist without relating at least one instance for one of its roles. This is the idea that a relation is dependent upon the existence of one or more role-players. • A relation should still make sense even if any number of it’s role-players are missing • The roles and role-players should make logical sense to be connected in any combination
  • 19. Modelling decisions – relations You should find that you choose names from these categories: • abstract nouns • transitive verbs that can accept 2 or more arguments – decide, agree, marry • their verbal nouns are preferable – decision, agreement, marriage
  • 20. Modelling decisions – roles Nouns, verbs, prepositions location-of sub relation, abstract relates located, relates location; direction sub relation, relates from, relates to; ownership sub relation, relates owner, relates property;
  • 21. Modelling decisions – relations Wherever possible, relations should be named in such a way that the name doesn’t include a ‘reference’ to one of its role-players in particular. Parenthood is an example of a fairly unavoidable case, where the relation naming refers more to the role of parent than the role of child . An example of the ideal case would be: hierarchy sub relation, relates superior, relates subordinate;
  • 22. Let’s iterate on our schema Discussion Looking specifically at your relations, what would you change or what do you imagine needing to put more thought to?
  • 23. Modelling decisions – attributes Usually the easiest to identify, as they are the direct description of a set of values that we want to model. Naming an attribute: • The name of an attribute should refer to a literal value. • Make attributes context-specific – by concatenating words or ending with a noun • Abstract nouns e.g. colour • Adjectives e.g. friendly • Intransitive verbs (no direct objects, can’t be followed by “who” or “what”) e.g. is-raining, graduated
  • 24. Benefits of inheritance – scoping queries Wide scope: get all the posts post status-update sub comment media photo video sub sub sub sub Intermediate scope: get all media match $m isa media; post sub entity, status-update sub post; comment sub post; media sub post; video sub media; photo sub media; match $p isa post; match $c isa comment; Narrow scope: get all comments
  • 25. Benefits of inheritance – constraints person ownership owner owned However, we can see a problem. Based on this schema, a person can own an office and a company can own a social-group. company office social-group owner owned ownership sub relation, relates owner, relates owned; company sub entity, plays ownership:owner; office sub entity, plays ownership:owned; social-group sub entity, plays ownership:owner; person sub entity, plays ownership:owned;
  • 26. Benefits of inheritance – constraints person ownership social-group owned-group group-ownership office-ownership group-owner company office owned-office office-owner owned ownership sub relation, abstract, relates owner, relates owned; office-ownership sub ownership, relates office-owner as owner, relates owned-office as owner; owned
  • 27. Composition vs. inheritance Composition replaces the temptation of multiple inheritance. “Entity type Y is a subtype (subclass) of an entity type X if and only if every Y is necessarily an X” (https:/en.wikipedia.org/wiki/Enhanced_entity%C3%A2%C2%80%C2%93relationship_model) Therefore define customer sub person; is a bad idea, since: • An organisation could be a customer, therefore customer is a behaviour (a role) • A person who plays the role of a customer could play the role of many other things, e.g. teacher Mindset Shift View using roles as composition for behaviours of a concept Try putting names in a context like this: A [relation] has a [role] in the form of a [thing]
  • 28. Ternary and n-ary Relations To help us see the use of ternary relations, consider someone buying a product vendor product owns Start with only binary relations Ternary – since we have 3 role-players in one relation transaction product company person custom er customer purchase sale product company person Where do we add value for the sale? Here, value, can be added trivially value
  • 29. Nested relations vendor product owns Now we can refer to the transaction in other relations. Note that this can be favourable over adding another role to the existing relation. This is better for: • Consistency across schema • Versatility, we can add more information to either of the two relations transaction product company person customer value place located location location-of- transaction
  • 30. Optimisation Schema design impacts query performance. Use context-specific relation and role names, this allows the query planner to find a good path (otherwise all data is homogeneous, it all looks the same).