Creating a single context index on a one-to-many and lookup table

Hello,
I've been successfully setting up text indexes on multiple columns on the same table (using MULTI_COLUMN_DATASTORE preferences), but now I have a situation with a one-to-many data collection table (with a FK to a lookup table), and I need to search columns across both of these tables. Sample code below, more of my chattering after the code block:
CREATE TABLE SUBMISSION
( SUBMISSION_ID             NUMBER(10)          NOT NULL,
  SUBMISSION_NAME           VARCHAR2(100)       NOT NULL
CREATE TABLE ADVISOR_TYPE
( ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
  ADVISOR_TYPE_NAME         VARCHAR2(50)        NOT NULL
CREATE TABLE SUBMISSION_ADVISORS
( SUBMISSION_ADVISORS_ID    NUMBER(10)          NOT NULL,
  SUBMISSION_ID             NUMBER(10)          NOT NULL,
  ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
  FIRST_NAME                VARCHAR(50)         NULL,
  LAST_NAME                 VARCHAR(50)         NULL,
  SUFFIX                    VARCHAR(20)         NULL
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (1, 'Some Research Paper');
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (2, 'Thesis on 17th Century Weather Patterns');
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (3, 'Statistical Analysis on Sunny Days in March');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (1, 'Department Chair');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (2, 'Department Co-Chair');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (3, 'Professor');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (4, 'Associate Professor');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (5, 'Scientist');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (1,1,2,'John', 'Doe', 'PhD');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (2,1,2,'Jane', 'Doe', 'PhD');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (3,2,3,'Johan', 'Smith', NULL);
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (4,2,4,'Magnus', 'Jackson', 'MS');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (5,3,5,'Williard', 'Forsberg', 'AMS');
COMMIT;I want to be able to create a text index to lump these fields together:
SUBMISSION_ADVISORS.FIRST_NAME
SUBMISSION_ADVISORS.LAST_NAME
SUBMISSION_ADVISORS.SUFFIX
ADVISOR_TYPE.ADVISOR_TYPE_NAME
I've looked at DETAIL_DATASTORE and USER_DATASTORE, but the examples in Oracle Docs for DETAIL_DATASTORE leave me a little bit perplexed. It seems like this should be pretty straightforward.
Ideally, I'm trying to avoid creating new columns, and keeping the trigger adjustments to a minimum. But I'm open to any and all suggestions. Thanks for for your time and thoughts.
-Jamie

I would create a procedure that creates a virtual document with tags, which is what the multi_column_datatstore does behind the scenes. Then I would use that procedure in a user_datastore, so the result is the same for multiple tables as what a multi_column_datastore does for one table. I would also use either auto_section_group or some other type of section group, so that you can search using WITHIN as with the multi_column_datastore. Please see the demonstration below.
SCOTT@orcl_11gR2> -- tables and data that you provided:
SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION
  2  ( SUBMISSION_ID           NUMBER(10)          NOT NULL,
  3    SUBMISSION_NAME           VARCHAR2(100)          NOT NULL
  4  )
  5  /
Table created.
SCOTT@orcl_11gR2> CREATE TABLE ADVISOR_TYPE
  2  ( ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
  3    ADVISOR_TYPE_NAME      VARCHAR2(50)          NOT NULL
  4  )
  5  /
Table created.
SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION_ADVISORS
  2  ( SUBMISSION_ADVISORS_ID      NUMBER(10)          NOT NULL,
  3    SUBMISSION_ID           NUMBER(10)          NOT NULL,
  4    ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
  5    FIRST_NAME           VARCHAR(50)          NULL,
  6    LAST_NAME           VARCHAR(50)          NULL,
  7    SUFFIX                VARCHAR(20)          NULL
  8  )
  9  /
Table created.
SCOTT@orcl_11gR2> INSERT ALL
  2  INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
  3    VALUES (1, 'Some Research Paper')
  4  INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
  5    VALUES (2, 'Thesis on 17th Century Weather Patterns')
  6  INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
  7    VALUES (3, 'Statistical Analysis on Sunny Days in March')
  8  SELECT * FROM DUAL
  9  /
3 rows created.
SCOTT@orcl_11gR2> INSERT ALL
  2  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
  3    VALUES (1, 'Department Chair')
  4  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
  5    VALUES (2, 'Department Co-Chair')
  6  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
  7    VALUES (3, 'Professor')
  8  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
  9    VALUES (4, 'Associate Professor')
10  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
11    VALUES (5, 'Scientist')
12  SELECT * FROM DUAL
13  /
5 rows created.
SCOTT@orcl_11gR2> INSERT ALL
  2  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
  3    VALUES (1,1,2,'John', 'Doe', 'PhD')
  4  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
  5    VALUES (2,1,2,'Jane', 'Doe', 'PhD')
  6  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
  7    VALUES (3,2,3,'Johan', 'Smith', NULL)
  8  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
  9    VALUES (4,2,4,'Magnus', 'Jackson', 'MS')
10  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
11    VALUES (5,3,5,'Williard', 'Forsberg', 'AMS')
12  SELECT * FROM DUAL
13  /
5 rows created.
SCOTT@orcl_11gR2> -- constraints presumed based on your description:
SCOTT@orcl_11gR2> ALTER TABLE submission ADD CONSTRAINT submission_id_pk
  2    PRIMARY KEY (submission_id)
  3  /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE advisor_type ADD CONSTRAINT advisor_type_id_pk
  2    PRIMARY KEY (advisor_type_id)
  3  /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_advisors_id_pk
  2    PRIMARY KEY (submission_advisors_id)
  3  /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_id_fk
  2    FOREIGN KEY (submission_id) REFERENCES submission (submission_id)
  3  /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT advisor_type_id_fk
  2    FOREIGN KEY (advisor_type_id) REFERENCES advisor_type (advisor_type_id)
  3  /
Table altered.
SCOTT@orcl_11gR2> -- resulting data:
SCOTT@orcl_11gR2> COLUMN submission_name FORMAT A45
SCOTT@orcl_11gR2> COLUMN advisor      FORMAT A40
SCOTT@orcl_11gR2> SELECT s.submission_name,
  2           a.advisor_type_name || ' ' ||
  3           sa.first_name || ' ' ||
  4           sa.last_name || ' ' ||
  5           sa.suffix AS advisor
  6  FROM   submission_advisors sa,
  7           submission s,
  8           advisor_type a
  9  WHERE  sa.advisor_type_id = a.advisor_type_id
10  AND    sa.submission_id = s.submission_id
11  /
SUBMISSION_NAME                               ADVISOR
Some Research Paper                           Department Co-Chair John Doe PhD
Some Research Paper                           Department Co-Chair Jane Doe PhD
Thesis on 17th Century Weather Patterns       Professor Johan Smith
Thesis on 17th Century Weather Patterns       Associate Professor Magnus Jackson MS
Statistical Analysis on Sunny Days in March   Scientist Williard Forsberg AMS
5 rows selected.
SCOTT@orcl_11gR2> -- procedure to create virtual documents:
SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE submission_advisors_proc
  2    (p_rowid IN           ROWID,
  3       p_clob     IN OUT NOCOPY CLOB)
  4  AS
  5  BEGIN
  6    FOR r1 IN
  7        (SELECT *
  8         FROM      submission_advisors
  9         WHERE  ROWID = p_rowid)
10    LOOP
11        IF r1.first_name IS NOT NULL THEN
12          DBMS_LOB.WRITEAPPEND (p_clob, 12, '<first_name>');
13          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.first_name), r1.first_name);
14          DBMS_LOB.WRITEAPPEND (p_clob, 13, '</first_name>');
15        END IF;
16        IF r1.last_name IS NOT NULL THEN
17          DBMS_LOB.WRITEAPPEND (p_clob, 11, '<last_name>');
18          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.last_name), r1.last_name);
19          DBMS_LOB.WRITEAPPEND (p_clob, 12, '</last_name>');
20        END IF;
21        IF r1.suffix IS NOT NULL THEN
22          DBMS_LOB.WRITEAPPEND (p_clob, 8, '<suffix>');
23          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.suffix), r1.suffix);
24          DBMS_LOB.WRITEAPPEND (p_clob, 9, '</suffix>');
25        END IF;
26        FOR r2 IN
27          (SELECT *
28           FROM   submission
29           WHERE  submission_id = r1.submission_id)
30        LOOP
31          DBMS_LOB.WRITEAPPEND (p_clob, 17, '<submission_name>');
32          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r2.submission_name), r2.submission_name);
33          DBMS_LOB.WRITEAPPEND (p_clob, 18, '</submission_name>');
34        END LOOP;
35        FOR r3 IN
36          (SELECT *
37           FROM   advisor_type
38           WHERE  advisor_type_id = r1.advisor_type_id)
39        LOOP
40          DBMS_LOB.WRITEAPPEND (p_clob, 19, '<advisor_type_name>');
41          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r3.advisor_type_name), r3.advisor_type_name);
42          DBMS_LOB.WRITEAPPEND (p_clob, 20, '</advisor_type_name>');
43        END LOOP;
44    END LOOP;
45  END submission_advisors_proc;
46  /
Procedure created.
SCOTT@orcl_11gR2> SHOW ERRORS
No errors.
SCOTT@orcl_11gR2> -- examples of virtual documents that procedure creates:
SCOTT@orcl_11gR2> DECLARE
  2    v_clob  CLOB := EMPTY_CLOB();
  3  BEGIN
  4    FOR r IN
  5        (SELECT ROWID rid FROM submission_advisors)
  6    LOOP
  7        DBMS_LOB.CREATETEMPORARY (v_clob, TRUE);
  8        submission_advisors_proc (r.rid, v_clob);
  9        DBMS_OUTPUT.PUT_LINE (v_clob);
