Knowledge Graph Modeling: Facet Names + Values micro-pattern using gist

July 13, 2020 | 3 minute read
Michael J. Sullivan
Principal Cloud Solutions Architect
Text Size 100%:

This is the sixth in a series of blogs describing how one would go about modeling an enterprise ontology.

In my last post I showed how one would create an informal taxonomy using the gist upper-level ontology. To keep the previous blog from becoming hideously complex, I chose to not document any facets there. However, facets are something that are clearly needed if your informal taxonomy is to have any value in the real-world. 

To that end, I am building upon the previous informal taxonomy micro-pattern by demonstrating the recommended use of facets which is intended to dovetail at each category bucket. Note that typically any item node would have more than one facet (e.g. :Laptop123 would likely have CPU, Screen Resolution, Weight, and Battery Life as facets just to name a few). To this end, I am leveraging blank nodes* in order to place enumerated name + value pairs for each facet edge. Also note that I'm using a more specific variant of gist:Category below (i.e. gist:ProductCategory) which may or may not be appropriate for your project – replace as needed.

THE ABOVE IN TURTLE FORMAT:


@prefix ex1:  <https://data.example.com/> . 
@prefix cat:  <https://taxa.example.com/> . 
@prefix gist: <https://semantic-arts.com/gist/> . 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 

{
  gist:ProductCategory rdfs:subClassOf gist:Category .  
  ex1:Laptop123 a  cat:Product .   
  ex1:Laptop456 a  cat:Product .  
  cat:Laptop    a  gist:ProductCategory .  
  ex1:Laptop123 gist:categorizedBy cat:Laptop . 
  ex1:Laptop456 gist:categorizedBy cat:Laptop . 
}

# facet name + value pairs added to items via blank nodes
ex1:Laptop123 cat:hasFacetAndValue 
  [ cat:hasFacet cat:CPU ;       cat:hasValue "Intel I7" ] ,
  [ cat:hasFacet cat:ScreenRes ; cat:hasValue "1920 x 1080” ] ,
  [ cat:hasFacet cat:Weight ;    cat:hasValue "< 3 lbs" ] ,
  [ cat:hasFacet cat:BattLife ;  cat:hasValue "> 7 hrs" ] .

ex1:Laptop456 cat:hasFacetAndValue 
  [ cat:hasFacet cat:CPU ;       cat:hasValue "Intel I7" ] ,
  [ cat:hasFacet cat:ScreenRes ; cat:hasValue "2400 x 2000” ] ,
  [ cat:hasFacet cat:Weight ;    cat:hasValue "< 4 lbs" ] ,
  [ cat:hasFacet cat:BattLife ;  cat:hasValue "> 5 hrs" ] .

While there are simpler ways of modeling item attributes, modeled in this manner and using SPARQL code such as the following snippet, the front-end developer doesn't need to know á priori what facets any category bucket might have. This makes it easy to build a faceted search or configurator as you can fetch all the enumerated facet values in one go using the same code for each category. All of this is done in order to keep the front-end code both simple and less brittle. And it frees up the content creators/taxonomists to add addition facets as needed without doing a lot of code refactoring.

REUSABLE SPARQL QUERY TO FETCH A COMPLETE SET OF FACETS PER ANY CATEGORY:

# where cat:laptop is a variable representing the current category bucket
SELECT ?facet ?value {
  ?item gist:categorizedBy cat:Laptop ;
        cat:hasFacetAndValue ?blanknode .
  ?blanknode cat:hasFacet ?facet ;
             cat:hasValue ?value .
}

What could be simpler? The above query will return all the facet name + value pairs from any category as modeled above. 

NEXT UP: Formal Taxonomies

RELATED LINKS:

  1. https://www.ateam-oracle.com/knowledge-graph-modeling-governance-project-scope
  2. https://www.ateam-oracle.com/knowledge-graph-modeling-introduction-to-gist-and-buckets
  3. https://www.ateam-oracle.com/knowledge-graph-modeling-group-micro-pattern-using-gist
  4. https://www.ateam-oracle.com/knowledge-graph-modeling-product-category-micro-pattern-using-gist
  5. https://www.ateam-oracle.com/knowledge-graph-modeling-informal-taxonomy-micro-pattern-using-gist
  6. https://www.ateam-oracle.com/knowledge-graph-modeling-facet-names-values-micro-pattern-using-gist
  7. https://www.ateam-oracle.com/knowledge-graph-modeling-formal-taxonomy-micro-pattern-using-gist

END NOTES:

* see: https://en.wikipedia.org/wiki/Blank_node

** see: https://www.w3.org/TR/sparql11-property-paths/

Michael J. Sullivan

Principal Cloud Solutions Architect


Previous Post

Knowledge Graph Modeling: Informal Taxonomy micro-pattern using gist

Michael J. Sullivan | 3 min read

Next Post


How to setup SSSD on OID12c or OUD12c in OCI

Tim Melander | 10 min read