views:

47

answers:

1

Background

I'm sketching on an application that needs to perform something like this

database a >--|                          |--> fileformat 1
database b >--+--> custom application >--+--> fileformat 2
...           |                          |    ...
database n >--|                          |--> fileformat n

The databases in question are all of the same type but with different tables and structure. The objects that are to be loaded are all products of some type. The files have similar structure but not necessarily the same, some are xml, some are csv etc.

The custom application is here to ensure a consistent interface for manipulating the objects retrieved from the relational data. It is a simple web application with a few options on each product and a paginated display of the products. It adds additional data to each record that is persisted through the means of an ORM.

Only one database will be active in each instance of the application, however many fileformats can be active. The writing of these files are simultaneous.

Question

I've been struggling with finding the best approach for designing the conversion steps.

Is there a pattern that somehow manages to combine the different schemas into one single Model? There is the assumption here that only the fields that are present in all of the databases are supposed to end up in the model.

And what about the reverse? When the product objects are to be written to file?

I've looked at different patterns such as the Strategy pattern, but i'm still not having that moment where all the bits and pieces seem to fall into place.

For what it's worth the application itself will most likely be written in PHP.

+1  A: 

This would be my approach:

Each DB would have a view on it that would present the needed data to your app.

Your app would have a layer that would read the data and reformulate it into a (fairly standard) data structure.

Then you would have a layer that would read those standard data structures and write out to the requested files.

Paul Nathan