Skip to main content

Flakes

This lesson will cover the infrastructure of a Fluree ledger, including flakes, blocks, and triples. This background information is extremely helpful for gaining an intuitive understanding of Fluree. This first lesson will focus on flakes.

Before starting this lesson, it is useful to have completed Querying Basics or to have a basic understanding of Fluree and collections and predicates.

Subject-Predicate-Object

Fluree uses a standard structure for data called an RDF triple. Triples are made up of a subject, predicate, and object.

Subject

Every single item in a Fluree ledger is a subject, and whenever a new subject is created, it is automatically assigned a unique, unchangeable numeric id. i.e. 12345.

Predicate

Predicates are features of those subjects. i.e. "Full Name".

Object

Objects are the values of the predicates. i.e. "Jane Doe".

The resulting triple would therefore be: 12345. Full Name. Jane Doe.

That same subject, 12345, might have a lot of different triples:

SubjectPredicateObject
12345Birthday1/30/85
12345Hair ColorRed
12345Fav Nums7
12345Fav Nums28

As you can see above, some of those triples might even have the same predicate, i.e. a person might have more than one favorite number, so they could have two or more triples that list their favorite numbers.

Flakes and a Concept of Time

Because Fluree has a concept of time, we need to extend the standard RDF triple. In Fluree, our triples are actually five-tuples, and we call them flakes. Flakes are assertions of a fact at a given point in time. They are made up of:

  1. Subject
  2. Predicate
  3. Object
  4. Time - the moment at which a fact is asserted.
  5. Operation - true/false - whether we are asserting or retracting a fact.

For example:

SubjectPredicateObjectTimeOperation
12345Hair ColorRed1/1/2019true
12345Birthday1/30/851/1/2019true
12345Fav Nums71/1/2019true
12345Full NameJane Doe1/1/2019true
12345Fav Nums281/1/2019true

So, from January 1, 2019 and onwards, 12345's full name was Jane Doe, hair color was red, birthday was Jan. 30, and favorite numbers were 7 and 28. At any point in the future, Jane might change her hair color to brown and add a new favorite number.

SubjectPredicateObjectTimeOperation
12345Hair ColorRed1/1/2019true
12345Birthday1/30/851/1/2019true
12345Fav Nums71/1/2019true
12345Full NameJane Doe1/1/2019true
12345Fav Nums281/1/2019true
12345Hair ColorRed2/1/2019false
12345Hair ColorBrown2/1/2019true
12345Fav Nums1012/1/2019true

We can see that, as of 2/1/2019, 12345 retracts the statement that her hair is red, and asserts that her hair is brown. Additionally, we will always be able to go back in the database, and see what color Jane's hair was during January.

Notice that when Jane got a new favorite number, we didn't retract any of her old favorite numbers. Between 1/1/2019 and 1/31/2019, Jane's favorite numbers were 7 and 28. From 2/1/2019 on, her favorite numbers were 7, 28, and 101.