I have two tables: ZDEPARTMENT01
and ZEMPLOY01
.
ZDEPARTMENT01
has a foreign key DEPHEAD
, whose data element is ZPERSONNEL_NO
of domain ZPERSONNEL_NO
( NUMC, 10 ). ZEMPLOY01
has a primary key EMP_NUM
, whose data element is ZEMP_NUM
of domain ZEMP_NUM
( NUMC, 10 ).
ZDEPARTMENT01-DEPHEAD
is the foreign key and ZEMPLOY01-EMP_NUM
is the check key, and ZDEPARTMENT01-DEPHEAD
domain ZPERSONNEL_NO
has value table: ZEMPLOY01
.
While setting the check table for ZDEPARTMENT01-DEPHEAD
I got the error Check table ZEMPLOY01 has no key field with the domain ZPERSONNEL_NO of the field DEPHEAD
Even though both domains have the same datatype and length (but different domains) the system is unable to recognize the foreign key table and check table relationship.
The document says: The system attempts to assign the key fields of the check table to fields of the table with the same domain. Does it mean in addition to the datatype and the length, the domain names should be same between the foreign key table and the check table?
How to solve this?
As it already says in the message, you'll have to adjust your data elements to use the same domains:
The check table must have a key field to which the domain of the check field is assigned.
I'm not entirely sure about this, but I believe the rationale behind this is that this will prevent you from changing one of the table field definitions without changing the other one at the same time.