Benjamin-Philip

Benjamin-Philip

Introduction

Ash seems to be great with regular relational data. However when I tried it out for a hobby project, where I had to represent a hierarchy of arbitrary depth, I noticed there isn’t any support for graphs or any other non relational data. I propose that data layers for some NoSQL DBs/Postgres Extension be created.

Now, I firmly believe that 90% of modern requirements can be met with a regular RDBMS. It take a very significant load and a number of optimizations elsewhere in the stack before your database becomes a bottleneck. However, there are cases where you genuinely need more than vanilla postgres or even a specialized DB. As such, my approach would be to have as little information outside of standard postgres as possible, while also limiting the number of extra services my app depends on.

Postgres and friends

One approach to enforce this principle is to stick to postgres extensions like Apache AGE (for graphs), TimescaleDB (for time-series) and JSONB (for documents). Since we are only extending the functionality of our primary database, there are 2 main of advantages:

  • No consistency problems/data duplication between DBs (since there’s only one DB)
  • Simplified deployment and reduced footprint (since there’s only one service)

However, this raises the important question: do MySQL and SQLite become second class citizens compared to Postgres in Ash? It’s possible that MySQL has equivalents for all these extensions, and we can support these features on top of AshPostgres and AshMySQL.

NoSQL DBs

The disadvantage with Postgres Extensions is that they may or may not be as performant as specialized solutions. Additionally they tend to have a smaller user base than specialized solutions. Supporting NoSQL DBs though, is a difficult task:

  • How do we decide how much data to duplicate between DBs?
  • How do we ensure consistency?
  • When does an implementation become too opinionated and actively hinder the user when he steps off the beaten path?
  • Are Postgres, MySQL and SQLite even replaceable (as they are now) when used with conjunction with a NoSQL DB?

I personally think that integrating additional databases is a problem best solved on a case-by-case basis. I don’t even think Ash trying to solve for the scale and the unique cases that demand a NoSQL database is even right thing to do, since the vast majority of Ash’s users don’t and will not operate at that scale.

Further Steps

The main question to answer is if we want to go with supporting the database extensions, or the NoSQL DBs or both and we fill in the details after that.

If we were to go with just Postgres, the order I would implement these would be:

  1. jsonb (already supported) → Document DB
  2. timescaledb (since it’s essentially a regular table, but optimized for time) → Time-Series DB
  3. pgvector (since it’s just an extra datatype with a few vector specific extensions to SQL) → Vector DB
  4. age (since graphs are queried with Cypher and not SQL) → Graph DB
  5. postgis (since a lot of specialized GIS expertise is required) → Geospatial DB

I’m happy to help if this a direction Ash Core wants to go.

If there’s demand, we could support hstore as a Redis replacement, but I’m not sure for what’s the point in the context of Elixir (or even if you need it anyway when you’ve got jsonb).

Showing Posts 1 to 7

garrison

garrison

Not to take away from your overall point, but can you explain what you mean by this? A relational database (e.g. Postgres) should be more than capable of modeling a tree (“hierarchy”) or graph. Does the problem you ran into have to do with Ash specifically?

Benjamin-Philip

Benjamin-Philip OP

I wanted to model the sub-organizations in a parent organization - each group could be split into smaller groups. In essence this a tree with unbounded depth. In retrospect, I could have handled this with CTEs or ltree.

I could probably pull off ltree with Ash or Ecto fragments.

Again, the main point is we could do with some data layers for non-tabular data. This will take time, and is a tricky problem to solve, but I think it has a lot of value.

zachdaniel

zachdaniel

Creator of Ash

What about this one? Home — AshNeo4j v0.10.1

Or this one?

Or this one?

Or this one?

Or the builtin ETS/Mnesia data layers?

We have quite a few data layers for non-relational data.

zachdaniel

zachdaniel

Creator of Ash

If you’re referring to relationships not being able to return nested graph (i.e nested) structures, I think that’s less of a limitation than you realize. Data layers also have calculations at their disposal, and we could add various things to make that more ergonomic if/when people need/want it.

Benjamin-Philip

Benjamin-Philip OP

I was unaware of these since they’re not under the ash-project organization. Maybe you should link to them from the main repo.

zachdaniel

zachdaniel

Creator of Ash

We link to the ones we or someone on our team maintains, but not necessarily to community related ones. Best way to explore packages that might fit that bill is with an awesome list like:

https://github.com/mipmip/awesome-ash-framework

or with hex

Benjamin-Philip

Benjamin-Philip OP

Hmm… I didn’t think of looking for an awesome list. I just assumed that community packages didn’t exist yet.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
515 12931 101
New
wmnnd
Hey folks, I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Ganna
Hi everyone, I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New
AstonJ
A remark @Garrison made… ..has already inspired a thread for the technical side of reclaiming our internet, but there is of course anot...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews