title: Is it a good idea to have SQL table entries refer to other ids in the same table?
body: <p>I'm designing a table for product categories for a kinda-e-commerce site. The table currently looks a bit like this:</p>
  
  <pre><code>| 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     |
  </code></pre>
  
  <p>Basically I don't want to create a whole new table and map the relationships every time people want to add a new sub-level to the category structure, and rely on <code>level</code> and <code>parent_id</code> columns to let my code know how to do with this category and what its parent is. I'm completely new to model designing and this is the best I could come up with. Is there any downside to this self-referencing structure that I'm just too noob to realize?</p>