是“黑洞”表邪恶吗? [英] Is a 'blackhole' table evil?

查看:123
本文介绍了是“黑洞”表邪恶吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读这个问题,我刚刚学到了 blackhole 表技巧:基本上是使用单个表来插入数据,然后是一个触发器,将数据分成许多其他表。

Reading to this question i've just learned the existence of the blackhole table trick: basically consist in using a single table to insert data, and then a trigger that split the data in many other tables.

我不知道这是否会导致问题,一旦工程项目的开发人员知道这一点。

Im wondering if this could cause problems, once the developers whos working on the project are aware of that.

这个 > tecnique

编辑
当我看到这个例子时, :如果由于某种原因事务失败,你会发现 blackhole 行与原始数据,历史目的,也许是一个帮助debug - 但这似乎是只有+1我可以看到与黑洞。想法?

Edit: The blink I got in mind when I saw the example, is about transactions: if for some reason the transaction fail, you'll find the blackhole row with the original data, for historical purpose and maybe a help with debug - but this seems to be the only +1 i can see with blackholes. Ideas?

推荐答案

我不认为黑洞有任何真正的职业。

I don't think blackhole has any real pros.

编写触发器代码来移动数据可能不会比编写代码将数据插入到正确的位置要少得多。

Writing the trigger code to move data around is probably not noticably less work than writing the code to insert the data in the right place in the first place.

正如Christian Oudard所写的,它不会降低复杂性 - 只是将它移到一个真正难以调试的地方。

As Christian Oudard writes, it doesn't reduce complexity - just moves it to a place where it's really hard to debug.

在缺点:

副作用在软件开发中通常是个坏主意。触发器是副作用 - 我打算做一件事(在表中插入数据),它实际上做了很多其他的事情。现在,当我调试我的代码,我必须保持所有的副作用在我的头也 - 副作用本身可能有副作用。

"Side effects" are usually a bad idea in software development. Triggers are side effects - I intend to do one thing (insert data in a table), and it actually does lots of other things. Now, when I'm debugging my code, I have to keep all the side effects in my head too - and the side effects could themselves have side effects.

大多数软件在维护上花费的时间比在开发中要多得多。让新开发者进入团队并解释黑洞伎俩可能会提高学习曲线 - 对于可以忽略不计的利益(在我看来)。

most software spends far more time in maintenance than it does in development. Bringing new developers into the team and explaining the black hole trick is likely to increase the learning curve - for negligible benefit (in my view).

因为触发器是副作用,如果你不小心,相对容易引发一个庞大的触发器级联,我总是试图设计我的数据库而不依赖于触发器;触发器显然是正确的方法,我只让我最有经验的开发人员创建它们。黑洞技巧使得触发器进入正常,规律的工作方式。这是个人的观点,当然。

Because triggers are side effects, and it's relatively easy to set off a huge cascade of triggers if you're not careful, I've always tried to design my databases without a reliance on triggers; where triggers are clearly the right way to go, I've only let my most experienced developers create them. The black hole trick makes triggers into a normal, regular way of working. This is a personal point of view, of course.

这篇关于是“黑洞”表邪恶吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