Organizing models of Component

Hi, I searched for a while (using Google, because currently I cannot search through our forum - do we have that feature?), but what I found is the place to put module’s model is inside its path, no recommendation when we have many components to access it’s own database. So basically my system will have many database, and I found the instruction of how to configure models and modules to work with it’s database or global database.

What I am trying to build is a system, which has many modules, any each module has many tables to support it. But still I don’t know how to structure the model of components.

Since my system (modules and whole system) needs some shared parts which is mainly dealing with database, no form and view (only called within the system, not by users), I think I should implement these parts as components so they are easily to be accessed throughout the system, but then I don’t want to mix the models used by components with my main system models.

I hope that I can divide the models into each component accessing it, and divide components into some directory as well (but still easily to access it - please show me how to access it as well, I am a newbie here :( ).

Do you have any suggestions for my problem? Thank you very much.

So to sum up, I can illustrate my problem like this:

  1. The current system

My_system (created by yiic webapp)

[indent]config[/indent]

[indent]controllers[/indent]

[indent]components[/indent]

[indent][indent]many components here[/indent][/indent]

[indent]models[/indent]

[indent][indent]many models of system and components here[/indent][/indent]

[indent]modules[/indent]

[indent][indent]module_1 (uses a separated databased for its models - m_db1)[/indent][/indent]

[indent][indent][indent]models[/indent][/indent][/indent]

[indent][indent]module_2 (m_db2)[/indent][/indent]

[indent][indent][indent]models[/indent][/indent][/indent]

[indent][indent]module_3 (m_db3)[/indent][/indent]

[indent][indent]…module_n[/indent][/indent]

[indent]views[/indent]

[indent]…[/indent]

  1. The "ideal" system

My_system (created by yiic webapp)

[indent]config[/indent]

[indent]controllers[/indent]

[indent]components[/indent]

[indent][indent]Security.php[/indent][/indent]

[indent][indent]Privacy.php[/indent][/indent]

[indent][indent]version_control.php[/indent][/indent]

[indent][indent]Data_components[/indent][/indent]

[indent][indent][indent]data component 1 (used its own database dc1, and its mapping models are in models/component_model1/*)[/indent][/indent][/indent]

[indent][indent][indent]data component 2 (used dc2 -> models/component_model2/*)[/indent][/indent][/indent]

[indent][indent][indent]data component 3 (used dc3 -> models/component_model3/*)[/indent][/indent][/indent]

[indent]models[/indent]

[indent][indent]some php file of global models of sytem[/indent][/indent]

[indent][indent]component_model1[/indent][/indent]

[indent][indent][indent]some php files of models component 1 here[/indent][/indent][/indent]

[indent][indent]component_model2[/indent][/indent]

[indent][indent][indent]some php files of md2[/indent][/indent][/indent]

[indent][indent]component_model3[/indent][/indent]

[indent][indent][indent]some php files of md3[/indent][/indent][/indent]

[indent]modules[/indent]

[indent][indent]module_1 (uses a separated databased for its models - m_db1)[/indent][/indent]

[indent][indent][indent]models[/indent][/indent][/indent]

[indent][indent]module_2 (m_db2)[/indent][/indent]

[indent][indent][indent]models[/indent][/indent][/indent]

[indent][indent]module_3 (m_db3)[/indent][/indent]

[indent][indent]…[/indent][/indent]

[indent]views[/indent]

[indent]…[/indent]