Reputation: 103
I have 2 Tables bills and memos. 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
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
How should I keep the reference of bill table in Memos table? should I keep multiple ids in a column?
Upvotes: 0
Views: 37
Reputation: 6018
If I understood well, you got an NxM relation between bills and memos.
This is asking for a separate table with 2 foreign keys: one towards the bills and the other towards the memos.
Upvotes: 1