Skip to content

Commit 8c72ca4

Browse files
mark-terminusdbgitbook-bot
authored andcommitted
GitBook: [#29] No subject
1 parent 161ab98 commit 8c72ca4

File tree

17 files changed

+192
-188
lines changed

17 files changed

+192
-188
lines changed

readme/terminusdb/overview/get-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Install as a [Python client](../../../terminusdb/overview/install/install-python
5050

5151
#### Diagram: TerminusDB and TerminusX install options
5252

53-
![TerminusDB installation options](../../../img/diagrams/terminusdb-install-options.png)
53+
![](../../../img/diagrams/terminusdb-install-options.png)
5454

5555
## Interfaces overview
5656

@@ -64,7 +64,7 @@ The TerminusDB [Command Line Interface](../../../terminusdb/overview/reference/r
6464

6565
### Dashboard
6666

67-
The TerminusX [dashboard](../../../terminusdb/overview/terminusx/get-started/) providing a visual interaface.
67+
The TerminusX [dashboard](../../../terminusdb/overview/terminusx/get-started/) provides a visual interface.
6868

6969
### APIs
7070

@@ -76,7 +76,7 @@ The TerminusDB [web object Query Language](../../../terminusdb/overview/explanat
7676

7777
#### Diagram: TerminusDB interfaces
7878

79-
![TerminusDB interfaces](../../../img/diagrams/terminusdb-interfaces.png)
79+
![](../../../img/diagrams/terminusdb-interfaces.png)
8080

8181
## See also
8282

readme/terminusdb/overview/introduction.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TerminusDB is a powerful, in-memory graph database enabling you to maximize your
1616

1717
#### Diagram: Some key features of TerminusDB
1818

19-
![What is TerminusDB](../../../img/diagrams/terminusdb-what-is-it.png)
19+
![](../../../img/diagrams/terminusdb-what-is-it.png)
2020

2121
## Why choose TerminusDB?
2222

@@ -56,19 +56,19 @@ TerminusDB is highly configurable with powerful features for rapidly and collabo
5656

5757
#### Diagram: Reasons to choose TerminusDB
5858

59-
![Why choose TerminusDB](../../../img/diagrams/terminusdb-why-choose.png)
59+
![](../../../img/diagrams/terminusdb-why-choose.png)
6060

6161
## The TerminusDB Git-like model
6262

6363
TerminusDB has many Git-like features including revision-control and distributed collaboration. Similar to Git, TerminusDB is open source, model-driven, and uses the **Resource Description Framework** ([RDF](../../../terminusdb/overview/resources/glossary/#RDF)) specification for collaboration.
6464

6565
### Delta-encoding
6666

67-
TerminusDB implements an advanced Git-like model, using [delta encoding](../../../terminusdb/overview/resources/glossary) to store append or delta-only changes to graphs. These deltas are stored in succinct [terminusdb-store](https://github.com/terminusdb/terminusdb-store) data structures. The delta encoding approach enables branch, merge, push, pull, clone, time-travel, and other Git-like operations.
67+
TerminusDB implements an advanced Git-like model, using [delta encoding](../../../terminusdb/overview/resources/glossary/) to store append or delta-only changes to graphs. These deltas are stored in succinct [terminusdb-store](https://github.com/terminusdb/terminusdb-store) data structures. The delta encoding approach enables branch, merge, push, pull, clone, time-travel, and other Git-like operations.
6868

6969
#### Diagram: TerminusDB Git-like operations
7070

71-
![TerminusDB Git-like operations](../../../img/diagrams/terminusdb-git-model.png)
71+
![](../../../img/diagrams/terminusdb-git-model.png)
7272

7373
## See also
7474

@@ -78,7 +78,7 @@ Read our [white paper](https://github.com/terminusdb/terminusdb-whitepaper/blob/
7878

7979
### Get started
8080

81-
[Get Started](../../../terminusdb/overview/overviews/get-started/) with an overview of the available [Installation Options](../../../terminusdb/overview/overviews/get-started/#installation-overview) and an overview of the [TerminusDB Interafces](../../../terminusdb/overview/overviews/get-started/#interfaces-overview) and their interconnections.
81+
[Get Started](../../../terminusdb/overview/overviews/get-started/) with an overview of the available [Installation Options](../../../terminusdb/overview/overviews/get-started/#installation-overview) and an overview of the [TerminusDB Interfaces](../../../terminusdb/overview/overviews/get-started/#interfaces-overview) and their interconnections.
8282

8383
### TerminusX
8484

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
# explanations
1+
---
2+
description: A selection of technologies and design concepts explained.
3+
---
4+
5+
# Explanations
26

readme/terminusx-db/explanations/acid.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ Where a schema exists for a TerminusDB database, a transaction will not be compl
3636

3737
### Partial consistency
3838

39-
When [rebasing](../../../terminusx-db/explanations/to-do/), transactions that completed under certain **read-conditions** can be _replayed_ by reordering their commits. Schema consistency is maintained but not under all conditions.
39+
When [rebasing](../../../terminusx-db/explanations/to-do/), transactions that complete under certain **read-conditions** can be _replayed_ by reordering their commits. Schema consistency is maintained but not under all conditions.
4040

4141
## Isolation
4242

4343
The isolation property gives a user the impression of being the sole user of a database. The user experiences no currency or conflicts with other users of the database.
4444

4545
### Read isolation
4646

47-
TerminusDB uses inherent database [immutability](../../../terminusx-db/explanations/to-do/) to ensure each read query exists at a given [layer](../../../terminusx-db/explanations/to-do/) providing each user an isolated snapshot of the database.
47+
TerminusDB uses inherent database [immutability](../../../terminusx-db/explanations/to-do/) to ensure each read query exists at a given [layer](../../../terminusx-db/explanations/to-do/) providing each user with an isolated snapshot of the database.
4848

4949
### Write isolation
5050

readme/terminusx-db/explanations/datalog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ When we search using datalog in WOQL, we implicitly ask for _all_ solutions (thi
3838

3939
Perhaps the most important predicate in WOQL is `triple` which gives results about edges in the current graph.
4040

41-
Our logical variables are represented as strings with the prefix `"v:"`. Our edges are represented by having a position for the _subject_, _predicate_ and _object_ of the edge in the graph. The _predicate_ being the labeled name of the edge, and the _subject_ and _object_ nodes the source, and target respectively.
41+
Our logical variables are represented as strings with the prefix `"v:"`. Our edges are represented by having a position for the _subject_, _predicate_ and _object_ of the edge in the graph. The _predicate_ is the labeled name of the edge, and the _subject_ and _object_ nodes the source, and target respectively.
4242

4343
```javascript
4444
triple("v:Subject", "v:Predicate", "v:Object")

readme/terminusx-db/explanations/graphs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ A repository is addressed by specifying its organization and name. For example,
5353

5454
The identifier `local` is used for specifying local repositories, for example, `admin/foo/local`.
5555

56-
A local repository in the repository instance data has **layer identifiers** which point to associated commit graphs.
56+
A local repository in the repository instance data has **layer identifiers** that point to associated commit graphs.
5757

5858
### Remote repositories
5959

readme/terminusx-db/explanations/woql.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ and(
111111

112112
## WOQL and JSON-LD
113113

114-
WOQL uses JSON-LD and a formally specified [ontology](../../../terminusx-db/explanations/glossary) to define the language and transmit queries.
114+
WOQL uses JSON-LD and a formally specified [ontology](../../../terminusx-db/explanations/glossary/) to define the language and transmit queries.
115115

116116
JSON-LD is sometimes tedious for us to read and write. Therefore, WOQL.js is designed to be as easy as possible for developers to write. All WOQL.js queries are translated into the equivalent JSON-LD format for transmission over networks.
117117

@@ -146,7 +146,7 @@ WOQL allows variables or constants to be substituted for any argument to all its
146146

147147
### Unification
148148

149-
WOQL uses the formal-logical approach to variables known as [unification](../../../terminusx-db/explanations/glossary) borrowed from the Prolog engine that implements WOQL within TerminusDB.
149+
WOQL uses the formal-logical approach to variables known as [unification](../../../terminusx-db/explanations/glossary/) borrowed from the Prolog engine that implements WOQL within TerminusDB.
150150

151151
#### Unification in variables
152152

@@ -175,7 +175,7 @@ triple('v:a', 'v:b', 'v:c')
175175

176176
## WOQL prefixes
177177

178-
Internally, TerminusDB uses strict [RDF](../../../terminusx-db/explanations/glossary) rules to represent all data. This means all identifiers and properties are represented by [IRIs](../../../terminusx-db/explanations/glossary) (a superset of URLs.)
178+
Internally, TerminusDB uses strict [RDF](../../../terminusx-db/explanations/glossary/) rules to represent all data. This means all identifiers and properties are represented by [IRIs](../../../terminusx-db/explanations/glossary/) (a superset of URLs.)
179179

180180
### Shorthand prefixes
181181

@@ -201,7 +201,7 @@ WOQL goes a step beyond supporting prefixes by automatically applying prefixes w
201201
* `subClassOf`
202202
* `domain`
203203
* `range`
204-
* Otherwise if no prefix is applied a string is assumed.
204+
* Otherwise, if no prefix is applied a string is assumed.
205205

206206
## See also
207207

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
# how-to-guides
1+
---
2+
description: How-to guides for performing various operations in TerminusDB.
3+
---
4+
5+
# How-to Guides
26

Original file line numberDiff line numberDiff line change
@@ -1,102 +1,96 @@
1-
# How to Find an Object State
2-
3-
> **On this page:** A how-to guide to find an object state at a given time in Python.
4-
5-
## Steps
6-
7-
[Step 1. Connect to a database](#step-1-connect-to-a-server)
8-
9-
[Step 2. Get the intial commit](#step-2-get-the-initial-commit)
10-
11-
[Step 3. Get the subsequent commit](#step-3-get-the-subsequent-commit)
12-
13-
[Step 4. Get the commit identifier](#step-4-get-the-commit-identifier)
14-
15-
[Step 5. Get the commit object state](#step-5-get-the-commit-object)
16-
17-
### Step 1. Connect to a database
18-
19-
<!-- doc-issue
20-
Connect to a server
21-
Given you have a database, (try downloading Seshat from TerminusdbHub) you can find the object state at a time in the following way: -->
22-
23-
Connect to an existing database with multiple commit activity. Refer to the [Create a simple database](/how-to/how-to-create-simple-database) How-to guide for creating a database containing multiple commits if required.
24-
25-
#### Code: Connect to an existing database
26-
27-
```python
28-
import os
29-
import time
30-
import datetime
31-
from terminusdb_client import WOQLClient
32-
from terminusdb_client import WOQLQuery as WOQL
33-
34-
server_url = "https://127.0.0.1:6363"
35-
db = "seshat"
36-
user = "admin"
37-
account = "admin"
38-
key = "root"
39-
client = WOQLClient(server_url)
40-
41-
client.connect(user=user, account=account, key=key, db=db)
42-
```
43-
44-
### Step 2. Get the initial commit
45-
46-
Get the `timestamp` of the last commit **before** the date specified in `date_string`, using the `timetuple()` method.
47-
48-
#### Code: Get the timestamp of a commit
49-
50-
```python
51-
date_string = "14/10/2020"
52-
timestamp = time.mktime(datetime.datetime.strptime(date_string, "%d/%m/%Y").timetuple())
53-
```
54-
55-
### Step 3. Get the subsequent commit
56-
57-
Get the **next** commit after the `timestamp` retrieved in [step 2](#step-2-get-the-initial-commit) and store commit data in `commit_query`.
58-
59-
#### Code: Get the details of the subsequent commit
60-
61-
```python
62-
commit_query = WOQL().using("admin/seshat/local/_commits",
63-
WOQL().limit(1,
64-
WOQL.woql_and(
65-
WOQL().triple("v:Branch", "ref:branch_name", "v2"),
66-
WOQL().triple("v:Branch", "ref:ref_commit", " v:Head"),
67-
WOQL().path("v:Head", "ref:commit_parent+", "v:Tail", "v:Path"),
68-
WOQL().triple("v:Tail", "ref:commit_id", "v:TailID"),
69-
WOQL().triple("v:Tail", "ref:commit_timestamp", "v:TimeStamp"),
70-
WOQL().greater(timestamp, "v:TimeStamp"),
71-
)))
72-
```
73-
74-
### Step 4. Get the commit identifier
75-
76-
Get the commit identifier into variable `commit_id` after running the `commit_query` defined in [step 3](#step-3-get-the-subsequent-commit).
77-
78-
<!-- docs-issue: Is TailID the same as the commit_id? -->
79-
80-
#### Code: Get the commit id
81-
82-
```python
83-
results = client.query(commit_query)
84-
commit_id = results['bindings'][0]['TailID']['@value']
85-
```
86-
87-
### Step 5. Get the commit object state
88-
89-
Get the commit object associated with the `commit_id` obtained in [step 4](#get-the-commit-identifier). Note the full `path` of the `commit_id`.
90-
91-
#### Code: Get the commit object state
92-
93-
```python
94-
path = f"admin/seshat/local/commit/{commit_id}"
95-
96-
object_query = WOQL().using(path,
97-
WOQL().read_object("terminusdb:///data/afghazn", "v:Document"))
98-
99-
results = client.query(object_query)
100-
101-
print(results)
102-
```
1+
# Find an Object State
2+
3+
> **On this page:** A how-to guide to find an object state at a given time in Python.
4+
5+
## Steps
6+
7+
[Step 1. Connect to a database](find-object-state.md#step-1-connect-to-a-server)
8+
9+
[Step 2. Get the initial commit](find-object-state.md#step-2-get-the-initial-commit)
10+
11+
[Step 3. Get the subsequent commit](find-object-state.md#step-3-get-the-subsequent-commit)
12+
13+
[Step 4. Get the commit identifier](find-object-state.md#step-4-get-the-commit-identifier)
14+
15+
[Step 5. Get the commit object state](find-object-state.md#step-5-get-the-commit-object)
16+
17+
### Step 1. Connect to a database
18+
19+
Connect to an existing database with multiple commit activities. Refer to the [Create a simple database](../../../how-to/how-to-create-simple-database/) How-to guide for creating a database containing multiple commits if required.
20+
21+
#### Code: Connect to an existing database
22+
23+
```python
24+
import os
25+
import time
26+
import datetime
27+
from terminusdb_client import WOQLClient
28+
from terminusdb_client import WOQLQuery as WOQL
29+
30+
server_url = "https://127.0.0.1:6363"
31+
db = "seshat"
32+
user = "admin"
33+
account = "admin"
34+
key = "root"
35+
client = WOQLClient(server_url)
36+
37+
client.connect(user=user, account=account, key=key, db=db)
38+
```
39+
40+
### Step 2. Get the initial commit
41+
42+
Get the `timestamp` of the last commit **before** the date specified in `date_string`, using the `timetuple()` method.
43+
44+
#### Code: Get the timestamp of a commit
45+
46+
```python
47+
date_string = "14/10/2020"
48+
timestamp = time.mktime(datetime.datetime.strptime(date_string, "%d/%m/%Y").timetuple())
49+
```
50+
51+
### Step 3. Get the subsequent commit
52+
53+
Get the **next** commit after the `timestamp` retrieved in [step 2](find-object-state.md#step-2-get-the-initial-commit) and store commit data in `commit_query`.
54+
55+
#### Code: Get the details of the subsequent commit
56+
57+
```python
58+
commit_query = WOQL().using("admin/seshat/local/_commits",
59+
WOQL().limit(1,
60+
WOQL.woql_and(
61+
WOQL().triple("v:Branch", "ref:branch_name", "v2"),
62+
WOQL().triple("v:Branch", "ref:ref_commit", " v:Head"),
63+
WOQL().path("v:Head", "ref:commit_parent+", "v:Tail", "v:Path"),
64+
WOQL().triple("v:Tail", "ref:commit_id", "v:TailID"),
65+
WOQL().triple("v:Tail", "ref:commit_timestamp", "v:TimeStamp"),
66+
WOQL().greater(timestamp, "v:TimeStamp"),
67+
)))
68+
```
69+
70+
### Step 4. Get the commit identifier
71+
72+
Get the commit identifier into variable `commit_id` after running the `commit_query` defined in [step 3](find-object-state.md#step-3-get-the-subsequent-commit).
73+
74+
#### Code: Get the commit id
75+
76+
```python
77+
results = client.query(commit_query)
78+
commit_id = results['bindings'][0]['TailID']['@value']
79+
```
80+
81+
### Step 5. Get the commit object state
82+
83+
Get the commit object associated with the `commit_id` obtained in [step 4](find-object-state.md#get-the-commit-identifier). Note the full `path` of the `commit_id`.
84+
85+
#### Code: Get the commit object state
86+
87+
```python
88+
path = f"admin/seshat/local/commit/{commit_id}"
89+
90+
object_query = WOQL().using(path,
91+
WOQL().read_object("terminusdb:///data/afghazn", "v:Document"))
92+
93+
results = client.query(object_query)
94+
95+
print(results)
96+
```

0 commit comments

Comments
 (0)