Model Questions

1 message Options
Embed this post
Permalink
Joseph U.

Model Questions

Reply Threaded More More options
Print post
Permalink
I am a bit confused on how to set up models properly in certain scenarios.

Take a help desk support ticketing application.

Say
Users have a type of either customer or staff.
Tickets are created by a user (of type customer) and completed by a user (of type staff)

In my table tickets would have an id, title, description, customer_id, staff_id

How do I create a model for tickets and properly alias the table.customer_id to point to user.id and also to alias the table.staff_id to point to user.id.

To further complicate things a user will have many tickets however those tickets may be referenced by either the user.id or the staff.id depending on the type.

Why don't I just create a staff table and a customer table and just dump the whole generic user table?

Well for 2 reasons. For one the two tables contain nearly the same information. And second it would make it easier for me to have other tables that also pertain to both types of user.

For example I will want to have a comments table with each row tied to a specific ticket and to a specific user (which may be of either type). If I split users into two tables (customers and staff(s)) then I would probably need to have customer_comments and staff_comments which is some redundancy I would like to avoid. I am very new to Cake so I am sure I am probably approaching this problem the wrong way.

Thank you in advance for your help.