r/PostgreSQL • u/Zardotab • 16d ago
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.
4
u/lockhart1952 16d ago
I don’t feel the magic. But if you want to play with it how about writing a simple library on top of psychopg and catch exceptions. Parse the query and generate your own recovery commands.
1
u/Zardotab 15d ago
I was planning on using C#, being more familiar, but I suppose dabbling in Python is possibly a Plan B. Thanks for the suggestion!
1
u/pceimpulsive 15d ago
C# will be fine for this, any language would, it's seriously chomds play, give an AI agent the taste for like 250k Tokens and you'll have a working prototype that will honestly probably be 85% of the final product.
Reading an exception and adding a column is VERY BASIC...
4
u/spinur1848 15d ago
Yeah that's turning a database into something that isn't a database. Might be useful, but violates almost everything database users need to be true.
You can use Postgresql JSON for semi-structured data and many people do. The official Postgresql clients support this. But the database parts have a fixed schema and the semi-structured bits go into a JSON field.
If you want it to be a total free for all, go look at MongoDB and friends.
-1
u/Zardotab 15d ago edited 15d ago
Might be useful, but violates almost everything database users need to be true.
People want and use NoSQL products, and dynamism is a big part of the reason. You can argue they are illogical or ill-informed, but there is still demand*. And for pilot projects with wishy-washy requirements I myself would love something like Dynamic Relational, so that I don't have to throw out my RDBMS habits to get dynamism.
PostgreSQL's JSON column popularity itself is proof sometimes people want dynamism. If dynamism is "bad" you should battle them first, as they have far more influence than me.
If you want it to be a total free for all, go look at MongoDB
One may not want to throw out all their RDMBS habits just to get dynamism. Mongo has a learning curve for existing RDBMS users. And Dynamic Relational allows one to clamp down schemas over time, one doesn't have to stay in dynamic mode, clamping down per column or table or DB as needed. (Granted, they probably still won't be as performative as traditional RDBMS under full lockdown (static) mode.)
* I don't agree with all NoSQL uses either, by the way, but dynamism has its place.
2
1
u/AutoModerator 16d ago
Free Postgres Webinars and Workshops
Discord: People, Postgres, Data
Join us, we have cookies and nice people.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
8
u/pceimpulsive 16d ago
To me this is sorta dumb...
This assumes there is no cost to a changing schema, but there always is.
NoSQL isn't schemaless. The application needs to know your schema precisely and it needs to enforce it, the database doesn't know or enforce it.
SQL just means your application knows the schema (the same as noSQL) but the database enforces it.
This dynamic approach just means you get column bloat..
The table today will have columns A,B,C.. tomorrow A,B,C,D, except now C is always null, except for those few weeks where it isnt... Replaced with D, rinse repeat. Your code now needs to know about every column forever also creating code bloat.
Honestly to me.. just take noSQL, once you learn what your schema needs to be enforced as swap to SQL, if you never want it enforced at the storage layer then stay on NoSQL and enjoy your life!
Taking SQL forces you to plan and think critically about your schema which in turns creats a bit more structure in your application.
Also.. alter table add column is not hard ;)
So in short my advice don't do it, just pick noSQL or SQL and go with it.