12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Container-Managed Persistence in <strong>Borland</strong> Enterprise Server<br />

CASE 3: a many-tomany<br />

relationship.<br />

We're not quite done with our relationship, though. Now, we need to complete it by<br />

specifying the relationship role for the other direction:<br />

<br />

<br />

Customer<br />

<br />

<br />

customers<br />

<br />

<br />

ORDER<br />

<br />

CUSTOMER_NO<br />

<br />

<br />

<br />

CUSTOMER<br />

<br />

CUSTOMER_NO<br />

<br />

<br />

<br />

<br />

<br />

<br />

.<br />

.<br />

<br />

If you define a many-to-many relationship, you must also have the CMP engine create<br />

a cross-table which models a relationship between the left table and the right table. Do<br />

this using the element, whose XML is:<br />

<br />

You may name this cross-table whatever you like using the element. The<br />

two elements correspond to columns in the left and right tables whose<br />

relationship you wish to model. For example, consider two tables, EMPLOYEE and<br />

PROJECT, which have a many-to-many relationship. An employee can be a part of<br />

multiple projects, and projects have multiple employees. The EMPLOYEE table has three<br />

elements, an employee number (EMP_NO), a last name (LAST_NAME), and a project ID<br />

number (PROJ_ID). The PROJECT table contains columns for the project ID number<br />

(PROJ_ID), the project name (PROJ_NAME), and assigned employees by number (EMP_NO).<br />

138 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!