Multiple application using one database?

Viewed 37347

Think Design: I have many applications that share the same user database! Other tables are shared as well such as user activity logs, purchases etc

1) Anyways my question is if I was to make all applications just use 1 database for everything! Would I have any problems with scalability? Or any other problem doing this? Is it better to have 1 database ? ? Or worst?

2) Or should I just let every application have their own database, then use web service to share the common tables between the applications?

8 Answers

The way you asked the question best for you is continue "database first" approach. Use single database and mitigate issues created by the fact that there are many apps using same database:

  • Strict db schema and database constraints
  • Separate stand-alone database management, database release process
  • Consult, inform all apps/developers about schema changes, block them from changing schema
  • Encourage developers to use db transactions because their app cannot control operation integrity
  • Some may suggest moving code to database (e.g. Stored Procedures) but that's debatable
  • If things got complicated then most relational databases has schemas that provides further data separation at database level

Also the way you asked the question: You feel that something is off with this design and it's true. But it depends on the short term/long term requirements/expectations for this system and it's not provided in this question.

I use this general "rule of thumb" to make a decision: what first thing we are thinking (me or a team) when faced with a business issue we need to solve:

  • If it's tables, fields and relations - use single database and preferably single app. Grow from there later when time is right and if still needed.
  • If it's business operations, business workflows, business services - then go down that path and attach dedicated databases where needed.

No database engine or programming language can solve poorly designed system. If you do that part right the tools you choose are second priority. Do what you and your team are best at.

I know this post is old but decided to add my two cents here.

P.S. Look at DDD concept. It has a deep dive into this matter.

How about writing an application wrapper around the user database let all the other application use that service to get user information instead of a database?

Related