我在我的网站上有文章,我想添加描述每篇文章的标签,但是我遇到了设计mysql表标签的问题.我有两个想法:
因此,当我想要ID为1的文章的标签时,我会跑
SELECT ... FROM tags WHERE `article_id`=1;
Run Code Online (Sandbox Code Playgroud)
但是,我也想通过比较标签来了解3篇最相似的文章,所以如果我的文章有标签"php,mysql,erlang",还有5篇带有标签的文章:"php,mysql","erlang,ruby", "php erlang","mysql,erlang,javascript",我会选择1.,3.和4.,因为这3个标签与主文章大致相同.
还有一个问题,获得10个"最常用标签"的最佳方法是什么?
我正在尝试使用在该类中void run( string method )运行方法的方法.例如:
class Foo {
public:
void run( string method ) {
// this method calls method *method* from this class
}
void bar() {
printf( "Function bar\n" );
}
void foo2() {
printf( "Function foo2\n" );
}
}
Foo foo;
int main( void ) {
foo.run( "bar" );
foo.run( "foo2" );
}
Run Code Online (Sandbox Code Playgroud)
这将打印:
Function bar
Function foo2
Run Code Online (Sandbox Code Playgroud)
谢谢!:)