[英]Referencing multiple row id from 1st table to 2nd table so that it can show all rows from the 1st table every time
I have 2 Tables bills and memos. 我有2张桌子的账单和备忘录。 Every time I generating a Memo I take the number of bills. 每次生成备忘录时,我都会拿出一些钞票。 For Example 例如
Bill Table 帐单表
+--+----------+------+------------+
|id|product_id|amount|date |
+--+----------+------+------------+
|01| 001 | 100| 26-09-2018 |
+--+----------+------+------------+
|02| 002 | 100| 28-09-2018 |
+--+----------+------+------------+
If I generate a memo on 30-09-2018 this will show data with the above 2 rows 如果我在2018年9月30日生成备忘录,将显示上面两行的数据
after generating this if I add another row in bill table, now the table will look like following 生成此表后,如果我在票据表中添加另一行,现在该表将如下所示
+--+----------+------+------------+
|id|product_id|amount|date |
+--+----------+------+------------+
|01| 001 | 100| 26-09-2018 |
+--+----------+------+------------+
|02| 002 | 100| 28-09-2018 |
+--+----------+------+------------+
|03| 001 | 100| 01-10-2018 |
+--+----------+------+------------+
If I generate a memo this will show memo with all 3 rows 如果我生成备忘录,它将显示所有3行的备忘录
How should I keep the reference of bill table in Memos table? 我应该如何在Memos表中保留票据表的参考? should I keep multiple ids in a column? 我应该在一列中保留多个ID吗?
If I understood well, you got an NxM relation between bills and memos. 如果我了解得很好,您在帐单和便笺之间就会有NxM关系。
This is asking for a separate table with 2 foreign keys: one towards the bills and the other towards the memos. 这要求一个单独的表,该表带有2个外键:一个指向帐单,另一个指向备忘录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.