Im experimenting with a few different technologies such as graphql, mysql. fastify and react.
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
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).
db model:
Part 1:
Let's say I want to query my db but from app1 then it would look something like this:
SELECT Name from Employee where organisationId=1
In another scenario, I would have application2 and then the query would look like:
SELECT Name from Employee where organisationId=2
How would I maintain which organization I am coming from? At the moment I am reading the url which is www.myApp.com/organisation1
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?
Part2:
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?
I'm trying to learn here and asking for some guidance so that I'm doing it right.