Create Table-less Schemas

Learn how to create table-less schemas.

Create two schemas

We’ll create two new table-less schemas to solve our problem—one for SoloArtist and another for Band. We’ll use these schemas to collect user input and then translate them into Artist records when it’s time to store them.

First, let’s set up our new schemas.

Press + to interact
defmodule MusicDB.SoloArtist do
import Ecto.Changeset
use Ecto.Schema
embedded_schema do
field :name1, :string
field :name2, :string
field :name3, :string
field :birth_date, :date
field :death_date, :date
end
end
Press + to interact
defmodule MusicDB.Band do
import Ecto.Changeset
use Ecto.Schema
embedded_schema do
field :name, :string
field :year_started, :integer
field :year_ended, :integer
end
end

For the most part, these look quite a lot like ...