I wonder what the most efficient x practical strategy for foreign key functionality is for a traditional Owner has_one Item relationship in an Append-only Log scheme with Ecto.
Would it be to go with the distributed system method, and use UUID across every related row with no explicit foreign keys? e.g., Owner.entry_id === Item.entry_id for the Item owned by that Owner, with no :owner_entry_id or references() in Item's migration?
Or would it be worth saving space by going with a foreign key of id (e.g., owner_id) on an Item, and when querying the association, selecting an Item's Owner by owner_id then selecting the newest entry with that owner's entry_id?
I see in the migrations for this repo, a standard references() is used:
create table(:items) do
add(:name, :string)
add(:entry_id, :string)
add(:deleted, :boolean, default: false)
add(:owner, references(:users))
timestamps()
end
Interested in any thoughts about this in the context of the current UUID implementation of Alog
I wonder what the most efficient x practical strategy for foreign key functionality is for a traditional Owner has_one Item relationship in an Append-only Log scheme with Ecto.
Would it be to go with the distributed system method, and use UUID across every related row with no explicit foreign keys? e.g.,
Owner.entry_id === Item.entry_idfor the Item owned by that Owner, with no:owner_entry_idorreferences()in Item's migration?Or would it be worth saving space by going with a foreign key of id (e.g., owner_id) on an Item, and when querying the association, selecting an Item's Owner by owner_id then selecting the newest entry with that owner's entry_id?
I see in the migrations for this repo, a standard
references()is used:Interested in any thoughts about this in the context of the current UUID implementation of Alog