TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Flexible schemas are the mindkiller

79 点作者 l0b0大约 1 年前

16 条评论

MattPalmer1086大约 1 年前
I once worked at a place that had many different specialised applications serving different needs and serving different data.<p>The incoming CEO who wanted to make his mark (let&#x27;s call him Derek) had an impressive background in marketing decided that the right thing to do was to rationalise everything into one huge database.<p>They employed a small army of consultants who covered the entire office (it was a big office) in huge database schema diagrams. This took several months. Eventually they &quot;discovered&quot; that the only data that the schemas had in common was a reference, a description, and a created date field.<p>So they immediately cancelled the project and we all breathed a sigh of relief. Haha, only kidding. Of course they didn&#x27;t. The right solution was to go schemaless. Enter mongodb. They would achieve full flexibility going forward, and wouldn&#x27;t have to subside a small diagramatic wallpapering industry as a bonus.<p>At this point I was no longer involved and just watched the slow train wreck from afar. Years later all the applications had finally been migrated to use the new OneDatabaseToRuleThemAll™ system. I don&#x27;t think any new functionality was delivered over that period. There were persistent performance issues for the larger data sets. Changing anything required the code to support all previous possible schemas because they never migrated any data (it&#x27;s schemaless, it&#x27;s all super flexible!).<p>I think Derek left to go ruin somewhere else, with a huge success story on his CV.
评论 #39561012 未加载
评论 #39560518 未加载
评论 #39574289 未加载
评论 #39560031 未加载
shoo大约 1 年前
One useful piece of rhetoric is using &quot;schema-on-read&quot; instead of &quot;schemaless&quot;. It helps make it clearer that the schemas aren&#x27;t eliminated by using a &quot;schemaless&quot; data store, you&#x27;re just pushing the responsibility of data validation into all of the data-consuming applications. Shift right!<p>I think i encountered &quot;schema-on-read&quot; vs &quot;schema-on-write&quot; from the book designing data-intensive applications
评论 #39561018 未加载
评论 #39559711 未加载
andrelaszlo大约 1 年前
&gt; there is a certain type of person that probably has all the mental horsepower required to be a phenomenal engineer that simply gets stuck on their &quot;elegance&quot;<p>and<p>&gt; I do not understand how they are both smarter than me in many respects, and then still don&#x27;t understand how stupid this all is.<p>This is such a good question. The absolute worst codebases I&#x27;ve worked on have been created by brilliant individuals. I remember spending <i>months</i> tracking down bugs leading to inconsistencies in the universal &quot;Things&quot; table. &quot;Everything is a thing! Right?!&quot; Wrong...
评论 #39559730 未加载
评论 #39559922 未加载
评论 #39559799 未加载
brylie大约 1 年前
&gt; there is a schema, it lives in their incomprehensible code<p>I’ve started to think of this as a diffuse schema. I.e. the schema never really goes away in “schemaless” databases. It just spreads throughout the application in helper functions, mappings, and backward compatibility hacks.<p>Perhaps the distinction is between diffuse and consolidated or implicit vs. explicit schema. Are there any similar models or articles that have further described this realization?
polotics大约 1 年前
I am surprised no-one mentionned the to me obvious explanation for Derrek&#x27;s behavour: wilfull obfuscation, at-least partly aware of the consequences, with a calculated maximization of the consulting fee.<p>If the incentive structure is set up in such a way as to provide an easy local maximal for the individual that is not a good outcome for the compoany, then it is a management failure.<p>Having such a situation where all individuals up the management chain are doing short-term local maximization that medium term leads to a bad outcome for everyone is societal failure.
评论 #39561077 未加载
baazaa大约 1 年前
Tangentially related: it now takes our data eng team 6 months to mirror some tables (into databricks) due to data vault modelling... presumably to handle schema changes. And then at the end of it everything is riddled with duplicates and missing data because they don&#x27;t know what they&#x27;re doing. But none of the source-systems can do schema evolution anyway, so we know the schemas would never change.<p>I think as an industry we should stop warning juniors of &#x27;premature optimisation&#x27; (kids aren&#x27;t even choosing the right data-structures&#x2F;algos&#x2F;architectures and are getting terrible perf), and instead warn them away from premature scalability and premature &#x27;flexibility&#x27;.
fabian2k大约 1 年前
Obviously, if you actually have a defined schema then using anything like EAV or JSON support in your relational database is a bad, if not outright terrible idea. Your queries get a lot more complex and you lose most of the type safety a rigid schema provides.<p>But there are cases where you need flexibility, and the very categorical dismissal of EAV and anything similar is not particularly helpful if you find yourself in the situation where you need that kind of feature. It&#x27;s a lot better today with good JSON support in relational databases, but even that doesn&#x27;t give you good index support unless you give up on some of the flexibility. EAV is actually superior in that aspect if you don&#x27;t put all your values into a string column.
评论 #39561047 未加载
andyjohnson0大约 1 年前
Lone wolf developer in a small organisation with minimal supervision. Seen it before. I maybe even was one once, way back.
评论 #39560021 未加载
j-pb大约 1 年前
Shoving triples into SQL is braindead, but theres a multi-billion dollar industry around triple stores, graph databases, and RDF.<p>Datomic is in the same group, and I&#x27;d consider Rich Hickey to be one of the best programmers there are.
评论 #39559333 未加载
评论 #39559475 未加载
评论 #39565757 未加载
MrBuddyCasino大约 1 年前
&gt; <i>I do not understand how they are both smarter than me in many respects, and then still don&#x27;t understand how stupid this all is.</i><p>Met this kind of person three times so far, been asking myself the same question. I suspect they live too much in their own head.
评论 #39559459 未加载
jfisher4024大约 1 年前
I’m working with a Derek right now. Highly motivated and highly incompetent. Usually it’s one or the other. How do you deal with people like this?
评论 #39561098 未加载
评论 #39561025 未加载
peteradio大约 1 年前
This is such a good article. Poor Derek probably lacks communication skills or any firm mentorship or a spine.
sam_lowry_大约 1 年前
@lucidity can you give an example of a database test with views?
评论 #39561116 未加载
fifticon大约 1 年前
I have a question about this, that I probably can&#x27;t explain well in a single comment. Normally I have well-defined schemas for my data, and obviously prefer this for its uncountable benefits.<p>However, over the years I have occasionally and reluctantly used the &#x27;Derek table&#x27;, for importing domain data with a dynamic schema, aware that I will be paying dearly for it.<p>My question is: What alternatives are there..? Other kinds of databases, maybe those used for &#x27;big data&#x27;?<p>I must clarify:<p>(1) I know I could instead create proper db tables on the fly - this way, I _can_ have varying columns depending on each new set of domain data I import. However, IF I do this, I will now have to dynamically build my SQL queries, to refer to these varying tables and column names. The BUILDING of those SQL queries is not to fear, but the query execution of them is, since each new variant is a not previously seen db execution plan, and some of those will hit weird performance problems. I am painfully aware of this, because I have worked(still do) &#x27;lifeguard duty&#x27; on a production database, where I routinely had to yet again investigate how a user this time had created a dbms-choking query with exactly this technique.<p>(2) In the derek approach, the approach would usually be to violently retrieve &#x27;all the query-relevant records&#x27; (e.g., the contents of &#x27;project&#x27;&#x2F;&#x27;document&#x27;), and then do the actual calculation in code, e.g. C#. This of course has the downsides of<p>(2.1) - we must haul huge (relatively speaking) amounts of raw data off the db, since we are not summarizing it to the calculation-end-result before-hand. But this is also the &#x27;benefit&#x27;: We know we won&#x27;t bother the db further than this initial and rather simple haul&#x2F;read. (I AM aware I could also query the derek monstrosity directly, but I have seen enough of that to know to avoid that, to not bring the dbms to the curb.)<p>(2.2) This is an extension of 2.1: Since we are working with the raw data, we must &#x27;pay&#x27; both for moving the big chunk of data over the network, and also&#x2F;often for having it in working memory on the actual external processing&#x2F;calculation server (this may not be true, if the calculation can be done piece-wise working on a stream). And, of course, there is the entire cost of &#x27;a single table cell is now a whole db row&#x27;.<p>Echoing poor Derek, the benefits of the described approach, is that it actually takes relatively simple approach and code to build the solution this way, at a tremendous cost to resources&#x2F;efficiency. If I did &#x27;the right thing&#x27;, I would have to write considerably more and more complex code, to handle the dynamic DDL&#x2F;schema processing, to dynamically work with the real DB schema.<p>Back in the 90&#x27;s, I would by necessity have &#x27;done the right thing&#x27;, since the Derek approach was doomed performance-wise then. But now, in the 2020&#x27;s, we have so much computing power, we can survive - for a time - by wasting extravagant amounts of resources.<p>To recap&#x2F;PS: Whenever I have done this, it has been for a small subset of specific data; I have never done it in the insane &quot;one single table&quot;, with dynamic tables too. My case has always been &#x27;dynamic fields&#x27;.<p>Also, for context: The &#x27;calculation&#x27; to be done, typically amounts to what could generously be referred to as a bit pivot-table operation on a heterogeneous set of data (which is why, expressed on proper SQL, the query would be rather verbose and unwieldy, accounting for all those heterogeneous and possibly-present fields on the different source tables&#x2F;datasets)
FredPret大约 1 年前
Amazing writing! Reminds me of the Cuckoo&#x27;s Egg for some reason.
评论 #39559198 未加载
评论 #39561157 未加载
评论 #39559699 未加载
edg5000大约 1 年前
So derek left after 8 months without delivering anything useful. The data was in a format that prompted immediate conversion to a correct relational database model.<p>You then took over and worked for ~8? months, taking good pay, working from home for a substantial portion, complaining about a not perfect air conditioner, and left as soon as your paperwork got approved.<p>By the end of you time there, did you deliver something that they could put into use?<p>Of course those first months are painful, as management was unaware of the unusable state of the code.