Using the factory pattern to generate SQL's