diff --git a/docs/presentations/2016/06/21/data/triples.txt b/docs/presentations/2016/06/21/data/triples.txt new file mode 100644 index 00000000..b7f63b6f --- /dev/null +++ b/docs/presentations/2016/06/21/data/triples.txt @@ -0,0 +1,12 @@ +/person "born_in"@[] /city +/person "born_in"@[] /city +/city "belongs_to"@[] /country +/country "located_in"@[] /continent +/city "belongs_to"@[] /country +/country "located_in"@[] /continent +/person "knew"@[] /_ +/_ "_subject"@[] /person +/_ "_predicate"@[] "born_in"@[] +/_ "_object"@[] /city +/city "population"@[1860-04-10T4:21:00.000000000Z] "6000"^^type:int64 +/city "population"@[1869-04-10T4:21:00.000000000Z] "400"^^type:int64 diff --git a/docs/presentations/2016/06/21/images/ogm-property.jpg b/docs/presentations/2016/06/21/images/ogm-property.jpg new file mode 100644 index 00000000..065729d5 Binary files /dev/null and b/docs/presentations/2016/06/21/images/ogm-property.jpg differ diff --git a/docs/presentations/2016/06/21/images/ogm-statement-property-reified.jpg b/docs/presentations/2016/06/21/images/ogm-statement-property-reified.jpg new file mode 100644 index 00000000..d3b46ce1 Binary files /dev/null and b/docs/presentations/2016/06/21/images/ogm-statement-property-reified.jpg differ diff --git a/docs/presentations/2016/06/21/images/ogm-statement-property.jpg b/docs/presentations/2016/06/21/images/ogm-statement-property.jpg new file mode 100644 index 00000000..a14336b3 Binary files /dev/null and b/docs/presentations/2016/06/21/images/ogm-statement-property.jpg differ diff --git a/docs/presentations/2016/06/21/images/ogm-statement.jpg b/docs/presentations/2016/06/21/images/ogm-statement.jpg new file mode 100644 index 00000000..fd1697ce Binary files /dev/null and b/docs/presentations/2016/06/21/images/ogm-statement.jpg differ diff --git a/docs/presentations/2016/06/21/ottawa-graph-meetup.slide b/docs/presentations/2016/06/21/ottawa-graph-meetup.slide new file mode 100644 index 00000000..fa4abb8c --- /dev/null +++ b/docs/presentations/2016/06/21/ottawa-graph-meetup.slide @@ -0,0 +1,400 @@ +The BadWolf Project +Temporal Graph Store +19:00 21 Jun 2016 +Tags: badwolf, graph store + +Xavier LlorĂ  +SWE, Google Inc. +@badwolf_project +@xllora + +* What will be cover today? + +* Quick Overview + +Describing the world using statements + +Statements and how they map to graphs + +Quick Graph manipulation concepts + +Examples and demo + +Road map + +* What is a statement? + +* A simple statement + +A simple example of a statement + + Charles Darwin was born in Shrewsbury + +A statement describes some truth about something + +Deconstructing a statement + +- _Subject_: The main actor on the statement (`Charles` `Darwin`) +- _Predicate_: The verb qualifying the statement (`born` `in`) +- _Object_: What is being predicated (`Shrewsbury`) + +There are two entities (`Charles` `Darwin` and `Shrewsbury`) linked by a verb + +* Another statement + +This is also a simple statement, but with a twist + + Nikola Tesla knew Charles Darwin was born in Shrewsbury + +A possible way of desconstructing the statement + +- _Subject_: `Nikola` `Tesla` +- _Predicate_: `knew` +- _Object_: `Charles` `Darwin` `was` `born` `in` `Shrewsbury` + +You can have entities in a statement, but you can also have other statements + +The above example links an entity with another statement + +* One last statement + +One final statement + + Shrewsbury population 6,000 + +This statement is build using + +- _Subject_: (`Shrewsbury`) +- _Predicate_: A property (`population`) +- _Object_: The value of the property (`6,000`) + +A statement may not define a relation, but describe a _property_ + +The object of properties are primitive data types. Some examples + +- _Text_ +- _Numbers_ +- `...` + +* Statement summary + +Relation expressing statement + +- _Subject_: An entity or another statement +- _Predicate_: A verb +- _Object_: An entity or another statement + +Property expressing statement + +- _Subject_: An entity or another statement +- _Predicate_: A property (verb or property noun) +- _Object_: An entity or another statement + +* Modeling statements with graphs + +* A simple statement + +.image images/ogm-statement.jpg + +* A simple property statement + +.image images/ogm-property.jpg + +* Both together + +.image images/ogm-statement-property.jpg + +* Statements about statements + +.image images/ogm-statement-property-reified.jpg + +* Statements change over time + +* The twist + +Imagine the simple question: + +- Can you model how many pencils you have on your desk? + +You can think of it as property + + I have 10 + +Is this a universal statement? + +- But what about now? +- An hour ago? +- Yesterday? + +* I know the answer + +I can predicate a property about the estament + + I have 10 at 2016/06/21T19:00PST + +And we know how to decompose it + +- _Subject_: `I` `have` `10` +- _Predicate_: `at` +- _Object_: `2016/06/21T19:00PST` + +Yes we can model it, but it seems that it should be easier + +Some facts change over time by nature + +Taking it into account would allow a more intuitive reasoning + +* Meet BadWolf + +* Extending predicate semantics + +- _Immutable_: Predicates that do not change overtime + + Charles Darwin was born in Shrewsbury + +- _Temporal_: Predicates only true a some point in time + + Shrewsbury population 6,000 + +* BadWolf Predicates + +Predicates are defined by an `ID` and a `TIME_ANCHOR` + +- _Immutable_: Predicates that do have `ID` but do not have `TIME_ANCHOR` + + "born_in"@[] + +- _Temporal_: Predicates that have both `ID` and a `TIME_ANCHOR` + + "population"@[1860] + +* BadWolf Entities + +Entiies are defined by a `TYPE` and a `ID` + +`TYPE` is an hierarchical construct + +`ID` is a unique value that identifies the entity + +For convenience, you can write them as follows + + /person + /person + +* BadWolf Literals + +- `bool`: A simple boolean + + "true"^^type:bool + +- `int64`: A 64 bit signed integer + + "-1"^^type:int64 + +- `Float64`: A 64 bit float + + "1.23"^^type:float64 + +- `Text`: An arbitrary UTF-8 text + + "foo bar"^^type:text + +- `Blob`: An arbitrary byte array + + "[ 1 2 3 ]"^^type:blob + +* BadWolf Triples + +A triple is just a subject + predicate + object + +- _Subject_: An entity +- _Predicate_: An immutable or a temporal predicate +- _Object_: Either an entity or a literal or a predicate + +Triples in BadWolf are _immutable_ + +* Remember this graph of statements? + +.image images/ogm-statement-property-reified.jpg + +* Expressing it with BadWolf triples + +Each of the edges in that graph represent a triple. + + /person "born_in"@[] /city + /city "population"@[1860] "6000"^^type:int64 + /person "knew"@[] /_ + /_ "_subject"@[] /person + /_ "_predicate"@[] "born_in"@[] + /_ "_object"@[] /city + +This format also represent how data can be shared + +* How can you manage all these statements? + +BadWolf groups triples into graphs + +Graphs are _mutable_ + +* Managing graphs + +* Graph basic operations + +You can create a graph + + bql> CREATE GRAPH ?g; + +Or you can create several graphs at once + + bql> CREATE GRAPH ?g, ?h; + +You can also get rid of a graph + + bql> DROP GRAPH ?g; + +Or multiples at once + + bql> DROP GRAPH ?g, ?h; + +* Managing data in the graphs + +* Adding triples to a graph + +Once you have a graph, you can add triples to it + + bql> CREATE GRAPH ?scientist, ?cities, ?towns; + + bql> INSERT DATA INTO ?scientist { + /person "born_in"@[] /city . + /person "born_in"@[] /city + }; + + bql> INSERT DATA INTO ?cities, ?towns { + /city "belongs_to"@[] /country . + /country "located_in"@[] /continent . + /city "belongs_to"@[] /country . + /country "located_in"@[] /continent + }; + +* Removing triples form a graph + +You can also remove triples form multiple graphs + + bql> DELETE DATA FROM ?science, ?cities, ?towns { + /person "born_in"@[] /city . + /person "born_in"@[] /city . + /city "belongs_to"@[] /country . + /country "located_in"@[] /continent . + /city "belongs_to"@[] /country . + /country "located_in"@[] /continent + }; + +* Reasoning using queries + +* Variables + +Variables start with `?` + +Variables can appear in any position of a triple + + ?country "located_in"@[] /continent + /country ?predicate /continent + /country "located_in"@[] ?continent + +A variable can be binded to one or multiple values. For instance + + ?country "located_in"@[] /continent + +The variable `?country` in the above example given the triples + + /country "located_in"@[] /continent + /country "located_in"@[] /continent + +Can bind against to values `/country` and `/country`. + +* BQL + +Allows you to express complex declarative queries + +List all the cities you know from Europe + + bql> CREATE GRAPH ?g; + + bql> load data/triples.txt ?g; + + bql> SELECT ?city + FROM ?g + WHERE { + ?city "belongs_to"@[] ?c . + ?c "located_in"@[] /continent + }; + + ?city + /city + /city + +.link https://en.wikipedia.org/wiki/SPARQL Extension of SPARQL + +* BQL + +Population of cities + + bql> SELECT ?city, ?population + FROM ?g + WHERE { + ?city "population"@[,] ?population + }; + + ?city ?population + /city "6000"^^type:int64 + /city "400"^^type:int64 + +* BQL + +What about population of cities before 1865? + + bql> SELECT ?city, ?population + FROM ?g + WHERE { + ?city "population"@[,1865-01-01T0:00:00.000000000Z] ?population + }; + + ?city ?population + /city "6000"^^type:int64 + + +* BQL + +What about population of cities after 1865? + + bql> SELECT ?city, ?population + FROM ?g + WHERE { + ?city "population"@[1865-01-01T0:00:00.000000000Z,] ?population + }; + + ?city ?population + /city "400"^^type:int64 + + +* Demo time + +* Public usages + +* Road map + +* Updates to BQL (high priority) + +.link https://github.com/google/badwolf/issues/45 Create derived statements via BQL `CONSTRUCT` query + +.link https://github.com/google/badwolf/issues/52 Remove derived statements via BQL `DECONSTRUCT` query + +* Low priority (a.k.a. Out of bandwidth) + +Writing storage drivers + +.link https://github.com/xllora/bwdrivers BwDrivers repository contains contributions (e.g. BoltDB) + +Bridging a sister project + +.link https://github.com/google/cayley Cayley as a backend for BadWolf