How to do polymorphic relationships, but with only 1 table?
Apologies if this has been answered before, but I couldn't find it in the search function.
I want to create a table called
transactions
with the following columns:
I know there is documentation regarding polymorphic resources in Ash, but it uses multiple tables to create the relationship.
My intention with the transactions table is to be able to do various combinations of source_type
and destination_type
, so I don't think having multiple tables is a good solution.
How can I do this in Ash?3 Replies
So you can do this, but (just like in any other set of tooling) its not necessarily going to be easy
The way that you do it is with calculations that produce union types
but keep in mind, this design pattern means you can't have foreign keys
Assuming
destination_id
could point at one of many tablesThanks! Looks like I have to give it some more thought then
I'd recommend doing it as multiple tables also - foreign keys are very nice to have 🙂