我有很多文章.我有很多可能的关键字.每篇文章都有至少一个与之关联的关键字,但可能有许多关键字.有一个数据库,其中包含所有文章的列表,并且如果适用该关键字,则将每个关键字的布尔变量设置为true.用户拥有所有关键字的列表,然后选择感兴趣的关键字.我正在尝试找到一种比蛮横的SQL SELECT方法更优雅的方法来提取相关文章列表.任何建议将不胜感激!
I have a large number of articles. I have a large number of possible keywords. Each article has at least one keyword associated with it, but may have many keywords. There is a database containing a list of all articles and a boolean variable set to true for each keyword if that keyword applies.A user has a list of all keywords and selects those which interest them.I am trying to find a more elegant way to extract the list of relevant articles than a brute force SQL SELECT.Any suggestions would be appreciated!
推荐答案我想您不会能够从选择语句中逃脱...也许您可以尝试为此使用存储过程,或者尝试优化选择,但并非没有选择,我认为 I guess you will not be able to escape from a select statement...maybe you could try to use a stored procedure for that, or try to optimize the select, but not without a select I think
我认为您的数据库设计不理想.您应该为所有文章提供一个表,并为所有可能的关键字提供一个表.在第三张表中,保存所有关键字-文章关联(使用文章和关键字的主键). I think your database design is not ideal.. You should have a table for all the articles and a table for all possible keywords. In a third table you save all keyword-article associations (using the primary key of the article and keyword).
更多推荐
基于布尔值的SQL选择
发布评论