Specifying Data from Multiple Tables

You can use the [using TABLE(COLUMN)] clause to supply an ID in an alternate table and column without creating virtual or joined tables.

See Also
Joined Tables

You can use this clause with any statement in a Type or Relationship description in the mapping file. Whenever possible, you should use the [using TABLE(COLUMN)] clause and avoid joins.

This example shows two table definitions:

table EMP {
  EMPNO int primary;
  ENAME string;
  JOB string;}
table HIRE {
  EMPNO int primary;
  HIREDATE date;
}

You can use the using clause to get the Hire Date attribute:

type Employee {
  id EMP(EMPNO);
  name EMP(ENAME);
  attribute "Hire Date" HIRE(HIREDATE) using HIRE(EMPNO);
}

Otherwise, you could use joins. To create an object type out of the data in both tables, you could create a joined table and then refer to the joined table in a Type description as follows:

table EMPHIRE {
  join EMP,HIRE;
  where EMP.EMPNO=HIRE.EMPNO;
}
type Employee {
  id EMPHIRE(EMP.EMPNO);
  name EMP(ENAME);
  attribute "Hire Date" HIRE.HIREDATE;
}