可扩展查询接口的良好设计是什么?

发布于 2024-07-08 10:30:34 字数 469 浏览 13 评论 0 原文

我们的应用程序通过 Web 服务公开查询,我们发现我们的客户经常需要自定义查询,要么通过指定附加条件进一步限制返回的结果,要么通过询问我们尚未提供的内容暴露。

现在,我们可以采取为每个新方法创建新方法的方法,但这有点不方便; 在客户站点部署我们的应用程序通常需要数周的分阶段集成测试。 我们提出了一种命名查询机制,应用程序管理员可以通过参数化的名称来定义查询,以及简单地调用这些参数的相应 Web 服务。 然而,我忍不住认为以前有人已经解决了这个问题,所以我希望 SO 社区就可能的设计提供一些意见。

谢谢!

更新

规范模式是一个很好的模式,但是我们的应用程序处理足够的数据,我们希望将尽可能多的查询工作推送到 RDBMS 中,这样可以更好地优化查询计划比我们想要的还要多。 此外,我们支持三个 RDBMS 后端,因此我们不得不使用最大公分母方法:我们使用功能最少的数据库可以提供的尽可能多的功能。

Our application exposes queries by way of web services, and what we've found is that our clients often want custom queries, either by way of further limiting the results returned by specifying additional criteria, or by asking for things that we don't already expose.

Now, we can take the approach of creating new methods for each of these new methods, but that's somewhat inconvenient; deployment of our application at a client site usually requires weeks of staged integration testing. We've proposed a named query mechanism, where the application administrator would define queries by name that are parameterized, and a corresponding web service that simply invokes these parameters. However, I can't help but think that someone has solved this problem before, so I'd like some input from the SO community on possible designs.

Thanks!

Updates

The specification pattern is a good one, but our application deals with enough data that we want to push as much of the querying work down into an RDBMS, which can do a better job of optimizing the query plan than we would ever want to. Moreover, we support three RDBMS backends, so we're stuck using a greatest-common-denominator approach: we use as much capability as the least functional database can provide.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

宣告ˉ结束 2024-07-15 10:30:34

我还建议考虑此类应用程序中的“规范模式”作为后端的设计决策。 检查以下有关“规范模式”的帖子:

http ://www.mattberther.com/2005/03/25/the-specification-pattern-a-primer/

http://devlicio.us/blogs/jeff_perrin/archive/2006/12/13/the-specification-pattern.aspx

I would also recommend to consider the "Specification Pattern" in this type of applications as a design decision for your backend. Check the following posts about "Specification Pattern":

http://www.mattberther.com/2005/03/25/the-specification-pattern-a-primer/

http://devlicio.us/blogs/jeff_perrin/archive/2006/12/13/the-specification-pattern.aspx

冰之心 2024-07-15 10:30:34
  • 查看 Hibernates Criteria API 并使用它或构建一些类似的
    为您的用户提供的功能。
  • 如果值得付出努力,请提供一个用于分组标准的树状界面。 (“一组的所有条件必须匹配”/“一个条件必须匹配”/“否定”)

优点:

  • 易于构建。
  • 用户参数是可能的。
  • 强大的查询是可能的。
  • 您可以应用诸如 SELECT ... FROM table WHERE someRestriction AND (​​用户提供的条件)之类的限制
  • Take a look at Hibernates Criteria API and use it or build some similar
    functionality for Your users.
  • If it's worth the effort, provide a tree-like interface for grouping criterias. ("all criteria of a group must match" / "one criteria must match" / "negate")

Advantages:

  • Easy to build.
  • User parameters are possible.
  • Powerful queries are possible.
  • You can apply restrictions like SELECT ... FROM table WHERE someRestriction AND (user-provided criteria)
恬淡成诗 2024-07-15 10:30:34

由于我们确实不知道您的用户如何使用您的界面,因此就感觉更接近“囚犯正在管理庇护所”问题。
有一些非常好的建议和常见方法可以解决这个技术方面的问题,但是它们对您的用户有用吗? 也许他们真的不在乎你的问题,而是有一个很好的一键解决方案? (或者更像谷歌?)

Since we really don't know which how your users use your interface it seems a little premature to give a technical advice on something that feels a lot closer to "Inmates are running the Asylum" problem.
There are some very good advice and common ways to solve this i technical aspects but do they work for your users? Maybe the really don't give a crap about your problem but rather have a fine working one button solution? (Or more like google?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文