Data for Elixirs
Ecto is Elixir's database toolkit. It provides a Repo for talking to the database, schemas that map tables to structs, changesets for validating and casting data before writes, a composable query DSL and migrations. It is most often used with PostgreSQL and is not a classic ORM.
Stage: Tooling and Data · Part of the Elixir roadmap · Last reviewed 19 November 2026
What to learn in Data
- Define an Ecto schema and a migration that creates its table
- Validate and cast incoming params with a changeset before inserting
- Build queries with from, where and join and run them through the Repo
- Preload associations to avoid the N+1 query problem
- Wrap several writes in Ecto.Multi or Repo.transaction
Data interview questions
What is a changeset in Ecto?
A changeset is a struct that tracks changes to data along with validations and errors. You cast external params into allowed fields, apply validations and constraints, then pass it to Repo.insert or update. Invalid changesets never reach the database.
How do you avoid N+1 queries in Ecto?
Associations are not loaded automatically, so you use preload, either in the query with a join or as a separate batched query through Repo.preload. That fetches related rows for all parents in a fixed number of queries instead of one per parent.
Where Data fits in the Elixir roadmap
Data belongs to the Tooling and Data stage (intermediate level). Real projects.
Other units in this stage
Back to the full Elixir roadmap