From 0a33514d7e21140c92b6aef33342c6068508fcba Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Fri, 27 Jan 2017 09:54:11 -0800 Subject: [PATCH] Updated Home (markdown) --- Home.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Home.md b/Home.md index 3ed3e35..86b7b64 100644 --- a/Home.md +++ b/Home.md @@ -2,12 +2,6 @@ Welcome to the Mentat Wiki! At its core, Mentat maintains a set of assertions of the form entity-attribute-value (EAV). The assertions conform to a schema whereby the given attribute constrains the associated value/set of associated values. -## Assertions - -Mentat assertions are represented as rows in the `datoms` SQLite table, and each Mentat row representing an assertion is tagged with a numeric representation of `:db/valueType`. - -The tag is used to limit queries, and therefore is placed carefully in the relevant indices to allow searching numeric longs and doubles quickly. The tag is also used to convert SQLite values to the correct Mentat value type on query egress. - ## Entities and entids A Mentat entity is represented by a *positive* integer. (This agrees with Datomic.) We call such a positive integer an *entid*. @@ -23,6 +17,25 @@ You almost certainly want to add new entities in the `:db.part/user` partition. The entid sequence in a given partition is monotonically increasing, although not necessarily contiguous. That is, it is possible for a specific entid to have never been present in the system, even though its predecessor and successor are present. +## Representation of assertions + +Mentat assertions are represented as rows in the `datoms` SQLite table, and each Mentat row representing an assertion is tagged with a numeric representation of `:db/valueType`. + +The tag is used to limit queries, and therefore is placed carefully in the relevant indices to allow searching numeric longs and doubles quickly. The tag is also used to convert SQLite values to the correct Mentat value type on query egress. + +The value type tag mapping is currently: + +| `:db/valueType` | value type tag | SQLite storage class | examples | +| --- | --- | --- | --- | +| :db.type/ref | 0 | INTEGER | `1234` | +| :db.type/boolean | 1 | INTEGER | `0` (false), `1` (true) +| :db.type/long | 5 | INTEGER | `-4321` | +| :db.type/double | 5 | REAL | `-0.369` | +| :db.type/string | 10 | TEXT | `arbitrary textual data` | +| :db.type/keyword | 13 | TEXT | `:namespaced/keyword` | + +Observe that some Mentat value types share a value type tag: they are differentiated using SQLite's storage class. + ## Representation as SQL tables The authoritative table in the SQL store is the `transactions` table; from its contents, all other tables can be derived. Each assertion in a transaction (see [[Transacting|Transacting]]) is represented as a row in the `transactions` table, which has columns roughly