I have the following statements to create my conceptual model:

EMPLOYEE belongs to one DEPARTMENT;
EMPLOYEE can work in many PROJECTs of his DEPARTMENT;
PROJECT is managed by only one DEPARTMENT;
DEPARTMENT can have many PROJECTs;

1 EMPLOYEE can work in N PROJECTs and both have to belong to the same DEPARTMENT. How can i guarantee that the EMPLOYEE and the PROJECT belongs to the same DEPARTMENT using a ternary relationship?

Making some test I found out that I can have an EMPLOYEE in a PROJECT and both aren't from the same DEPARTMENT
Example:

7A4Xs.png

As shown in the image, the second and third line from the table is allowed, but it is not valid considering that the PROJECT and the EMPLOYEE is from DEPARTMENT '1'.
The second line says that the EMPLOYEE is from DEPARTMENT 2 but it's previously define DEPARTMENT 1.
The third line says PROJECT 1 is from DEPARTMENT 2 but it is also defined to be from DEPARTMENT 1 in the first line. What do i do to solve this problem?