Subject Help with setting up the master-detail relationships - please
Author Daniel R. Jimenez
Hi,

I am having some problems with setting up the master-detail relationship on
IB.

I have the following tables defined:

RECREATE TABLE USERS
(
USERS_ID SMALLINT NOT NULL,
USERS_NAME VARCHAR( 50) COLLATE NONE,
USERS_PASSWORD VARCHAR( 50) COLLATE NONE,
CONSTRAINT PK_USERS PRIMARY KEY (USERS_ID)
);

RECREATE TABLE USERS_GROUP
(
UG_ID SMALLINT NOT NULL,
UG_NAME VARCHAR( 50) NOT NULL COLLATE NONE,
CONSTRAINT PK_USERS_GROUP PRIMARY KEY (UG_ID)
);

RECREATE TABLE USERS_GROUP_LINK
(
UGL_USERS_ID INTEGER NOT NULL,
UGL_UG_ID INTEGER NOT NULL,
CONSTRAINT PK_USERS_GROUP_LINK PRIMARY KEY (UGL_USERS_ID, UGL_UG_ID)
);

I have created the following SQL statement:

SELECT
USERS.USERS_NAME,
USERS.USERS_ID,
USERS_GROUP_LINK.UGL_USERS_ID,
USERS_GROUP_LINK.UGL_UG_ID
FROM
USERS_GROUP_LINK
INNER JOIN
USERS_GROUP
ON
USERS_GROUP_LINK.UGL_UG_ID = USERS_GROUP.UG_ID
RIGHT JOIN
USERS
ON
USERS_GROUP_LINK.UGL_USERS_ID = USERS.USERS_ID
WHERE
USERS_GROUP_LINK.UGL_USERS_ID IS NULL


I have a IBQuery (call it IBQMaster) which retrieves all available
USERS_GROUP records, this works fine. The application users then selects a
USERS_GROUP.

I have another IBQuery (call it IBQMember) which has as MasterSource
IBQMaster, this gets all USERS_GROUP_LINK records for the selected
USERS_GROUP.

I am trying to set up the third IBQuery (call it IBQNotMembers) to retrieve
all USERS record which are not in the USERS_GROUP_LINK (using the SQL
displayed above) based on the selected USERS_GROUP.

However, I require some help regarding the following properties of the
IBQuery, as well as any others which need to be set:

KeyLinks
MasterLinks

Thank you for your help

daniel