Subject Re: [IBO] Help with setting up the master-detail relationships - please
Author Lester Caine
Daniel R. Jimenez wrote:

> 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)
> );

IBQMaster =
SELECT UG_NAME, UG_ID FROM USERS_GROUP

IBQMember =
SELECT USERS_NAME, USERS_ID
FROM USERS
WHERE USERS.USERS_ID IN
( SELECT UGL_USERS_ID FROM USERS_GROUP_LINK
WHERE UGL_UG_ID = :GROUP )

IBQNotMember =
SELECT USERS_NAME, USERS_ID
FROM USERS
WHERE USERS.USERS_ID NOT IN
( SELECT UGL_USERS_ID FROM USERS_GROUP_LINK
WHERE UGL_UG_ID = :GROUP )

Keylinks are *_ID
Link second query :GROUP to UG_ID of first query MasterParamLinks ->
GROUP=UG_ID with MasterSource the IBQMaster Datasource

Just 'JOIN' any other information you need to the above basic queries

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services