title: Single database vs multiple databases - Microservices Architecture
body: <p>I am planning to build a project using micro-services architecture. I was curious to know which design would be better in terms of database?</p>
  <ol>
  <li>Keep a separate database for each service like in the given image</li>
  </ol>
  <p><a href="https://i.stack.imgur.com/jki5f.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jki5f.png" alt="enter image description here" /></a></p>
  <ol start="2">
  <li>Multiple applications point to 1 database.</li>
  </ol>
  <p>If I keep separate database for each service, how do we decide where to keep the mapping tables?</p>
  <p>For example, we have <strong>Customers</strong> service (separate project talking to DB 1) and <strong>Products</strong> service (separate project talking to DB 2), where should I store customer and product <strong>mapping</strong> (products bought by a customer)?</p>
  <p>How about reporting in the longer run where I would need joins over a number of tables (that are in different databases due to Architecture mentioned in point 1)?</p>