Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
ceherr
Contributor
Contributor

Multiple databases implementation question

I was watching a video a while back where the instructor set up his SQL data access layer. He said to use an interface in case we want to change the database later. My questions are specifically why and how would you go about swapping a database being used by a set of applications?

Thoughts on why:

Usually you pick a DB that fits the situation, not the other way around. In the real world, could the situation change so drastically that you would switch from say SQL Server to Mongo DB? I am not even sure how one would transfer the existing data. I could see an API talking to both DBs but client apps using only one DB.

Thoughts on how:

Lets say you make the DAL in a library that is used by an API. Then you use unit of work + repository pattern to have a different unit for each DB. Then swapping which unit is used in a controller would be easy. But then the different databases most likely do not use the same models and the controller can only accept a model (not an interface). So do you need a separate set of controllers with endpoints for each DB?

Let me know what you think and have experienced. Thank you!

Labels (1)
  • Other

0 Replies