title: How to optimize queries where one app is used by multiple organisations and using the same db?
body: <p>Im experimenting with a few different technologies such as graphql, mysql. fastify and react. </p>
  
  <p>I came up with a fun app where I would have multiple organizations using the same app and the same db.
  The difference would be the url. Organisation1 would have www.myApp.com/organisation1</p>
  
  <p>Each app would hold a list of employees and each employee would have a reference to one organization at a given time but can also belong to many organizations at separate time periods(many to many relationships).</p>
  
  <p>db model: </p>
  
  <p><a href="https://i.stack.imgur.com/iPlBy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iPlBy.jpg" alt="enter image description here"></a> </p>
  
  <p><strong>Part 1:</strong> </p>
  
  <p>Let's say I want to query my db but from app1 then it would look something like this: </p>
  
  <pre><code>SELECT Name from Employee where organisationId=1
  </code></pre>
  
  <p>In another scenario, I would have application2 and then the query would look like: </p>
  
  <pre><code>SELECT Name from Employee where organisationId=2
  </code></pre>
  
  <p>How would I maintain which organization I am coming from? At the moment
  I am reading the url which is www.myApp.com/organisation1</p>
  
  <p>And depending on which organization it is I add it to the header in every request. 
  Then my backend takes the parameter and queries the db. Is this optimal? is there a better way?</p>
  
  <p><strong>Part2:</strong> </p>
  
  <p>Is there some way I could cache/set what organization I'm querying for in the mysql db so that I don't have to include the parameter in the request? again is this optimal?</p>
  
  <p>I'm trying to learn here and asking for some guidance so that I'm doing it right. </p>