Note: This is my own interpretation based on self-study of the lecture slides. While I’ve tried to be accurate, some of my commentary and understanding may be imperfect.
Data Graph
Data graph is the foundation of any knowledge graph. Its key property includes:
- intuitive abstractions to capture entities and their relationship
- do not require schema to start adding data $\to$ flexibility to assemble data from multiple sources
- enable queries over paths of arbitrary length
- potential to correspond with logical unary and binary predicates.
The exemplary data graphs are directed edge-labelled (multi)graphs, property graphs, heterogeneous graphs (heterogeneous information within a node), hypergraphs (edges connecting a set of nodes), hypermodes (nested graphs in a node). Among these, the first two data graphs will commonly appear in this lecture.
Directed Edge-Labelled (Multi)Graphs
As seen from the figure above,
- $(Ernesto,Person) \neq (Person, Ernesto),$ which makes the graph “directed.”
- $(Ernesto,Person) \in E$ is labeled as “teaches,” which makes the graph “edge-labelled”
Property Graph
A property graph is a graph such that for each information belongs to node, relationship, or property, where
- node: tagged with one or more labels and can store any number of properties
- relationship: directed, named connections between two nodes.
- property: key-value pair that provides an attribute (keys are strig, values can be any type)
For instance, in the figure above, Ernesto is a node and {type: Person} is a property of Ernesto, as it gives additional information that Ernesto is a person.
RDF
Resource Description Framework A standardised data model based on the directed edge-labelled graph model $\to$ facilitate data merging even when underlying schema differ.
($c.f.$. web page is based on vision/audio that “people” need to understand information, RDF is based on framework that “computer program” can search/retrieve/analyse information.)
RDF Graph
RDF graph is a collection of triples (subject, predicate, object) which are also called as statement or fact, and the relationship between subject, predicate, and object follows typical English grammar and we usually denote the relationship as (subject) $\to$ (object) and use predicate to label the edge $\to.$
The right-side is the simple visualisation of the three triples in the left-side. Notice that Charles III is object in the triple (England, has king, Charles III) and the subject in the triple (CharlesIII, born year, 1948). It is not a problem at all, and this kind of situation frequently happens.
While subject and object are nodes of the graph, node can be of 3 different types:
- resource with unique identifiers (Internationalised/Uniform Resource Identifier): a concept that people/user/program want to describe. Unlike a blank node, it has a unique identifier.
- literal: a value of certain type such as string, number, date
- blank node: a resource without unique identifier (anonymous)
Resource Identifier
We can use both Uniform Resource Identifier (URI) and International Resource Identifier (IRI) to identify our resource.
URI
URI is a string of characters that identify particular resource, following the predefined set of syntax rules.
URI generally follows the structure:
scheme:\[//authority\]path\[?query\]\[#fragment\](in brackets optional elements)
- scheme: tells how to access the resource
- authority: host of the resource. usually domain
- path: specific resource in the host that the web client wants to access
- query: string of information that the resource can use for some purpose
- fragment: a subpart of a retrieved resource
Also, URI can be either hierarchical or opaque.
While a hierarchical URI is highly human-readable (by looking at URI, you can infer that Luke work for JediDepartment in mycompany), opaque URI does not give context to infer a relationship. Still, using an opaque URI is good for privacy and less stress for upkeep. Consider a case where Luke transferred to other department. Then, if we are using hierarchical URI, we should update the URI so that other people are not mislead; however, there is no need to do such a thing for the opaque URI.
Still, there is a problem that is likely to arise for both type of URI, which is potentiality of URI being too long. When URI is long, it becomes hard to read and write, and thus cause problem. To resolve this issue we use abbreviation.
The most common way to abbreviate URIs is by defining a prefix:
@prefix PREFIX_NAME: <BASE_URI/>
This means that we will replace @prefix dbr: <http://dbpedia.org/resource/>, we can now write http://dbpedia.org/resource/London $\to$ dbr:London. This shortened format is called a CURI (Compact URI) or QName (Qualified Name).
URL VS URI VS IRI
While URL, URI, and IRI seems similar, there are differences between them.
- URL vs URI: URL $\subset$ URI such that URL must include scheme.
- URI vs IRI: URI uses ASCII and IRI uses character from Universal Character Set that allows foreign language character.
Literal
Literals are used to represent data values, and it can only appear in object position of a triple. This is beause literals are just values.
A literal in RDF can be of three types:
- lexical form: simply saying a string type. always inside quotation (e.g. “London”)
- datatype IRI: specific IRI to indicate data type (e.g. ^^xsd:integer)
- language tag: a two or three character code indicating language based on BCP 47 specification (e.g. “en”)
Examples:
-
dbr: London dbo:population "9,304,000"^^xsd:integer$\Longleftrightarrow$ London’s population is 9,304,000. -
dbr: London rdfs:label "Londres"@es$\Longleftrightarrow$ London is called Londres in Spanish.
Blank Nodes
Blank nodes are resources with URI. Since there is no identifier, there is no way to refer them outside of the context that they are originally introduced. Blank nodes can appear in graph for multiple reasons such as
- when we want to represent structured information
- there is a lack of information about the resource
- the node isn’t important enough to warrant a URI.
Also, blank node can appear in subject and object of triples; however, it cannot appear as predicate position because it will be “too meaningless” and confusing.
Let _:b1 represent the blank node. In the figure above, there are four triples total where _:b1 appears as the object once and as the subject three times:
- (dbr:City_UoL, dbo:address, _:b1)
- (_:b1, dbo:street, “Northampton Square”)
- (_:b1, dbo:place, “London”)
- (_:b1, dbo:postcode, “EC1V OHB”)
What we know about _:b1 | What we do not know about _:b1 |
|---|---|
| It is a resource/object in the RDF graph. | We don’t know URI |
It is the dbo:address of dbr:City_UoL. | We cannot reference it outside the graph. |
| It has properties: street, place, postcode. | We cannot tell if it is the same as a node in another graph. |
It holds values like "London" and a postcode. | We don’t know its real identity or name. |
| It exists only within the current RDF graph. | We don’t know if it represents a unique real-world resource. |
RDF Dataset
RDF dataset is a collection of RDF graphs with
- exactly one default graph
- one or more named graphs (used to group multiple disconnected graphs)
RDF vs Property Graph
The basic differences are:
- property graph model supports edge properties.
- property graph model does not require IRI
- property graph model does not support blank nodes.
Things to Add
- representing
dbr: London dbo:population "9,304,000"^^xsd:integerand `dbr: London rdfs:label “Londres”@es in the graph. - ways to represent property graph through RDF
- reification