SimpleDB 作为评论数据库

发布于 2024-11-05 07:44:43 字数 240 浏览 1 评论 0原文

我是一个新手,正在构建一个允许对某些“文章”发表评论的应用程序。我可以有很多文章,其中有专门与该文章相关的个人评论。

我正在考虑使用 SimpleDB (已经设置并运行我的应用程序的其他组件)。我将使用一个域来存储所有文章的所有评论,并查询该域以在需要时提取适当的评论。显然,随着规模的扩大,我需要跨多个域进行扩展。我很乐意将评论限制在 255 个字符或更少。

这个解决方案有意义吗?我是否遗漏了任何重大缺点?

谢谢!

I'm a newbie building a app that allows commenting on certain "articles." I could have many articles with an individual comment tied specifically to that article.

I'm thinking of using SimpleDB (already setup and running other components of my app). I'd use one domain to store all comments across all articles and query this domain to pull in the appropriate comments when needed. Obviously as this scales I'll need to spread across multiple domains. I'm comfortable with limiting the comments to 255 characters or less.

Does this solution make sense? Are there any major downsides I'm missing?

Thanks!

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

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

发布评论

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

评论(1

不必你懂 2024-11-12 07:44:43

Steven,考虑到您可以接受的限制(稍后当应用程序扩展时跨域分片和 255 个字符的限制),SimpleDB 非常适合这样的事情。实际上,如果您同意限制文章评论的 1 个限制 总共 255 篇,您可以通过在 SimpleDB 中存储以下结构来非常干净地做到这一点:

itemName | comment1 | comment2 | ... | commentN
-----------------------------------------------
articleID| This is..| I like...| ... | Blahbl..

articleID 只需要以您在系统中识别文章的方式进行,以便您可以快速查找;然后您可以拉出一个项目及其所有属性,并且您将获得该文章的所有按顺序的评论。

如果您想更改顺序(ASC/DESC),则必须在应用程序层执行此操作,因为 SimpleDB 不会对您的 attrs 进行排序,而只会对项目本身的列表进行排序。

这也将有助于保持您的域更紧密,因此查询将运行得更快、更长。

如果每篇文章需要超过 255 条评论,则可以将它们分成每条评论 1 个项目,如下所示:

itemName | commentID | commentTest
----------------------------------
articleID| 1         | Ham is gr..

然后,您可以轻松查询一篇文章的所有评论,并根据需要对“commentID”字段应用排序顺序它们是 ASC 或 DESC。

Steven, given the limitations you are OK with (sharding across domains later when the app scales and 255 char limit) SimpleDB is a really natural fit for something like this. Actually, if you are OK with 1 more limitations of limiting comments on an article to 255 total, you could do this really cleanly by storing the following structure in SimpleDB:

itemName | comment1 | comment2 | ... | commentN
-----------------------------------------------
articleID| This is..| I like...| ... | Blahbl..

The articleID would just need to be whatever way you identify the articles in your system such that you could look it up quickly; then you could pull an item, with all it's attributes and you'd have all the comments, in-order, for that article.

If you wanted to change ordering (ASC/DESC) you'd have to do that at the app layer as SimpleDB won't apply a sort to your attrs, just to a list of items themselves.

This will also help keep your domain tighter so queries will run faster, longer.

If you need more than 255 comments per article, you can break them out into 1 item per comment, something like:

itemName | commentID | commentTest
----------------------------------
articleID| 1         | Ham is gr..

Then you can query easily for all the comments on an article and apply a sort ordering to the "commentID" field if you want them ASC or DESC.

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