Heading image for post: Embrace the Database with Ecto

Elixir PostgreSQL

Embrace the Database with Ecto

Profile picture of Josh Branchaud

The database is a hugely important, and often times underappreciated, part of the development stack we use to build most web applications.

Web frameworks, such as Ruby on Rails, and their database adapter layers can sometimes lull us into a false understanding of the world. They leave us so far removed from the actual database that we sometimes forget it is even there. It becomes a mysterious black box that we can shovel data into and then ask very rigid standard questions to get that data back out. When we treat the database in this way -- as a dumb data store -- we miss out on all it has to offer. However, if we seek to understand the database and how to fully utilize it, we can harness guarantees about the correctness of our data, build a solid data model, and write expressive, powerful, and highly performant queries.

The Elixir community has built Ecto, a tool and DSL for interacting with database engines like PostgreSQL. Unlike many adapters and ORMs, Ecto encourages us to understand the queries we write and to take advantage of many features a database engine like PostgreSQL has to offer.

I recently spoke at both ElixirDaze (in St. Augustine, FL) and Rome Erlang Factory Lite. I presented on these concepts showing how Ecto makes it easy to constrain our data, query like we would with SQL, and pull in the SQL and PostgreSQL-specific features that we depend on.

This topic is important to me because poorly modeled and ill-constrained database schemas are dangerous. They can dictate poor design and defensive coding throughout our application. Once it is allowed into production, this technical debt becomes extremely hard to manage and fix. And in some cases, it can mean incomplete or incorrect data. Ecto encourages and empowers us to address these things head-on early in the development of our web applications.

If you'd like to know more of the specifics, check out the recording of my talk at ElixirDaze. Also, feel free to follow along with the slides.


You ought to come away from this talk with a renewed appreciation for what the database can do for you. I hope it also piques your interest around Elixir and Ecto. Enjoy!

More posts about Elixir ecto PostgreSQL

  • Adobe logo
  • Barnes and noble logo
  • Aetna logo
  • Vanderbilt university logo
  • Ericsson logo

We're proud to have launched hundreds of products for clients such as LensRentals.com, Engine Yard, Verisign, ParkWhiz, and Regions Bank, to name a few.

Let's talk about your project