I am making an application in cakephp and would like your help in what would be the best way to create my database and my relationship between the models .
Would be a " workflow " .
Would it work as follows:
1 - This application will have several groups and these groups , several users .
2 - Each request would have its flow , multiple requests can have the same flow .
3 - The " admin " can create multiple workflows , with up to 5 steps between groups and individuals . example :
First aprover | second apover | third aprover user group user
4 - When the administrator chooses a group , not a specific user , someone would be drawn from this group .
5 - The approvals follow the order , ie , the next can only approve if the previous one has already approved .
I think that's basically it. Really it ta giving me so much trouble . I'm having trouble thinking of anything.
What is the tables that i have to create and they relationship?
You need tables to manage:<ol> <li>Groups, Users and user membership within the groups</li> <li>The definition of a workflow, its associated steps and the assignment of those steps to either groups or users.</li> <li>Instances of a workflow, its associated steps and the assignment of those steps to either groups or users.</li> </ol>
Note: the assigment to groups/users is populated on the step instance upon creation. This allows for the definition to be updated without overwriting the assignments on existing workflow instances.
The following shows the tables need to track what I have outlined above. This is by no means a complete model, but should be enough to get you pointed in the right direction.
<img src="https://i.stack.imgur.com/2SmPG.png" alt="Conceptual Model">
I think it is normal when building any application to go thru these issues. Making sense of Database relations and what makes sense can be tricky. What I usually do is build the basics and go from there. I usually use http://www.cakeapp.com to give me a headstart when building a CakePHP application. It allows you to build your tables and connect them to each other thru belongsTo, hasMany and hasAndBelongsToMany. After you are done, you can download your SQL file and upload it to your DB.
Just a note: Do not download the entire application as the version of Cake is outdated. Just download the SQL file. Also, constantly save your changes.