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:

  1. every employee can in 1 department , department can have many employees. (one many choice did {dep_link[fk]})
  2. each employee can in many groups , group can have many employees.
  3. 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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -