Are there any diagrams of what a data model of a completed project in Phoenix would look like? Something other than a directory tree structure, but more of a bubble chart?
That’s actually a really good start for me. And just so I’m clear on terminology, in Elixir/Erlang/Phoenix, are the terms Repository and Database used interchangeably and mean the same thing here?
I is “Repo” not repository. And Hex documentation for Ecto.Repo says more or less that “Repo is a database handler”. Confusing as hell if you ask me.
Basically it is a module that you hit when you want to execute some query on given database. If you will have a need to connect to 2 databases, you will need 2 repos.
“Repo” is indeed short for Repository, which, according to Wiktionary, means as much as a location for storage, often for safety or preservation
.
In the Elixir+Ecto world, the Repo is what you use to connect to an external database. But: The terms cannot be used interchangeably.
Database:
- External, somewhere not inside Elixir
- Has a lot of information: Tables, Indexes, etc.
Repo:
- Internal, configuration + DB-querying functions.
- Cares only about settings to connect to the database.
You could view this somewhat akin to a Database being a house, and a Repo being the door. You can use the door to access things in the house, but they are definitely not the same thing.
Ok, that makes a ton of sense now. Thank you for the great explanation.