I'm currently working on a project that requires using a database. This system may be required to use an SQL database in the future, but for now we are using Google Spreadsheets via API because we need to access the data quickly, easily and for free. My question is: Should we create a DB API in case we change the database backend? As I said in the future is possible that we use SQL, so I was thinking about using and API to change just the DB server, and not the whole app.How you do this? Do you create an API once and use it while the DB server changes? Do you change the whole app when you need a different DB?Thanks!
Create database API to allow backend portability
database;web applications;api design
Use a Database-Abstraction-Layer (DBAL). Running SQL against a Google Spreadsheet will not be easy; so you should put your abstraction further up the hierarchy.I'd suggest the Repository pattern. Create implementations that work with the Spreadsheet API. When you later switch to a SQL server, create implementations that utilize an O/RM.