Saturday, April 13, 2013

Re: Proper Relations Question

I would say you need a contracts_employees table that contains the contract_id and the employee_id. When the employee logs in select all contracts with his employee number and when viewing a contract select all employees with that contract number. You don't need the employer_id in it as the employees have that field.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 13 Apr 2013, at 10:32:45, "Advantage+" <movepixels@gmail.com> wrote:

I need to properly configure this model relationship and was looking for some insight.
 
Basically :
Company hasMany Employees
Company hasMany Contracts
 
I need to allow the administrator for that Company to assign a Contract to and Employee
So Employee hasMany Contracts but the Contract <-> Company, what is the best way to relate the Contract <-> Employee in the database with relations?
 
Build a separate table employees_contracts with id, contract_id, employer_id, employee_id?
But how to link employee to contract without having a employee_id in the contract table?
 
Ideally the Employee logs in and they see the set of Contracts assigned to them, without having to actually have employee_id in the Contract table since it really belongs to the Company.
 
Any tips would be great.
 
Thanks,
 
Dave

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
--- 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate