php - Employees and departments with groups database schema advice -
what got is
tables:
employee {id, name, phone, dep_link[fk]} department {id, name} groups {id, name} employees_groups {id, emp_id_link[fk] ,group_id_link[fk]} departments_groups {id, dep_id_link[fk], group_id_link[fk]}
logic:
- every employee can in 1 department , department can have many employees. (one many choice did
{dep_link[fk]}
) - each employee can in many groups , group can have many employees.
- each department can in many groups , group can have many departments.
is did tables , relations right? have 2 departments (it,archives) part of group (all). after add relation in departments_groups table how can retrieve employees of these departments?
for example got 2 departments (it,archives) part of group (all) after add relation in departments_groups table how can retrieve employees of these departments ?
select * employee employee.dep_link in (select dep_id_link departments_group inner join groups on groups.id = group_id_link , groups.name = 'all')
Comments
Post a Comment