2
    CREATE TABLE IF NOT EXISTS `user_words` (
      `id` int(15) NOT NULL AUTO_INCREMENT,
      `user` int(15) NOT NULL,
      `word` int(15) NOT NULL,
      PRIMARY KEY (`_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

CREATE TABLE IF NOT EXISTS `words` (
      `words_id` int(15) NOT NULL AUTO_INCREMENT,
      `words_word` VARCHAR(15) NOT NULL,
      PRIMARY KEY (`words_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

我有上面的表,它当前为每个用户存储单词,所以结果可能是这样的:

1 - 1 - 1
1 - 1 - 2
1 - 1 - 3

现在字位链接到字表 word=words_id

我想知道这是最好的方法还是说有

CREATE TABLE IF NOT EXISTS `user_words` (
  `id` int(15) NOT NULL AUTO_INCREMENT,
  `user` int(15) NOT NULL,
  `word` TEXT NOT NULL,
  PRIMARY KEY (`_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

1 - 1 - 1 2 3

并使用数组在文本字段中获取 3 个结果?

4

1 回答 1

0

If you know you only have 3 words, i would just put the word in to the user tables in one or 3 extra fields and not use these tables at all.

If you need to maintain a words table, you should use this connection table that you are using. So the first one is the way to go !

于 2013-02-09T12:41:01.470 回答