Multiple schemas per table

Hello, can you give me some indications for when it is advisable to use multiple schemas for the same table in Ecto?

In the Ecto.Schema documentation it is stated that “An Ecto schema is used to map any data source into an Elixir struct. One of such use cases is to map data coming from a repository, usually a table, into Elixir structs.”

In general, should I always map an sql table to a schema, or there are nice examples where multiple schemas pointing to the same table is a more logical choice?

Thank you


It might be advisable to use multiple schemas when dealing with cross boundaries associations.

Instead of crossing contexts, use 2 schemas of the same table, but with different responsabilities.

I have an example where I use 2 User schemas for the same table here…


Thank you, really helpful!