multiple tables need one to many relationship

后端 未结 5 1475
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 19:39

I have a SQL database with multiple tables: A, B, C, D. Entities in those tables are quite different things, with different columns, and different kind of relations between

5条回答
  •  星月不相逢
    2020-12-05 19:55

    You could have a single comments table and within that table have a column that contains a value differentiating which table the comment belongs to - ie a 1 in that column means it's a comment for table A, 2 for table B, and so on. If you didn't want to have "magic numbers" in the comments table, you could have another table that has just two columns: one with the number and another detailing which table the number represents.

提交回复
热议问题