I've been working on a kind of "universal type language" to address this problem. My goal is that it can have semantically identical data structures that function in multiple host languages, and then similarly on the DBMS. https://tenet-lang.org/
Re:Databases always have a schema (2018)
by erik_seaberg on Monday February 25, 2019 @11:30AM
(#19246752)
> that Java application was the only thing that would ever use that database
It's a mistake to make this assumption unless you've taken extreme measures to lock down and audit all access. It's pretty common for the entire dev team to have read access, and someone has inevitably built some ad hoc thing taking advantage of that.
Perhaps I should've said "the only piece of infrastructure that would ever use that database". DB browsing software and even ad-hoc scripts don't need a perfect schema; you can usually just grok it by visual inspection
Re:Databases always have a schema (2018)
by erik_seaberg on Wednesday February 27, 2019 @12:17PM
(#19264840)
That's a problem when we break something ad hoc the founder wrote to reconcile the books once per month. Data attracts surprising and important uses.
Re:Databases always have a schema (2018)
by Arcsech on Monday February 25, 2019 @10:55AM
(#19246489)
You could use something like JOOQ[0], which (optionally) generates Java code based on your SQL schema.
We used hibernate, which does the opposite (Java classes/annotations -> SQL). You'd still have the same disadvantages: having an imperfect "clone" of your schema.
Can you elaborate what you mean by "imperfect"?
A Java string isn't precisely the same thing as a varchar(255), for example. Nor is an ArrayList (ordered) the same thing as a set of rows (unordered). Mapping between these slightly different sets of concepts usually works well enough, but it's an additional piece of disjointedness.
I spent a year and a half at an enterprise Java shop, and there was a ton of work there put into maintaining and syncing the Java types and the SQL schema, even though that Java application was the only thing that would ever use that database.
I wonder what it would look like to have a schema definition system that was equally understood by the DB and the code, so you didn't have to pick one or the other or both.