需求: 动态增减分类(2 级),音乐可以选择 0-n 个分类,用户可以选择 0-n 个分类来筛选结果.
我现在设计的表结构为:
分类表 cate

音乐表 sound

音乐的分类表 sound_cate

想请教下这样的表结构是否合理,是否有更好的方式? 然后我该怎么查询效率较高?
我现在用的子查询来查询,但效率实在太低了.
SELECT id,title from sound
where
status=50
and
(SELECT count(id) from sound_cate where sound_id=sound.id and cate_id in (8,1,9,14))=3
order by id desc