On Jun 15, 2005, at 7:20 PM, Rams wrote:
On Jun 15, 2005, at 4:24 PM, Sacha Mallais wrote:
On Jun 15, 2005, at 12:55 PM, Rams wrote:
Is it possible to create one WO app and have it access different databases based on the client? For instance, I would like to create a point of sale (POS) app. Different clients have different inventory requirements and would obviously like their own database. Someone selling stationary needs different inventory information than someone selling pets, automobiles, clothing, or whatever.
The difficulty is having multiple databases' tables map to the entities in a single model. WO don't play dat.
So if I understand correctly, I cannot programmatically change the database address of my EOModel within a WO app. It must be done with EOModeler or XCode.
That is NOT correct, it's actually very simple. In fact, in every app I write, I change the database address programmatically as the application starts up. (I keep the EOModeler-defined model pointed at the development instance, and specify the location of the test and deployment instances in a resource file.) But you need to point to the database of your choice before you start fetching objects, for obvious reasons. As long as the schemas are the same, the app won't know the difference. However, you could certainly do this after some interaction with the user, such as a login, if necessary. Ideally, I'd like the client to be able to dictate what inventory information they would like to store and then be assigned their own database for inventory without much intervention on my part. Is there any way to do this with WO?
The catch is "assigned their own database". The rest is easily possible within a single application.
If you must force WO to dynamically create databases and EOModels that models those databases, then you might look at dynamically creating EOModels and EOEntities (perhaps subentities of existing, abstract entities).
sacha
So I can dynamically generate a database table within the app? Any pointers on where to start? (sample code, examples, reference material or API docs)
You can easily alter the model from within the app (for instance, it's not uncommon to to add an EORelationship dynamically), but actually creating new tables is another matter. Have you considered having all of the data in one set of tables, but adding a "client id" field to the relevant tables and filtering on that?
Regards, Mark |