All Projects → wotbrew → relic

wotbrew / relic

Licence: MIT License
Functional relational programming for Clojure(Script).

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to relic

vulcan
A JavaScript propositional logic and resolution library
Stars: ✭ 56 (-51.72%)
Mutual labels:  logic
hsdatalog
BDD-based implementation of Datalog
Stars: ✭ 30 (-74.14%)
Mutual labels:  relational-algebra
dataflow-fsi-example
Using Google Cloud, this project is an example of how to detect anomalies in financial, technical indicators by modeling their expected distribution and thus inform when the Relative Strength Indicator (RSI) is unreliable.
Stars: ✭ 26 (-77.59%)
Mutual labels:  dataflow
PothosComms
Communications blocks and support libraries
Stars: ✭ 15 (-87.07%)
Mutual labels:  dataflow
pyroclastic
Functional dataflow through composable computations
Stars: ✭ 17 (-85.34%)
Mutual labels:  dataflow
DFiant
DFiant: A Dataflow Hardware Descripition Language
Stars: ✭ 21 (-81.9%)
Mutual labels:  dataflow
Ejercicios-Practicos
Mejora tu lógica de programación y aprende mucho más resolviendo estos ejercicios.
Stars: ✭ 316 (+172.41%)
Mutual labels:  logic
Tesseract
A set of libraries for rapidly developing Pipeline driven micro/macroservices.
Stars: ✭ 20 (-82.76%)
Mutual labels:  dataflow
auto-data-tokenize
Identify and tokenize sensitive data automatically using Cloud DLP and Dataflow
Stars: ✭ 21 (-81.9%)
Mutual labels:  dataflow
VIATRA-Generator
An efficient graph solver for generating well-formed models
Stars: ✭ 21 (-81.9%)
Mutual labels:  logic
dspatch
The Refreshingly Simple Cross-Platform C++ Dataflow / Pipelining / Stream Processing / Reactive Programming Framework
Stars: ✭ 124 (+6.9%)
Mutual labels:  dataflow
antares
Digital circuit learning platform
Stars: ✭ 15 (-87.07%)
Mutual labels:  logic
end-to-end-machine-learning-with-google-cloud
End to End Machine Learning with Google Cloud Platform
Stars: ✭ 39 (-66.38%)
Mutual labels:  dataflow
redis-dataflow-realtime-analytics
Build a real-time website analytics dashboard on GCP using Dataflow, Cloud Memorystore (Redis) and Spring Boot
Stars: ✭ 20 (-82.76%)
Mutual labels:  dataflow
dataflow-bundle
Data processing framework inspired by PortPHP
Stars: ✭ 13 (-88.79%)
Mutual labels:  dataflow
PothosDemos
Pothos demonstration applications
Stars: ✭ 24 (-79.31%)
Mutual labels:  dataflow
cocoon-demo
Cocoon – a flow-based workflow automation, data mining and visual analytics tool.
Stars: ✭ 19 (-83.62%)
Mutual labels:  dataflow
pireal
Relational Algebra Interpreter writting in Python and Qt
Stars: ✭ 31 (-73.28%)
Mutual labels:  relational-algebra
LPL
📚Solutions to Language, Proof and Logic (2nd Edition)
Stars: ✭ 21 (-81.9%)
Mutual labels:  logic
kibana graph
Interactive Network Graph Visualization For Kibana (unmaintained)
Stars: ✭ 38 (-67.24%)
Mutual labels:  relations

relic

tests Clojars Project

status: alpha, major breaking changes unlikely, minor ones likely

relic is a Clojure(Script) data structure that provides the functional relational programming model described by the tar pit paper.

Why

The relational view (or model) of data ... appears to be superior in several respects to the graph or network model .... It provides a means of describing data with its natural structure only-that is, without superimposing any additional structure for machine representation purposes - Codd, A Relational Model of Data for Large Shared Data Banks

Support for relational data representation

Programming with maps becomes less ergonomic as soon as you have to deal with more than one collection of them at a time, so often they are over structured into trees that limit their use in different contexts.

Normalized relations are a more principled way to represent our collections of maps. There are some tools for working with relations in clojure.set, and they help.

But clojure.set has little to say about how groups of relations should be represented, and indexes are either created for each join, or not used at all.

Declarative data processing

Data processing pipelines could be defined as queries, a specification of the result rather than the steps - but you need mechanisms that can do this efficiently, particularly for partial updates.

Declarative relational constraints

It is often important to rule out invalid states, there are many tools for doing this to single maps or collections, but specifying constraints that exist in the space of relationships is often on the programmer to do manually.

It'd be nice to have a constraint language which was more like a query.

Reactive programming

In interactive applications, the system must respond to user input. You have the problem of invalidation - that is, how do you make sure dependent computations are re-run in response to the state of the program changing. re-frame does this with its subscriptions, but getting good performance if you have to invalidate say, an aggregate - is difficult and on you.

Reducing accidental complexity

relic is trying to reduce complexity, an experiment that allows you to program with normalized data, declarative query, constraints and data processing, and retain good-enough performance.

Features

  • Fully featured in-memory database with indexed SQL style query.
  • Integrated and embedded in clojure, use clojure functions in queries, build queries with clojure.
  • Materialized views with incremental maintenance.
  • Make invalid states illegal with constraints.
  • Reactive, allowing efficient integration with react, bind components to materialized queries and remain responsive at 60fps.

relic only targets in-memory use cases, for this kind of thing at scale consider: materialize.

Installation

With leiningen

[com.wotbrew/relic "0.1.5"]

With clojure (deps.edn)

com.wotbrew/relic {:mvn/version "0.1.5"}

Documentation

See documentation for a detailed reference.

Pitch

Do you suffer from map fatigue? [1]

despair

Did you try meander, core.logic, datascript and every graph-map-database under the sun but still do not feel out of the tar pit?

in the tar pit

Are you tired of writing mechanical wiring and glue? That has nothing to do with your actual business logic?

relic might help, but it's not a medical professional. It's a functional relational programming library.

Definitely not at all like the other in-memory databases in clojure. This time it is different, really.

Brief tour

I like to use rel as an alias.

(require '[com.wotbrew.relic :as rel])

This is a query, lets find some bob's.

 [[:from :Customer]
  [:where [= :name "bob"]]]

You can refine queries by just adding elements to the vector. All your favorites are here, filtering (:where), computing columns (:extend), joins (:join & :left-join), grouping and aggregation (:agg) and more.

[[:from :Customer]
 [:where [= :name "bob"]]
 [:extend [:greeting [str "Hello, " :name "!"]]]

Because queries are just vectors, they just sort of lounge around being values. To put them to work we have to feed some data into relic.

relic databases are boring clojure maps. Prepare yourself:

(def db {})

See, boring.

You manipulate your database with the transact function. This returns a new database with the transaction applied. Plain old functional programming, no surprises.

(def db (rel/transact {} [:insert :Customer {:name "bob"} {:name "alice"}])

db 
;; =>
{:Customer #{{:name "bob"}, {:name "alice"}}}

Now we have some state, we can ask questions of relic, as you would a SQL database.

(rel/q db :Customer)
;; => 
({:name "bob"}, {:name "alice"})

(rel/q db [[:from :Customer] [:where [= :name "bob"]]]) 
;; => 
({:name "bob"})

(rel/q db [[:from :Customer] [:agg [] [:avg-name-len [rel/avg [count :name]]]]])
;; => 
({:avg-name-len 4})

Ok ok, neat but not cool.

Ahhhh... but you don't understand, relic doesn't just evaluate queries like some kind of cave man technology - it is powered by a data flow graph. relic knows when your data changes, and it knows how to modify dependent relations in a smart way.

You can materialize any query such that it will be maintained for you as you modify the database. In other words relic has incremental materialized views.

(rel/mat db [[:from :Customer] [:where [= :name "bob"]]])
;; => returns the database, its value will be the same, but internally some machinery will have been allocated.
{:Customer #{{:name "bob"}, {:name "alice"}}}

mat will return a new database, against which materialized queries will be instant, and as you change data in tables, those changes will flow to materialized queries automatically.

You can do more than query and materialize with relic, you can react to changes, use constraints and more.

If you read the tarpit paper, you might find this real estate example informative.

Another example demonstrating usage in the browser can be found in cljidle.

For further reading, see the docs.

Related libraries

Thanks

LETS GO

lets go

#relic on clojurians

Email and raise issues. PR welcome, ideas and discussion encouraged.

License

Copyright 2022 Dan Stone (wotbrew)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].