让 SQL table 条目引用同一 table 中的其他 ID 是个好主意吗?

Is it a good idea to have SQL table entries refer to other ids in the same table?

我正在为一个电子商务网站的产品类别设计 table。 table 目前看起来有点像这样:

| id |     name    | level |    value    | parent_id |
+----+-------------+-------+-------------+-----------+
| 1  | Food        |   0   | food        |    NULL   |
| 2  | Phone       |   0   | phone       |    NULL   |
| 3  | Thing       |   0   | thing       |    NULL   |
| 4  | Pasta       |   1   | pasta       |     1     |
| 5  | Apple       |   1   | apple       |     2     |
| 6  | SubThing    |   1   | subthing    |     3     |
| 7  | Tagliatelle |   2   | tagliatelle |     4     |
| 8  | iPhone 11   |   2   | iphone_11   |     5     |
| 9  | SubSubThing |   2   | subsubthing |     6     |

基本上我不想创建一个全新的 table 并在每次人们想要向类别结构添加新的子级别时映射关系,并且依赖 levelparent_id 列让我的代码知道如何处理这个类别及其父类别。我对模型设计完全陌生,这是我能想到的最好的。这种自引用结构有什么缺点是我菜鸟无法意识到的吗?

如果您确定子级别(子级)只会被该单行或父级引用,那么设计就足够了。如果多个子元素需要汇总到该父实体中,您可能 运行 会遇到问题。