【发布时间】:2012-02-13 04:33:26
【问题描述】:
我有 2 个表:products 和 categories。每个品类有很多产品,一个产品可以属于很多品类。
产品
product_id - int primary auto increment
name - unique
etc.
类别
category_id - int primary auto increment
name - unique
etc.
我有第三张桌子用于许多关系。
products_categories
product_id -> foreign key: products.product_id
category_id -> foreign key: category.category_id
我的问题是:我是否应该在 product_categories 中为 product_id 和 category_id 创建索引以便更快地进行选择查询,如果是,哪些索引?
谢谢
【问题讨论】:
标签: mysql indexing foreign-keys