10        DBMS_LOB.FREETEMPORARY (v_clob);
11    END LOOP;
12  END;
13  /
<first_name>John</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
<first_name>Jane</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
<first_name>Johan</first_name><last_name>Smith</last_name><submission_name>Thesis on 17th Century
Weather Patterns</submission_name><advisor_type_name>Professor</advisor_type_name>
<first_name>Magnus</first_name><last_name>Jackson</last_name><suffix>MS</suffix><submission_name>The
sis on 17th Century Weather Patterns</submission_name><advisor_type_name>Associate
Professor</advisor_type_name>
<first_name>Williard</first_name><last_name>Forsberg</last_name><suffix>AMS</suffix><submission_name
Statistical Analysis on Sunny Days inMarch</submission_name><advisor_type_name>Scientist</advisor_type_name>
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- user_datastore that uses procedure:
SCOTT@orcl_11gR2> BEGIN
  2    CTX_DDL.CREATE_PREFERENCE ('sa_datastore', 'USER_DATASTORE');
  3    CTX_DDL.SET_ATTRIBUTE ('sa_datastore', 'PROCEDURE', 'submission_advisors_proc');
  4  END;
  5  /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- index (on optional extra column) that uses user_datastore and section group:
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD (any_column VARCHAR2(1))
  2  /
Table altered.
SCOTT@orcl_11gR2> CREATE INDEX submission_advisors_idx
  2  ON submission_advisors (any_column)
  3  INDEXTYPE IS CTXSYS.CONTEXT
  4  PARAMETERS
  5    ('DATASTORE     sa_datastore
  6        SECTION GROUP     CTXSYS.AUTO_SECTION_GROUP')
  7  /
Index created.
SCOTT@orcl_11gR2> -- what is tokenized, indexed, and searchable:
SCOTT@orcl_11gR2> SELECT token_text FROM dr$submission_advisors_idx$i
  2  /
TOKEN_TEXT
17TH
ADVISOR_TYPE_NAME
AMS
ANALYSIS
ASSOCIATE
CENTURY
CHAIR
CO
DAYS
DEPARTMENT
DOE
FIRST_NAME
FORSBERG
JACKSON
JANE
JOHAN
JOHN
LAST_NAME
MAGNUS
MARCH
PAPER
PATTERNS
PHD
PROFESSOR
RESEARCH
SCIENTIST
SMITH
STATISTICAL
SUBMISSION_NAME
SUFFIX
SUNNY
THESIS
WEATHER
WILLIARD
34 rows selected.
SCOTT@orcl_11gR2> -- sample searches across all data:
SCOTT@orcl_11gR2> VARIABLE search_string VARCHAR2(100)
SCOTT@orcl_11gR2> EXEC :search_string := 'professor'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
  2           a.advisor_type_name || ' ' ||
  3           sa.first_name || ' ' ||
  4           sa.last_name || ' ' ||
  5           sa.suffix AS advisor
  6  FROM   submission_advisors sa,
  7           submission s,
  8           advisor_type a
  9  WHERE  CONTAINS (sa.any_column, :search_string) > 0
10  AND    sa.advisor_type_id = a.advisor_type_id
11  AND    sa.submission_id = s.submission_id
12  /
SUBMISSION_NAME                               ADVISOR
Thesis on 17th Century Weather Patterns       Professor Johan Smith
Thesis on 17th Century Weather Patterns       Associate Professor Magnus Jackson MS
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'doe'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
SUBMISSION_NAME                               ADVISOR
Some Research Paper                           Department Co-Chair John Doe PhD
Some Research Paper                           Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'paper'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
SUBMISSION_NAME                               ADVISOR
Some Research Paper                           Department Co-Chair John Doe PhD
Some Research Paper                           Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> -- sample searches within specific columns:
SCOTT@orcl_11gR2> EXEC :search_string := 'chair'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
  2           a.advisor_type_name || ' ' ||
  3           sa.first_name || ' ' ||
  4           sa.last_name || ' ' ||
  5           sa.suffix AS advisor
  6  FROM   submission_advisors sa,
  7           submission s,
  8           advisor_type a
  9  WHERE  CONTAINS (sa.any_column, :search_string || ' WITHIN advisor_type_name') > 0
10  AND    sa.advisor_type_id = a.advisor_type_id
11  AND    sa.submission_id = s.submission_id
12  /
SUBMISSION_NAME                               ADVISOR
Some Research Paper                           Department Co-Chair John Doe PhD
Some Research Paper                           Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'phd'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
  2           a.advisor_type_name || ' ' ||
  3           sa.first_name || ' ' ||
  4           sa.last_name || ' ' ||
  5           sa.suffix AS advisor
  6  FROM   submission_advisors sa,
  7           submission s,
  8           advisor_type a
  9  WHERE  CONTAINS (sa.any_column, :search_string || ' WITHIN suffix') > 0
10  AND    sa.advisor_type_id = a.advisor_type_id
11  AND    sa.submission_id = s.submission_id
12  /
SUBMISSION_NAME                               ADVISOR
Some Research Paper                           Department Co-Chair John Doe PhD
Some Research Paper                           Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'weather'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
  2           a.advisor_type_name || ' ' ||
  3           sa.first_name || ' ' ||
  4           sa.last_name || ' ' ||
  5           sa.suffix AS advisor
  6  FROM   submission_advisors sa,
  7           submission s,
  8           advisor_type a
  9  WHERE  CONTAINS (sa.any_column, :search_string || ' WITHIN submission_name') > 0
10  AND    sa.advisor_type_id = a.advisor_type_id
11  AND    sa.submission_id = s.submission_id
12  /
SUBMISSION_NAME                               ADVISOR
Thesis on 17th Century Weather Patterns       Professor Johan Smith
Thesis on 17th Century Weather Patterns       Associate Professor Magnus Jackson MS
2 rows selected.

Similar Messages

  • Import of Main and Lookup table in a single Map

    Hey Guys,
    I am developing a Proof of Concept to Import Main and Lookup-Flat in a single Import Map (by using a single excel file).
    Below is my Table structure:
    Main Table: Customer
    --->Customer_Number (Text,Unique Field, Display Field)
    --->Sales_Area (Lookup Flat)
    Lookup Table: Sales_Area
    Sales_Area_ID (Text,Unique Field,Display Field)
    Sales_Area_Desc (Text,Display Field).
    The import File (excel) has below attributes:
    Customer_Number,Sales_Area_ID,Sales_Area_Desc.
    When i start both Main Table and Lookup tables are empty (there is no data in Data Manager for either of the tables)
    Now in the Import Map, i selected source as the excel file and target as the Main table.
    I did mapping of Customer_Number as usual after that I created a compound field for Sales_Area_ID+ Sales_Area_Desc and did the mapping of this compound field. then did the mapping for Sales_Area_ID and Sales_Area_Desc.
    Now since there is no data in lookup table, i select the "Add" button in the "Value Mapping" section. when i execute this map, it works perfectly and data is loaded in both the Main table and lookup table but if a new value comes in the excel(a value which does not yet exist in lookup table), the map fails, when i open it , it says that i need to redo the Value Mapping, again i click on "Add" button and it starts working. So basically the Import Map fails whenever i get a value in excel which does not yet exist in Lookup table.
    Now my question is, is there a way to automate my import map, i thought clicking on "Add" button will take care of all the lookup values which are not already present.
    Can anyone please help me in this regard.
    Thanks
    Saif

    Hi Saif,
    You can try the following option.
    Right click on the lookup filed/compound filed in destination fields, and select the option 'SET MDIS Unmapped Value Handling' as 'ADD'.
    Cheers,
    Cherry.

  • Unidirectional one-to-many with join table

    According to http://docs.jboss.org/hibernate/orm/3.5/reference/en-US/html/associations.html#assoc-unidirectional-12m "A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended", instead they recommend using a join table, e.g.
    create table Person ( personId bigint not null primary key )
    create table PersonAddress ( personId not null, addressId bigint not null primary key )
    create table Address ( addressId bigint not null primary key )
    However if doing this, when using SQLDeveloper the Address table does not appear as a child table of Person, which it should be as a unidirectional one-to-many meaning that I can't create a cache group for Person and subsequently Person.
    Is this something that can be worked around as I'm using a legacy schema created from Hibernate/JPA and the implications of changing are quite substantial?
    Thanks

    Hi Gennady,
    Apologies but my question was not clear enough. The schema structure that I have inherited is as follows:
    CREATE TABLE T_PERSON ( PERSONID NUMBER PRIMARY KEY, PERSONFIRSTNAME VARCHAR2(20), PERSONLASTNAME VARCHAR2(20) );
    CREATE TABLE T_PERSONADDRESS (PERSONID NUMBER NOT NULL, ADDRESSID NUMBER NOT NULL PRIMARY KEY );
    CREATE TABLE T_ADDRESS ( ADDRESSID NUMBER  PRIMARY KEY, ADDRESSTEXT VARCHAR2(200) );
    ALTER TABLE T_PERSONADDRESS ADD CONSTRAINT FK_PERSON_ADDR_PERSON_ID FOREIGN KEY (PERSONID) REFERENCES T_PERSON(PERSONID);
    ALTER TABLE T_PERSONADDRESS ADD CONSTRAINT FK_PERSON_ADDR_ADDR_ID FOREIGN KEY (ADDRESSID) REFERENCES T_ADDRESS(ADDRESSID);This is implementing a unidirectional one-to-many relationship between T_PERSON and T_ADDRESS according to the Hibernate and JPA recommendation. As far as I can see most schema designers would do this using by adding a column "PERSON_ID" (and associated FK) on the T_ADDRESS table and therefore not needing the T_PERSONADDRESS table.
    This being what it is, I would then like to create a cache-group as follows:
    CREATE READONLY CACHE GROUP "CACHEGROUPADDRESSES"
    AUTOREFRESH MODE INCREMENTAL INTERVAL 5 MINUTES
    STATE PAUSED
    FROM
      "SCHEMA1"."T_PERSON" (
        "PERSONID"        NUMBER            NOT NULL,
        "PERSONFIRSTNAME" VARCHAR2(20 BYTE),
        "PERSONLASTNAME"  VARCHAR2(20 BYTE),
        PRIMARY KEY("PERSONID")
      "SCHEMA1"."T_ADDRESS" (
        "ADDRESSID" NUMBER NOT NULL,
        "ADDRESSTEXT" VARCHAR2(20 BYTE),
        PRIMARY KEY("ADDRESSID")
      "SCHEMA1"."T_PERSONADDRESS" (
        "PERSONID"  NUMBER NOT NULL,
        "ADDRESSID" NUMBER NOT NULL,
        PRIMARY KEY("ADDRESSID"),
        FOREIGN KEY("PERSONID")
          REFERENCES "SCHEMA1"."T_PERSON"("PERSONID"),
        FOREIGN KEY("ADDRESSID")
          REFERENCES "SCHEMA1"."T_ADDRESS"("ADDRESSID")
      )This however gives me the error "TT8222: Multiple parent tables found" because TimesTen has failed to identify the one-to-many-using-link-table pattern.
    Without a schema re-write is there anything that I can do, alternatively will this be looked at for a future release of TimesTen?
    Edited by: TrisStev on Apr 16, 2012 10:37 AM

  • Select with One-to-Many and Many-to-One without repeating

    Hi
    I have a customer who needs a report two sides left and right, but allowing for One-to-Many and Many-to-One relationships in the one report.
    A little background:-
    This has do do with listings on land and buildings.
    One building can be built on a few pieces of land.
    Similarly, there can be several buildings on one piece of land.
    What is required is a listing of buildings on the left, land on the right, but without repeating the "single line entries" either left or right.
    For example Building1 is on Land1 and Land2, and Building2 and Building3 are built on Land3.
    We need:-
    Building1 Land1
    ________Land2
    Building2 Land3
    Building3______
    The ___ just used for spacing so you get the idea ;)
    Essentially - a "break by" on columns on the left and right.
    The Buildings and Land are in different tables, with a link table - one row for each link.
    Any ideas?
    Thanks
    Mike

    To jitu.jk - first, this is not in SQL*Plus - its a report in APEX - second, I see no way to break on the left and the right in the same select.
    Maybe there is a way.
    To Etbin
    This is a very inovative solution - I've tried it out and the result is:-
    BUILDING LAND
    _____Land 4
    _____Land 3
    _____Land 5
    Building 2 Land 4
    Building 3 Land 1
    _____Land 4
    Building 4 Land 4
    Building 5 Land 3
    _____Land 4
    (The underscores I put in for spacing - not perfect but you get the idea - hard whe you write the reply in a fixed space font and it's displayed in the forum in variable space font!! ;)
    9 rows selected.
    This is not quite the desired result - in your list of associations, we have Building1 associated with Land 3,4, and 5.
    So for Building 1 we should have:-
    Building 1 Land 3
    ________Land 4
    ________Land 5..........
    But your result doesn't include Building 1 at all.
    The other requirement is that no building or land is ever repeated - so I came up with the concept of "groups".
    Starting with one building - I find all pieces of land that are associated - listing them on the right (without repeating the building.
    I then find any other buildings asociated with any of the land records that the first building was associated with.
    These are listed on the left - without repeating the land records on the right.
    This group is given a unique identifier of the minimum association ID (my associations have ID's).
    This all done, I use the unique ID as a break column ans summarise additional columns (area, value etc) below each group.
    Because of the summaries - adding area and value etc, I can't have any building or land duplicated as I would then "double count" the area, value etc.
    Maybe you method can be made to work with some tweaking.
    Very clever indeed - forums need great answers like this - it keeps us going.
    Thanks again
    Mike

  • Context index can't be used in complicated multiple tables join?

    hello
    thank you for view this page.
    i have a comlicated sql :
    SELECT count(*)
    from
    ((app_AssetBasicInfo left join app_AssetBasicInfoExt on
    app_AssetBasicInfo.id=app_AssetBasicInfoExt.id) left join
    (app_AssetCustominfo1 left join app_AssetCustominfoExt1 on
    app_AssetCustominfo1.id=app_AssetCustominfoExt1.id) on
    app_AssetBasicInfo.id=app_AssetCustominfo1.id) WHERE
    app_AssetBasicInfo.CategoryID=1 AND Del_tag=0 and contains(description,'department')>0;
    the table app_AssetBasicInfo and app_AssetBasicInfoExt have multiple columns and large recoord size. i create a context index on app_assetbasicinfoext(description) which description is 4000 varchar2.
    but the sql doesn't use context index. i suspect that the complicated multiple table join can't use context index? does it correct?
    thanks very much!

    Could you please post an explain plan? I'm not quite sure what is the issue.

  • One sequence for multiple lookup tables?

    I am sorry if this is off-topic, however can anybody advise what is better - use one sequence for all tables (lookup tables) or to create unique sequence for each table?
    Thanks
    DanielD

    Daniel,
    After you read this (http://asktom.oracle.com/pls/ask/f?p=4950:8:::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:2985886242221,), you may be sorry you asked.
    Scott

  • One to many and many to one transformation

    I want to transform a field one to many form and many to one.
    EXP: One to MAny
    Name and Address.
    Tanvir Ahmad Mughal
    i want to transfor it as first name=tanvir, M_name=Ahmad, Last name=Mughal
    similer with address. So tell me how i will do in oracle warehouse builder 10G.
    exp: many to one
    the address is stored in 4 attributes in source and i want to store in one field or 2 fields in oracle
    warehouse builder. tell me about it.
    i shall be thankful to you for this kind

    Hi
    Use expressions!
    Select an expression and connect the sorce fiedl to it. Create 3 output filed and define the expressions for them:
    - substr( source_field, 1, instr(source_field, ' '))
    - substr( source_field, instr(source_field, ' '), instr(source_field, ' ', 2))
    - substr( source_field, instr(source_field, ' ', 2)).
    For many to one concatenate them in an expression. Create an expression, connect the source fileds, create an output filed and in the expression use this:
    - field1 || ' ' || field2 || ' ' || field3 || ' ' || field4.
    Ott Karesz
    http://www.trendo-kft.hu

  • Understanding objects relations one-to-many and many-to-many with flex4

    Hello, I'm a newbie on Flex 4.
    I read several examples and also the "one week training". What I couldn't find is how to manage relations among objects.
    I understood that objects coming from the server must be translated to value objects.
    Because I'm working with Spring, Hibernate and BlazeDS, I've several beans and relations defined with the annotations @OneToMany and @ManyToMany. These relations are managed using List, Set and Map objects.
    More precisaly, I've to create a flex datagrid, each row is an "author" objects. Cliccking a row, I need to load some other related objects (let's call them "documents").
    Auhtor and Documents objects are in a one-to-many relation.
    My questions are:
    1) Which is the correct way to handle related objects in Flex? This questions arise from the fact that there are two ways in order to manage such objects. The first is to load the parent object and them call related method in order to get child. For example author.getDocuments(). I get all the related objects (author+ all his documents) with just one call, the one to load the "author" object. BlazeDS doesn't support lazy loading.
    The second way, is to provide the parent ID to a method that loads the related objects. For example getDocuments(authorID). I need to make a query for each ID
    Obviously, the value objects we have to create with AS are different. In the first case, the author VO will have a ArrayCollection in order to manage documents.In the second case I'll not create this property.
    2) In Flex, which is the best way? is it possible to manage objects (documents) of objects (authors) with MXML?
    3) More in general, Flex experts people, what are used to do? Where I can find an example?
    Thank you
    Paolo

    Thank you Pablo.
    Regarding my question n.2, it is confused.
    Here what I meant:
    Let's suppose I work with VO and ArrayCollection (the first "way" I wrote above). To get "Documents" objects, I need to call author.getDocuments().
    Now, I'm not sure that I'm able to do the same with MXML and that is is the easiest way. I think it should be easier working with "Documents" object instead of Auhors in order to work with Documents.
    For example, in order to get autors I can write a CallResponder and use a token. To fill a datagrid I define a method like
    protected function dataGrid_creationCompleteHandler(event:Flex:Event):void
         getAuthorsResult.token = auhtorService.getAuthors();}
    Now in order to fill the grid, I can use  for example <mx:DataGridColumn dataField="lastname">. Very easy and clear.
    But now, if I need to extract the Document objects and visualize them inside anothee DataGrid, I don't know how to do.
    For example, in <mx:DataGridColumn> tag what I've to write in order to visualize a Document property, using an Author object?
    Fixing an Auhtor, I need to loop over each Documents, but how can I loop inside the MXML? Something like <mx:DataGridColum dataField="author.documentloopvariable....>
    It should be better to get Documents via a method like getDocuments(authorID). Now I get a token related to a CallResponder, and I can work at the same manner as the Author. Isn't it? But this is the second "way" I wrote above.
    Well, I hope my question in a little clear.
    thank you
    Pbesi

  • Project Server 2010 - create a custom enterprise project field for persons (no text, no lookup table...)

    I want to create a custom enterprise project field and would like to use instead of for example a text attribute or a look-up table a field for employees (e.g. project manager) which are coming e.g. from the Active Directory. But when creating this custom
    project field I cannot see such an option. What solution do you suggest as I want to avoid that everybody uses different names and spellings for e.g. the project manager and without having to fill the lookup table with all resources of the company.
    Thank you so much for your help!

    Hi,
    Are you using Proejct Server 2007, 2010, 2013?
    In case you're working with 2010 version, here is an excellent
    blog about how to insert a resource picker in a PDP (project detail page).
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • ONE-to-MANY relationship between tables and forms in APEX

    I recently started using APEX and I have run into an issue.
    I have a ONE-TO-MANY relationship between two tables, A1 and A2, respectively.
    A1:
    A1_ID
    Item
    A2:
    A2_ID
    SubItem
    A1_ID
    I have 2 forms (lets call it F1 and F2) that I use to capture data for A1 and A2.
    On F2, I have the following fields that are setup to capture data:
         A2.A1_ID
    **A1.Item (this is a drop down that is populated using a SELECT statement where the select uses A1.Item field)
         A2.SubItem (user would enter SubItem)
    Note: A2.A2_ID is populated using a SEQ
    Everytime I pick **A1.Item on F2, is there a way to link to A1 table and display A1.A1_ID for every **A1.Item selected on F2?
    If so, I want to store the value captured in F2 for the A1_ID field into A2 table to maintain my 1-to-MANY relationship.
    If this will work, how do I go about implementing this solution?
    Can someone help me?

    I think it sounds like you are asking for a Master-Detail form. Try that and see what you get.
    chris.

  • One to Many with multiple tables on One side and one table on Many side

    Sorry for the confusion in the title. Here is my question. In my program, I have 2 different tables which store 2 different type of entities. Each one of entities has a list of attachments which I stored in a common attachment table. There is a one-to-many relationship between entity tables and attachment table.
    ENTITY_ONE (
    ID
    NAME
    ENTITY_TWO (
    ID
    NAME
    ATTACHMENTS (
    ID
    ENTITY_ID
    ATTACHMENT_NAME
    ENTITY_ID in ATTACHMENTS table is used to link attachments to either entity one or entity two. All IDs are generated by one sequence. So they are always unique. My question is how I could map this relationship into EntityOne, EntityTwo and Attachment JAVA class?

    For EntityOne and EntityTwo you can just define a normal OneToMany mapping using the foreign key.
    Are you using JPA, or the TopLink API? JPA requires a mappedBy for the OneToMany, so this may be more difficult. You should be able to just add a JoinColumn on the OneToMany and make the column insertable/updateable=false.
    For the attachment, you could either map the foreign key as a Basic (DirectToFieldMapping) and maintain it in your model, or use a VariableOneToOne mapping in TopLink (this will require the entities share a common interface).
    James : http://www.eclipselink.org : http://en.wikibooks.org/wiki/Java_Persistence

  • One to Many And Many to Many Association(jdev 11.4 ps3)

    Hi All,
    I was trying different types of ADF-BC implementations, I am stuck with following
    1)     One to Many Association
    a.     Order – OrderItem ( Join over two tables, One OrderVO should have List<OrderItemVO> orderItems
    b.     Employee-Manager (Self Join on the Employee Table, One Employee should have List<Employee> subordinates [0 to *])
    c.     Manager-Employee (Self Join on the Employee Table, One Employee should have List<Employee> managers [ 0 or 1] )
    2)     Many to Many Association
    Would be very helpful if you could provide any Blog published or Some sample implementation of the above.

    Would be very helpful if you tell us which version of jdev you are looking at.
    All this is described in the docs http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcintro.htm#sm0051 to start with and http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcentities.htm#sm0124 to follow up.
    Timo

  • To create bapi?(function module for bapi i.e. checks and update table)

    Hi all,
      I want to know how to create BAPI?. means in function module how i hv to put checks and how i will update database table.
    thanks and regards
    sg

    BAPI STEP BY STEP PROCEDURE: -
    http://www.sap-img.com/abap/bapi-step-by-step-guidance.htm
    BAPI Programming guide: -
    http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm
    BAPI user guide: -
    http://help.sap.com/saphelp_46c/helpdata/en/7e/5e115e4a1611d1894c0000e829fbbd/frameset.htm
    Example:-
    http://www.erpgenie.com/abap/bapi/example.htm
    list of all bapis
    http://www.planetsap.com/LIST_ALL_BAPIs.htm

  • JPA 1.x,: parent (one-to-many) and children(many-to-one) in the same table

    Hi, excuse me for silly question, but I can't get on with subject.
    Please, see my @Entity:
    @Entity
    public class Department {
         @Id
         @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="DEPARTMENT_SEQ")
         @SequenceGenerator(name="DEPARTMENT_SEQ", sequenceName="DEPARTMENT_SEQ", allocationSize=1)
         @Column(name="ID")
         private Long id;
         @Column(name="PARENT_ID")
         private Long parentId;
         @Column(name="LABEL")
         private String label;     
    Each department can have one parent (except root department). Each department can have 0-* children (sub-departments).
    Is it possible to realize tree structure using JPA 1.x?

    This example seems to demonstrate what you want:
    http://www.java2s.com/Code/Java/JPA/Relationsononeentity.htm

  • Error in Updating ctxsys.context index using ctxsrv

    Environment :
    Linux 6.2,
    Oracle 8.1.6
    character set : zhs16gbk or zhs16cgb231280
    I can create an ctxsys.context index(using CHINESE_VGRAM_LEXER) on a long column, and i can rebuild this index with no parameters.
    When i want to rebuild this index automatic using ctxsrv, this error occur ---
    DRG-50857 Oracle error in drtldml(dml)
    Ora-2000 error
    anybody can help me?
    null

    the complete error:
    Dml batch: cid=1023
    End batch: return code is 1
    DRG-50857: oracle error in drtldml(dml)
    ORA_20000: interMedia text 4mNs
    DRG-50857: oracle error in drsxsopen
    ORA-01480: STR83V51dA?H1IY?U:sW:
    null

Maybe you are looking for

  • Exchange syncing of contacts weirdly incomplete

    I am an Office 365 exchange user, with an iPhone, a PC with Outlook, an iPad and a couple Mac laptops.  I chalked it up to a problem with the first laptop, but when the second laptop was set up and did the exact same thing, I realized I have a more c

  • Statistical cost element (Value type 11) line item entry in CJI3

    Dear all I am doing WBS settlement to AUC thr CJ88. Suppose actual cost on WBS is 100 rs. CJI3 report shows the balance to be settled to AUC. Now It is showing 100 rs balance. I carry out WBS settlement to AUC. Even though settlement has taken place

  • Hierarchy Variables in VC

    Hello, I have a question regarding using heirarchy variables from BW query in VC.  As a work around, I found a thread that saying that I can use web_api filed of the input port and integrate the web template that was created from WAD to show hierarch

  • Log4j configuration problem

    Can anyone explain why every line in the log file is printed twice - this is my log4j configuration file. thanks... Liat <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!-- ===================================

  • Content Query display multiple columns

    Hello, I am using a content query web part (in sharepoint 2013) to display a list from another site. The problem is that I don't see enough info from that list because I can display maximum 2 columns. Is it possible to display more columns from this