abloom12
abloom12

Reputation: 25

Should I make a separate database for each application?

I’m building two applications that need to share some similar data but each will also have unique data. Should I build a separate database for each app or let each app access the same database.

I need the shared data to update automatically on one app if it is changed in another. I’m also using postgresql with react and express with the intent of having both apps be progressive web apps and eventually react native apps.

Upvotes: 0

Views: 1294

Answers (3)

Gordon Linoff
Gordon Linoff

Reputation: 1269693

In general, I would think of this as:

  • Databases are the unit of backup and recovery.
  • Databases can contain multiple schemas ("schemata" ?) which are the unit for managing users and objects.

Based on your question:

I need the shared data to update automatically on one app if it is changed in another.

It sounds like you want one database and separate schemas for each application.

Upvotes: 1

Koushik Roy
Koushik Roy

Reputation: 7387

Both has pros and cons. But i think keeping them separate will be better. Pro for one can be con for other.
Pros -

  • separate DB makes maintenance better,faster and easy.
  • performance wise separate DB is better.
  • Migrations of code will be easy.

Cons -

  • Auto synchup can be tricky if tables etc. are different.
  • If one process need to use tables from both DB, it will be an issue.

Upvotes: 0

user330315
user330315

Reputation:

It sounds as if you will need to join the database from both applications in a single SQL query. In that case, use one database and multiple schemas to separate the data.

You could have one schema common that contains the data which is shared between all applications and then one schema per application.

Upvotes: 1

Related Questions