After the migration, Ecto generated a schema. This file is responsible for identifying the fields in a way that ties in to both the database table and the Elixir struct. Now let’s take a look at the schema in web/models/video.ex:
|||schema "videos" do|
|||field :url, :string|
|||field :title, :string|
|||field :description, :string|
|||belongs_to :user, Rumbl.User|
Our schema sets up a belongs_to association, defining a :user_id field of type :integer and an association field. Our migration defines a :user_id foreign key. Ecto will use these elements to build the right association between our models.
The video module also includes a changeset ...