skyler
skyler

Reputation: 8338

Should I use a schema for my web app's tables?

I'm creating a web application backed by a PostgreSQL database. My question is, should I create a schema for all of the web app's tables, and do all work within that schema, or should I use the default, public schema?

I don't see an obvious reason to use a schema separate from public. What will I lose, and what will I gain, by not using a custom schema?

Upvotes: 3

Views: 771

Answers (1)

Daniel Lyons
Daniel Lyons

Reputation: 22803

This is one of those situations where the two options (one database with many schemas versus many databases) have differences that are so subtle it will lead to endless bikeshedding.

In my experience, most tools don't support schemas all that well so I just make separate databases. There are a number of minute technical reasons why you might want to avoid creating separate databases but the only meaningful one from a design standpoint is that unlike MySQL, cross-database querying with Postgres is not trivial. If you rely on this feature, you need to use schemas instead of separate databases. If you don't rely on this feature, you'll probably spend more effort supporting the decision to use schemas than you'll gain from having done it.

Upvotes: 3

Related Questions