mercredi 25 mars 2015

Database Schema knowledge boundaries

Im struggling to figure out where to put the knowledge about the database.


For example:


Lets say we have a database with operators of diferent enterprise and they operate in diferent states and diferent kinds of equipment. A operator can work in several states and for several companies for diferent kinds of equipment.


So to model that my db model is like:


Operator table (dni, id) Company table (name, id) Equipment table (name, id) States table (name, id)


and the relation tables


OpComEq (idOp, idComp, idEq) OpComSt (idOp, idComp, idSt)


So if we want to retrive an operator, we have to cross query. If a company tells us that a given operator no longer works with them, we have to delete all his links of this operator with this company had with states and with Equipments, and check if there is still any link with that operator (he might be working for another company etc) and if not, then delete him from the operator database.


THe problem i encounter is not knowing where to encapsulate this knowledge, inside the database class or inside the Operator class or maybe is another class.


I know this is a concrete example but is an abstract problem I bet is already solved but i cant find the design pattern for this. Can you please help me with this?


Aucun commentaire:

Enregistrer un commentaire