Foreign key strategy in Ecto for has_ relationships of ALog schemas?
- Dominant language
- Elixir
- Stars
- 15
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
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:
```elixir
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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.