- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
像 LINQ 这样的技术在描述关系数据查询方面做得很好,类型如 IQueryable
, IGrouping
, 和 IOrderedQueryable
建模投影、选择、聚合、排序等。这些来自关系代数的概念允许我们在一台机器上用一种语言交流一个相当任意的查询,并在不同的机器上用不同的语言 (~sql) 执行它。
如果能够对更复杂的多部分查询甚至涉及 INSERT
的数据操作命令执行相同的操作,那就太好了。 s, UPDATE
s 和 DELETE
s 可以描述完整的操作,而无需首先在应用层检索/水合数据的开销,这是对象关系映射器或 ORM 的典型特征。
在应用程序中,我们可以描述一个像 Delete all 这样的操作。客户 (以及他们的 订单 ),其最近的 订购 超过 2 年(此外,假设没有为该关系启用级联删除)。这当然比带有 t-sql 脚本的 ADO 更有效,但不能在 ORM 中完成,而没有在应用程序层中选择、传输、混合和跟踪数据以及可能发出单独的删除命令的开销。 (也许有一些可用于 ORM 的优化可以在某些情况下更有效地执行此操作,但通常 AFAIK 他们不能)当然,发布 t-sql 脚本的问题是语句中没有类型检查,也没有任何参数或返回数据。
能够为远程执行建模这些任意命令的一个惊天动地的优势是,除了减少运行时处理和网络聊天开销之外,还可以在应用层中对域范围的不变量进行编码和注册,然后可以将这些不变量与任何临时命令。
我们可能有一个愚蠢的域不变式 A
对于所有 客户 , 总和 客户 的订单' 价格不能超过 $10,000,000.00,除非 哇 位是 1 和另一个愚蠢的域不变量 B
说对于所有 客户 , 姓氏 不能包含三个以上的下划线(尽管这些下划线可能可以通过数据库引擎本身的检查约束或触发器的 native 机制强制执行)。然后当我们发出更新现有的命令时 订单 价格 ,系统通过静态分析可以知道不变量A
可能会因为命令和不变性而被违反 B
不能,因此系统会发出一些断言 A
在原始命令之后。整个发出的脚本将被包装在一个事务中(如果断言失败则回滚)并且可以自动缩小不变量以仅针对特定的 断言规则。客户的一套订单而不是不必要地重新检查所有 客户的总计。我相信这种优化的、集中的、DRY 的业务规则编码/执行在今天的产品中是不可能的。
为了实现这种潜力,我认为我们需要一个代数(超出 SELECT
的关系代数)来描述 INSERT、UPDATE 和 DELETE(统称为 DML)的任意数据操作,甚至像中间计算这样的东西值,如用于计算的临时表,在 t-sql 中表示为多语句列表。
不幸的是,我一直无法找到关于将 DML 形式化为代数的研究,或者能够对其进行建模,或者此类元编程。尽管 Tutorial-D 和 jOOq 似乎为讨论提供了一些东西 - 我只是不知道如何提取它。你能解释清楚吗?
一些我认为很有值(value)的讨论,但我想避免用它来填写评论:
Are you suggesting that domain models aren't a good fit to protect invariants and establishing transactional boundaries? The invariants you mentioned aren't hard to protect using a proper domain model. What problem are you trying to avoid exactly?
As I understand it, large domains in typical ddd require bounded contexts to avoid having to hydrate large subsets of the data into the application layer for validation. I am trying to avoid that overhead. Also, domain invariants must be non-trivially restated for each bounded context, which is error-prone. By modeling the operations for remote execution, we get smarter/smaller/faster/more correct code.
In some core library, the domain could be modeled and the invariants registered. Then consumers of that library, such as for a web service, could then construct type-checked descriptions of arbitrary operations without explicit consideration for bounded contexts or particular invariants. The domain core offers to its consumers "this is the full range of what you can do over this domain" and (perhaps) the service code offers to its clients "these are the exact features we're offering".
I'm not sure if you understood correctly what a Bounded Context is and how they might communicate with each-other. "Also, domain invariants must be non-trivially restated/maintained for each bounded context which is error-prone" There's usually just one context that have data ownership and that context shall be responsible for invariants involving it's own data. For instance, imagine a company that sells goods on Internet. They might have an Inventory context where products gets maintained and a Shopping context that listen to newly available products from the Inventory.
I'm not very much arguing against current ddd techniques, so I'm not choosing excellent examples against them. I'm more interested in this alternative arrangement which I intuit would be more natural and advanced than current ddd techniques. I've seen data models that are extremely intertwined and don't offer obvious boundaries (perhaps poorly designed, OK). I expect that this way could be boundaryless AND more performant.
If there was a rule that a Product name couldn't contain the word "propaganda" it would be enforced only in the Inventory context. If we were to duplicate invariants of every contexts in every other contexts it would indeed become a maintenance nightmare.
But you plausibly might have a bounded context centered on Customers and a second bounded context centered on Orders. And maybe the $10,000,000.00 Limit I mentioned is made to be a column in Customer (and therefore variable), so this business rule can be violated in two ways: either by dropping that Limit on Customer or increasing totals in Order. So non-trivially reciprocal rules must check for violations in either bounded context depending on the change. Our system could decide to skip the assertion if Prices and Limits aren't changed, which would be pretty slick, no? In the traditional ddd, you might also need some optimized variants for bulk manipulations (Add an Order of $1000 to every Customer) which could be automatically derived by our new system.
最佳答案
看起来不太可能,你不需要的一件事是“超越”关系代数的东西。这根本不是一个理论问题,而是一个想象力和工程问题。您所谈论的问题跨越多个领域:编程语言、库支持和 DBMS。它可以(并且应该)完成。但首先它需要被普遍理解为现实和可取的,而我们还没有做到。
就代数而言,缺少的只是赋值。如果你读过 Date 的第三个宣言,你可能还记得插入/更新/删除只是赋值的变体:
S += f(R) -- insert
S += f(R) - g(S) -- update
S -= f(R) -- delete
关于database - 对基于集合的 sql 数据操作操作的代码列表进行建模,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32894724/
我们使用 Azure 弹性池,生成多个客户端数据库和一个引用客户端数据库的主数据库。 我们已经拥有多个数据库,并且正在开发新版本的代码。我们使用 EF6 代码优先。当我们对模型进行更改(添加属性)时,
我们使用 Azure 弹性池,生成多个客户端数据库和一个引用客户端数据库的主数据库。 我们已经拥有多个数据库,并且正在开发新版本的代码。我们使用 EF6 代码优先。当我们对模型进行更改(添加属性)时,
我希望将一些信息分发到不同的机器上,以便在没有任何网络开销的情况下实现高效和极快的访问。数据存在于关系模式中,实体之间的关系是“加入”的要求,但根本不是写入数据库的要求(它会离线生成)。 我非常相信
我使用 GrapheneDB 来托管我的 neo4j 数据库 (db)。 问题 我有 N客户并且正在寻找自动分离他们的内容(他们独特的数据库)的方法,以便: 它不重叠数据 操作速度不受影响。 选项 1
当服务器开始工作(Tomcat)时,日志显示此错误: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid b
我在 Oracle 数据库实例中按以下方式创建了一个触发器。 CREATE OR REPLACE TRIGGER after_logon_on_database AFTER LOGON ON DATA
原谅我的无知,我是数据库约定的初学者。 这是我的 SQLite 代码:(由我的数据库浏览器自动生成) CREATE TABLE `ResearchItems` ( `ID` INTEGER NO
是的是的是的,我已经在整个互联网上搜索过这个问题。一些结果发现,甚至来自 Stackoverflow。但是他们中的大多数人说“你应该自动加载数据库”,或者“parent::__construct();
我正在创建一个 Mac 应用程序,它将一些数据保存到 SQLite 数据库中。问题是:当我关闭数据库并再次打开时,数据不存在了。这是我的代码: NSString *sql = [NSString st
我正在建立一个网站,我打算发布各种帖子,比如教程、文章等。我打算用 php 来管理它,但是当涉及到存储每个帖子的内容时,将要显示的文本,更好的选择是:使用单独的文本文件还是将其添加为数据库中的每个条目
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 3 年前。 Improve this qu
对不起,这个关键字对我来说没有任何意义...有人可以给我一个定义吗? 提前致谢... 最佳答案 这是一个品牌。 http://pervasive.com/这是他们的数据库产品的链接 http://ww
我已经在 docker 版本 1.10.1 的 docker 镜像中安装了 PostgreSQL 9.4.6。根据这张官方图片: https://github.com/docker-library/p
当我的 android 应用程序尝试读取 android 短信数据库时,我遇到了这个崩溃。读取android短信数据库的代码类似于下面的代码 fragment : String SMS_URI = "
我有一个 public kit repo,我推送了 v1.0.3 并具有以下结构 go -database --database.go --go.mod --go.sum 我需要它 require g
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 9 年前。 Improve this qu
我们正在使用MySQL数据库在Go中创建一个Web应用程序。我们的用户一次只能拥有一个活跃的客户端。就像Spotify一样,您一次只能在一台设备上听音乐。为此,我制作了一个映射,将用户ID和作为其值的
我已经尝试在 PostgreSQL 中创建数据库好几天了,遇到了几个问题,但似乎卡住了。 我在 PostgreSQL 中手动创建了一个名为 postgres_development 的数据库,因为 b
我正在创建一个 iMessage 应用程序,它需要连接到与我的常规应用程序相同的数据库。 我调用 FirebaseApp.configure() 并对用户进行身份验证,但出于某种原因,在所有 Data
就像std::unordered_map但所有数据都应存储在磁盘上而不是内存中。 按照我的理解,应该做两部分:索引和存储。我已经学习了一些关于索引的数据结构,比如 Linear-Hash 或 B-Tr
我是一名优秀的程序员,十分优秀!