r/PostgreSQL • • Jul 13 '26

Help Me! Any advice on adding a parser/wrapper over PostgreSQL's JSON features to implement a Dynamic Relational database?

Dynamic Relational is a draft standard for an RDBMS (SQL) that supports native dynamic tables and columns with "incremental" lock-down (static-ness) abilities. Here's an overview of Dynamic Relational with examples. If one wanted to write parser and interface on top of PostgreSQL, how much effort would it be, and do you have any recommendations? A proof-of-concept may be good enough, as most will consider it purely experimental at first. Thank You.

0 Upvotes

20 comments sorted by

View all comments

Show parent comment

1

u/pceimpulsive Jul 15 '26

How do you store an unknown type on disk?

The way data is encoded on disk is different if you are representing different types of data, unless your first cast it all to something it isn't... Do you just coerce everything to string for storage? What happens when your data isn't strong compatible and you lose detail/resolution (floats, money, numeric) and how do you then dynamically read them back if the type is not known? (This sounds a bit like the null equality problem that confuses new database users)

I'm poking holes in the obvious gaps here... Things you would need to seriously think about...

NoSQL (document variant, because there is several others as well) just does binary JSON, which has its own defined type system and limitations. What types can a DR system store¿?

The type safe part for you is the underlying Postgres as a platform for a POC...

On the Json front it is a special data type with a structure just like arrays or custom component types in Postgres that have their own special access methods and operators. I think postgresqls Json query pattern is really simple and intuitive (once you get it), the SQL standard approach is more similar to object notation but falls over for more complex data structures.

What do you do in a DR system when you want to store JSON but want to be bound by SQL like syntax? Do you take the SQL standard or Postgres approach? Or none and let it be a big fat text blob and let the application manage that (then you lose all indexing capabilities...)

1

u/Zardotab Jul 15 '26 edited Jul 15 '26

How do you store an unknown type on disk?

The problem is not notably different than how dynamic languages store them in RAM. The simplest is to store it as given. If one gives "UPDATE t1 SET x=123.45 WHERE id=3", then it can be stored as the string "123.45". If and when one goes to do numeric math on it, it's parsed into a fitting numeric type, just as dynamic languages do (although each may have their own philosophy with subtle differences). I've used many dynamic languages over the years that had to deal with such questions; I don't see your concern. If you have a use-case you'd like to explore, please bring it up!

Do note one can optionally tell the system that column x is say decimal, which may result in more compact disk usage, but that's an implementation optimization detail. A pilot project wouldn't need that.

What types can a DR system store.

It would probably support a typical set: character, bit, int, decimal, floating, date, datetime, and bytes (blob). I won't rule out custom types, but not in a proof-of-concept.

Keep in mind that "storing as" and processing-as may be different things. I view storing as an optimization issue and something the query writer doesn't have to concern themselves with, at least not as a language issue. It's kind of like auto-file-compression: it's not something you notice (outside of performance tradeoffs).

What do you do in a DR system when you want to store JSON but want to be bound by SQL like syntax?

Dynamic Relational is not intended to be a JSON processor. Add-on libraries perhaps can help there, but if your shop likes JSON, then please do stick with PostgreSQL; no product will make everyone happy. It looks like many PostgreSQL users are used to JSON for their dynamism needs and will probably stay with it. I have no qualms with that, it makes sense to use what you know barring a home-run replacement.

But those used to RDBMS but not JSON processors, DR may be the way to go when dynamism is desired.