数据库设计:如何在MySQL数据库中存储用户的新闻首选项?

时间:2022-10-04 07:11:32

I'm trying to implement a personalized news aggregator. I have to save user's preferred news sources in db. Should I store all the news sources liked by a user as JSON string and then decode it after retrieving?

我正在尝试实现一个个性化的新闻聚合器。我必须在db中保存用户喜欢的新闻源。我应该将用户喜欢的所有新闻源存储为JSON字符串,然后在检索后进行解码吗?

feeds | user

提要|用户

or have individual column for each news source(no of news sources would be around 200)?

或者每个新闻源都有单独的专栏(没有新闻源会在200左右)?

feed_name1 | feed_name2 | .....  | user

1 个解决方案

#1


2  

Sounds like a many-to-many situation. A solution that used a person table, a newsfeed table, and a person_newsfeed table might be appropriate. There are lots of articles on line about this and any good database theory book (or Something like Oracle: The Complete Reference) should cover this in detail.

听起来像是多对多的情况。使用person表、newsfeed表和person_newsfeed表的解决方案可能是合适的。有很多关于这方面的文章,任何好的数据库理论书籍(或者类似Oracle:完整的引用)都应该详细介绍。

This article is a pretty good (but very short) summary: http://www.databaseprimer.com/pages/relationship_xtox/

这篇文章是一个很好的总结(但非常简短):http://www.databaseprimer.com/pages/relationship_xtox/

Oracle8 The Complete Reference covers this around page 35 with the worker, skill, workerskills example during their discussion of third normal form.

Oracle8完整的参考文献涵盖了第35页的工人,技能,工人技能的例子,在他们讨论的第三个正常形式。

#1


2  

Sounds like a many-to-many situation. A solution that used a person table, a newsfeed table, and a person_newsfeed table might be appropriate. There are lots of articles on line about this and any good database theory book (or Something like Oracle: The Complete Reference) should cover this in detail.

听起来像是多对多的情况。使用person表、newsfeed表和person_newsfeed表的解决方案可能是合适的。有很多关于这方面的文章,任何好的数据库理论书籍(或者类似Oracle:完整的引用)都应该详细介绍。

This article is a pretty good (but very short) summary: http://www.databaseprimer.com/pages/relationship_xtox/

这篇文章是一个很好的总结(但非常简短):http://www.databaseprimer.com/pages/relationship_xtox/

Oracle8 The Complete Reference covers this around page 35 with the worker, skill, workerskills example during their discussion of third normal form.

Oracle8完整的参考文献涵盖了第35页的工人,技能,工人技能的例子,在他们讨论的第三个正常形式。