by mbreese · 2y ago · 0 comments
IIRC, SQLite can do similar things with virtual tables (with a more limited set of data file types).
I always liked this way of working, but I also wonder why it never really took off. Data discovery can be an issue, and I can see the lack of indexing as being a problem.
I guess that’s a long winded way to ask: as interesting as this is, what are the use cases where one would really want (or need) to use it?
In today's new fangled world, a lot of developers don't use a lot of the great stuff that RDBMS can provide - stored procedures, SQL constraints, even indexes. The modern mindset seems to be that that stuff belongs in the code layer, above the database. Sometimes it's justified as keeping the database vanilla, so that it can be swapped out.
In the old days you aimed to keep your database consistent as far as possible, no matter what client was using it. So of course you would use SQL constraints, otherwise people could accidentally corrupt the database using SQL tools, or just with badly written application code.
So it's not hard to see why more esoteric functions are not widely used.
It's honestly the dumbest situation, where people eagerly use extremely complex databases as if they were indexed KV stores. Completely ignoring about 97% of the features in the process.
What's especially funny is that half the time a basic KV store would perform better given all the nonsense layered on top.
And then there's this whole mentality of "we can't interface with this database unless we insert a translation layer which converts between relationships between sets of tuples and a graph structure".
It's like people have unearthed an ancient technology and have no idea how it's intended to be used.
The “consistency must be enforced at all costs” just turned out not to be true. Worked at many places at moderate scale since my old dba days that don’t use fks. It just doesn’t actually matter, I can’t recall any serious bugs or outages related to dangling rows. Plus, you end up having multiple databases anyway for scale and organizational reasons so fks are useless in that environment anyway.
On the other hand, I’m all for indexes and complex querying. not just k-v.
That's what I meant when I said it's weird people keep picking these particular databases for projects which don't end up using any of the features.
Stored procedures, triggers and all the other features people seem to refuse to use work mostly fine if you actually design the rest of the product around them and put a modicum of effort into them.
"It doesn't scale" - that can be said of the fundamental database design itself. If you need to scale hard then you need to pick a distributed database.
But I like foreign keys (ON DELETE RESTRICT), they are the last layer of defense against application bugs messing up the database.
Implementing constraints in application code is certainly a lot easier (and easier to test) than in the database. What I want is a database which far stronger constraint capabilities than eg MySQL or Postgres provide, so that my application-level constraints can live in the database where they belong, without compromising ease of development and maintenance.
I can’t imagine doing this. You’re basically saying that you will only ever have one program writing to your database.
The idea being that a single service/codebase is controlling interaction with the database. Any read/writes should go through that service's APIs. Basically a "CreateFoo(a, b, c)" API is a better way to enforce how data is written/read vs every service writing their own queries.
Its storing transform code in an inscrutible way, hiding pipeline components from downstream users. The rest of your alarms and dq has to be extendend to look into these...
Oh an PL/SQL requires a huge context switch from whatever you were doing.
On the other hand, yes, going back to the days of poorly written and documented oracle pl/sql stored procs, yes, I shudder too, but then again, that can also be said of a number of public APIs that have been hacked/had side effects exposed.
Don’t worry, just wait another 5-10 years, they’ll be back in vogue again.
Not necessarily. All depends on particulars. Very complex processing of reasonably sized chunk of data especially when can be done in multiple threads / distributed can be way more efficient.
I've head very real case: consulting company was hired by TELCO to write the code that will take content of the database and create one huge file containing invoices to clients. Said file would then be sent to a print house that can print the actual invoices, and mail those to clients.
They tried to do it with stored procedures and had failed miserably - it would run for a couple of days give or take and then crash.
I was called for help. Created 2 executables. On is a manager and the other is multithreaded calculator that did all the math. Calculator was put on 300 client care workstations as a service. Dispatcher would do initial query from accounts table for current bill cycle, split account id's into few arrays and send those arrays to calculators. Calculators would suck needed data in bulk from a database, do all the calculations and send the results back to dispatcher for merging into final file. TELCO people were shocked when they realized that they can have print file in less than 2 hours.
- Audit tables are often implemented thanks to triggers
- Soft deletes can be easily implemented thanks to triggers
People don't hate stored-procedures (or other custom SQL constraints/triggers) per-se, but more the amount of headache they bring when it comes to debugging and keeping in sync with version control.
That's way easier to debug than if Jimmy also had his query living as a string somewhere in your backend code.
Honestly, if this stuff is hard, it's because you've made it hard. I can only assume most people griping about stored procedures don't have a /sql folder living next to their /python or /java folder in source control.
What build system has good integration for doing these kinds of updates out of the box or does it require customization?
I understand if it's a prototype, I have seen developers of even mature products follow this mentality that they want the DB to be portable. It's insane. The reality is that rarely happens and when it does its mostly cause your business is growing. But not knowing (or caring to know) the features your DB offers you and not exploiting it is just laziness.
However, I like to limit my toolset to three things, these days thats duckdb, julia for analysis side, and... OK two things.
Oh yeah Trino for our distributed compute.
It’s actually a chapter in the ISO/ANSI SQL specification.
As a result, a specification was added, as part of ISO/ANSI SQL specification process.
The MED term is an acronym and not a shortening of "medical".
I wouldn't be surprised if the term SQL/MED had been spoken in healthcare/medicine circles (I worked in that industry before). That said, it's the first time I've ever seen anyone connect the term/concept specifically to medicine as the driver for the term.
I'm actually someone who has gone deep down the SQL rabbit hole (I worked for a company that built a data federation platform previously), I'd be interested to read more if you can share.
My apologies, I thought the confusion of the acronym simple came from the "MED" part, which as I mentioned, stands for "management of external data".
In that respect we are in complete agreement :)
EDIT: Perhaps you might be referring to something like this paper about data federation in general? https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&d...