Best way to store tags in a sql server table?

前端 未结 3 600
一向
一向 2021-02-07 07:06

What\'s the best way to store tags for a record? Just use a varchar field? What about when selecting rows that contains tag x? Use the like operator?

thanks!

3条回答
  •  不要未来只要你来
    2021-02-07 07:44

    Use a tags table with the smallest allowable primary key. If there are less than 255 tags use a byte (tinyint) or else a word (smallint). The smaller the key the smaller and faster the index on the foreign key in the main table.

提交回复
热议问题