You are right. That stems from another issue that I “resolved” using a trick that is not elegant at all:
For context, a warehouse can receive the instruction to release goods from 2 different sources:
- A StockTransferOrder to send Products to another warehouse
- A DeliveryNote to indicate that the Products come from an external supplier
I did not know how to manage refs from multiple tables so in the GoodsReceivedNotes table, I created 2 fields: a dropdown name SourceDocumentType and a dependant dropdown Enum that lists the IDs of the selected Document Type. In the table, GoodsReceivedNotes that number is stored as plain text.
That is why there is no physical link between the table GoodsReceivedNotes and the tables StockTransferOrders / DeliveryNotes.
Is there a more elegant way achieve that goal?
Below is a screenshot of the table GoodsReceivedNotes showing the DocumentTypeID and SourceDocumentID fields
Below are screenshots of the case of GoodsReceivedNotes from a StockTransferOrder:
Below are screenshots of the case of GoodsReceivedNotes from a PurchaseOrder:







