我的帖子存储在一个posts
表中,我希望每个帖子都有多个类别,存储类别及其关系的最有效方法是什么?
我首先是这样想的:
Categories Table:
+------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(32) | NO | | NULL | |
| parent | int(11) | NO | | NULL | |
+------------+---------------+------+-----+---------+----------------+
Relationships Table:
+------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+----------------+
| post_id | int(11) | NO …
Run Code Online (Sandbox Code Playgroud)