# Enum, Joins, or Strings

**URL:** <https://forum.elixirforum.com/t/enum-joins-or-strings/23639>\
**Category:** Discussions\
**Tags:** ecto, phoenix, postgresql\
**Created:** [July 2, 2019, 6:26pm UTC](https://forum.elixirforum.com/t/enum-joins-or-strings/23639 "2019-07-02T18:26:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [July 2, 2019, 6:38pm UTC](https://forum.elixirforum.com/t/enum-joins-or-strings/23639/2 "2019-07-02T18:38:05Z")

</div>

👋

I usually go with `1.`

```elixir
# migration
create table(:car_conditions, primary_key: false) do
  add :name, :string, primary_key: true
end

flush()

Repo.insert_all("car_conditions", [
  %{name: "new"},
  %{name: "excellent"},
  # ...
])

create table(:cars) do
  # ...
  add :contidion_name,
          references(:car_conditions,
            column: :name,
            type: :string,
            on_delete: :nilify_all,
            on_update: :update_all
          ),
          default: "good"
  # ...
end

# schema
schema "cars" do
  # ...
  field :condition_name, :string # or a custom ecto type like CarCondition
  # or field :condition, :string, source: :condition_name
  # or belongs_to if you have a schema for the condition type
  # ...
end

```

> What do you all think is the best approach and why? Under what conditions would you choose one approach over another?

I think all approaches are more or less equivalent … I’ve found `1.` a bit easier to manage than enums.

---

_[View the full topic](https://forum.elixirforum.com/t/enum-joins-or-strings/23639)._
