Pages

Sunday, October 25, 2015

Extending the database

Extending the database object So, how could we extend the database object, and the way we have designed it? Inheritance: We could have a database interface, which defines some base methods for any database object we create, making it easier to swap the type of database we use (for example, from MySQL to pgSQL, or MSSQL). Abstracting the logic to the queries: To further simplify the use of various database engines, we could abstract the logic from our queries into the database object itself. This way, instead of passing queries to the object, we pass the make up of the queries—for example, table, fields, fields to order by (to define how the results should be ordered), types of joins, and so on—and the object inserts every bit of SQL that is required. This is the only true way to have complete database abstraction within a framework. Debug information: We could add provisions for logging the performance of our queries, recording slow queries to allow us to debug, and optimize the queries we use.

No comments:

Post a Comment