Foreign keys in logical fact

Hi,
Should I define foreign keys in logical fact table? I need to use "aggregation rule=count distinct" of the foreign key column in my reports.
Thanks.
Andy

Hi Andy,
You can add the foreign keys to your fact table as a measure column (count distinct aggregation).
Do not use these foreign keys to create foreign key joins in the logical layer. Always use complex joins (http://obibb.wordpress.com/2010/08/06/joins-in-oracle-bi-ee/)
Good Luck,
Daan Bakboord
http://obibb.wordpress.com

Similar Messages

  • How to determine the logical Keys of logical fact table in BMM layer?

    Hello guys
    I'd like to know more about how to know what columns of the logical fact table should be used as key in BMM layer. How OBIEE behaving differently when different keys are selected?
    In my situation, I have 1 fact table that physically joins to 20 dimensions in physical layer. Therefore, in physical layer, this fact table has about 20 foreign keys but no primary keys..
    In the logical layer, this fact table is logically joined to the same group of dimension tables. So in this case, how do I know what columns in logical fact table I should use as keys?
    Please advice
    Thanks

    thanks for the reply...
    The interesting thing I notice is that, when I start using fragmentation with the fact tables in its LTS, if not primary key is defined in the logical fact table, then I will be getting errors:
    [nQSError: 10058] A general error has occurred. [nQSError: 14023] None of the fact sources for columns are compatible with the detail filter []. (HY000)
    When I create the key by choosing random columns from the fact table as the logical key columns, this error goes way and the correct SQL is generated according to the frag..
    Because of such behavior, I'd really like to know how logical key really works in BMM layer.

  • SSAS 2008 Linking two cubes on the foreign key between two fact tables

    Hi, all -- 
    I have two cubes:
    Cube 1 has Fact1 (F1, "Events") and 3 dimensions (D1, D2, D3)
    Cube 2 has Fact2 (F2, "Sales") and 3 dimensions (D4, D1, D6)
    As you can see, two cubes reuse D1 as their common dimension.  In addition, F2 foreign keys into F1, e.g. F1 is "Events", and F2 is "Sales".  Every "sale" is an "event", but not every "event" is
    a "sale".
    The question is, how to I link the two cubes and their two respective fact tables on the foreign key?
    Thanks, Austin.

    Hi Austin,
    According to your description, you want to retrieve data from two different cubes, right? In Analysis Services, to query multiple cubes from a single MDX statement you can use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
    The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
    Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Foreign Keys for a Logical Table

    Hi All,
    I want to know in which scenarios we create the Foreign Keys for a Logical Table. Once we create the foreign key for the logical table, does it mean that it will automatically override if any joins are there.
    Physical Table A, B ( no physical joins)
    Logical Table A, B (logical join B(Dim)-->A(Fact))
    created the foreign key in logical table A with B .(A.1=B.1)
    Will the rpd generate sql with A.1=B.1 join condition for reports.
    I tried to create the logical foreign key for logical table A, I could not see any corresponding table option.Here is its snapshot
    http://tinypic.com/r/jq1gkz/6
    Thanks,
    Virat

    In general when we go complex joins in Physical layer we go for Logical foreign key joins in BMM layer, best examples is SCD Type-II.
    Physical Table A, B ( no physical joins)
    -->You need to have a physical join so that this can be override by BMM layer
    created the foreign key in logical table A with B .(A.1=B.1) Will the rpd generate sql with A.1=B.1 join condition for reports.
    -->Yes you can see this join in BI Physical query.
    I tried to create the logical foreign key for logical table A, I could not see any corresponding table option.Here is its snapshot
    -->2 cases: 1)You need to delete existing logical joins 2) You might not have join in physical layer.
    Hope this helps
    Let me know for issues
    Edited by: Srini VEERAVALLI on Jan 18, 2013 1:29 PM
    BTW: You got very good name, why dont you update in your profile to see your name instead of some number
    Edited by: Srini VEERAVALLI on Jan 18, 2013 1:29 PM

  • Logical foreign key

    Hi All,
    I apologize to bring similar question. .
    I am able to create the logical foreign key for logical table A with new joining condition (A.2=B.2) (2 is calculated logical column).
    However there still exist Physical foreign key join with old condition (A1.=B.1). When I deploy this rpd, the report generates sql with (A1.=B.1) join condition.
    Then,I removed this Physical foreign key join in rpd,and got a warning' logical dimension B has a source that does not join with any fact table' in consistency check.
    Still after deploying this rpd , I am getting error [nQSError: 14025] No fact table exists at the requested level of detail: in report.
    I am missing anything.The logical foreign key has correct join condition still it is not over riding the physical join.
    Thanks for going through this question,
    http://tinypic.com/r/2qiwmrr/6

    Based on your comments I'm looking at documentation:
    I found a Note: A logical key for a fact table must be made up of the key columns that join to the attribute tables. Logical foreign key joins may be needed if the Oracle BI Server is to be used as an ODBC data source for certain third-party query and reporting tools.
    I need to see why ODBC, and unlike the Logical Foreign key join is not overriding join Physical layer.
    Btw: Since you want to go with a join using defined logical column, can you use the same expression in Physical join using expression builder?
    This should work.
    EX: T43770.DEPARTMENT_ID = case when T43764.DEPARTMENT_ID > 10 then T43764.DEPARTMENT_ID else 0 end
    Edited by: Srini VEERAVALLI on Jan 18, 2013 4:52 PM

  • Composite foreign key issue

    Hi,
    I am trying to create a composite foriegn key. I have created my primary key as a composite key, made up of three fields.
    Table 1
    PatientID - Made from 3 fields(a,b,c)(primry key)
    Table B
    PatiendID- (should be the foreign key which references table1)
    However i am finding that when i try to create my constraint i get the following messages
    error 02270 - no matching unique or primarty key for this column list.
    below is the sample code i am using to create my foreign key)
    (ALTER TABLE XD_PatientSedation ADD CONSTRAINT fk_Sedation_PatientID FOREIGN KEY (PatientID)REFERENCES XD_Patient_Demographics(PatientID)
    I am really stuck on this and dont quite know what to do.
    Hope you can help.
    Thanks
    Jagdish

    Just speaking about design, when you want to use a foreign key, it already means that the referenced columns represent something important enough to be a primary key of some other table. I don't understand the business logic of your example (using real table and column names would help), but the solution is probably one of these two :
    a) your foreign key should in fact refer to (a,b,c), the complete primary key of the first table (what was suggested by the others).
    b) your foreign key should stay as 'a' (patientid?), you should have a third table (patients?) whose primary key is 'a', and your "Table 1" should have a foreign key on 'a', referencing the third table. In this case you may find it silly to create a new table with only one column, but I would bet that you will very soon think of interesting attributes which could be added to this table.
    In any case, I think that Oracle did a good job by forcing an improvement of your design !

  • How to avoid shared locks when validating foreign keys?

    I have a table with a FK and I want to update a row in that table without being blocked by another transaction which is updating the parent row at the same time. Here is an example:
    CREATE TABLE dbo.ParentTable
    PARENT_ID int NOT NULL,
    VALUE varchar(128) NULL,
    CONSTRAINT PK_ParentTable PRIMARY KEY (PARENT_ID)
    GO
    CREATE TABLE dbo.ChildTable
    CHILD_ID int NOT NULL,
    PARENT_ID INT NULL,
    VALUE varchar(128) NULL,
    CONSTRAINT PK_ChildTable PRIMARY KEY (CHILD_ID),
    CONSTRAINT FK_ChildTable__ParentTable FOREIGN KEY (PARENT_ID)
    REFERENCES dbo.ParentTable (PARENT_ID)
    GO
    INSERT INTO ParentTable(PARENT_ID, VALUE)
    VALUES (1, 'Some value');
    INSERT INTO ChildTable(CHILD_ID, PARENT_ID, VALUE)
    VALUES (1, 1, 'Some value');
    GO
    Now I have 2 transactions running at the same time:
    The first transaction:
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;BEGIN TRAN
    UPDATE ParentTable
    SET VALUE = 'Test'
    WHERE PARENT_ID = 1;
    The second transaction:
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;BEGIN TRAN
    UPDATE ChildTable
    SET VALUE = 'Test',
    PARENT_ID = 1
    WHERE CHILD_ID = 1;
    If 'UPDATE ParentTable' statement runs a bit earlier, then 'UPDATE ChildTable' statement is blocked untill the first transaction is committed or rollbacked. It happens because SQL Server acquires shared locks when validating foreign keys, even
    if the transaction is using read uncommitted, read committed snapshot (read committed using row versioning) or snapshot isolation level. I cannot see why change in the ParentTable.VALUE should prevent me from updating ChildTable. Please note that ParentTable.PARENT_ID
    is not changed by the first transaction, which means that from FK's point of view whatevere is set to the ParentTable.VALUE is never a problem for referential integrity. So, such blocking behavior seems to me not logical. Furthermore, it contradicts to the
    MSDN:
    Transactions running at the READ UNCOMMITTED level do not issue shared locks to prevent other transactions from modifying data read by the current transaction. READ UNCOMMITTED transactions are also not blocked by exclusive locks that would prevent the
    current transaction from reading rows that have been modified but not committed by other transactions. 
    Does anybody know how to workaround the issue? In other words, are there any tricks to avoid shared locks when validating foreign keys? (Disabling FK is not an option.) Thank you.
    Alexey

    If you change the primary key of the parent table to be nonclustered, there is no blocking.
    Indeed, when I update ParentTable.VALUE, then:
    in case of PK_ParentTable is clustered, a particular row in the clustered index is locked (request_mode:X, resource_type: KEY)
    in case of PK_ParentTable is non-clustered, a particular physical row in the heap is locked (request_mode:X, resource_type: RID).
    and when I update ChildTable.PARENT_ID, then:
    in case of PK_ParentTable is clustered, this index is used to verify referential integrity:
    in case of PK_ParentTable is non-clustered, again this index is used to verify referential integrity, but this time it is not locked:
    It is important to note that in both cases SQL Server acquires shared locks when validating foreign keys. The principal difference is that in case of clustered PK_ParentTable the request is blocked, while for non-clustered index it is granted.
    Thank you, Erland for the idea and explanations.
    The only thing that upsets me is that this solution cannot be applied, because I don't want to convert PK_ParentTable from clustered to non-clustered just to avoid blocking issues. It is a pity that SQL Server is not smart enough to realize that:
    ParentTable.PARENT_ID is not changed and, as a result, should not be locked
    ChildTable.PARENT_ID is not actually changed either (old value in my example is 1 and the new value is also 1) and, as a result, there is no need at all for validating the foreign key.
    In fact, the problem I described is just a tip of the iceberg. The real challenge is that I have deadlocks because of the FK validation. In reality, the first transaction has an additional statement which updates ChildTable:
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
    BEGIN TRAN
    UPDATE ParentTable
    SET VALUE = 'Test'
    WHERE PARENT_ID = 1;
    UPDATE ChildTable
    SET VALUE = 'Test'
    WHERE PARENT_ID = 1;
    The result is famous message:
    Msg 1205, Level 13, State 51, Line xx
    Transaction (Process ID xx) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
    I know that if I change the order of the two statements, it will solve the deadlock issue. But let's imagine I cannot do it. What are the other options?
    Alexey

  • Logical foreign key display values

    I have a schema in which the primary keys are auto generated numbers. Foreign keys exist from child tables to the primary key of the parent.
    I have figured out how to change auto generated forms to display a dropdown list of display/values to the user on insert or update instead of the meaningless number.
    What I can't figure out how to do is have the generated report show the display that I am looking for without losing the ability to edit the child record. As soon as I manipulate the query to include another table I lose the icon in the application to edit the row.
    Is it possible to keep the edit icon on the report while showing logical values instead of actual ones?
    Thanks in advance,
    Chris S.

    We'll use a football analogy because it's time for the ployoffs.
    Let's create a TEAMS table and a DIVISIONS table.
    TEAMS consists of:
    TEAM_ID NUMBER -> PK
    LOCATION VARCHAR2(35)
    TEAM_NAME VARCHAR2(35)
    and DIVISIONS consists of:
    DIVISION_ID NUMBER -> PK
    DIV_NAME VARCHAR2(35)
    Now there can't just be a link from a team to a division because they move around a bit. The Detroit Lions used to be in the NFC Central. That doesn't exist anymore and now they are in the NFC North. (Please set aside the fact that the NFC should be a part of the conferences table).
    This means that I would create a table to link the TEAM record to a DIVISION record with the season that the team became a part of the division and potentially the last season that they were in that division. This table will be called DIVISION_TEAM_XREF and looks like this:
    LINK_ID NUMBER -> PK
    DIVISION_ID NUMBER -> FK(DIVISIONS.DIVISION_ID)
    TEAM_ID NUMBER -> FK(TEAMS.TEAM_ID)
    SEASON_EFF NUMBER(4) (actually a year maybe a VARCHAR2 would be better)
    SEASON_TERM NUMBER(4) (nullable)
    Now I created all of that through HTML DB with foreign keys from the XREF table to the teams and divisions tables. Then I create an application throught the application builder. I choose report and form and the application type like the demo. for each of the three tables. Choose a theme and walah there is an application with all three tables. If I add data to TEAMS or DIVISIONS I can see them in the report page that is created and there is an icon to the left of each row which when clicked will allow me to edit the row.
    The problem comes with my XREF table. The creation screen is just a form which expects me to know the auto generated number that was created for my division and team. I have figured out how to change this in the application builder so that it is a drop down list built from a query of the respective table.
    Once I create a record I can see it in the report page for the XREF table. This page has the option to edit the record but the values on the screen are the auto generated numbers that don't mean anything to a user. When I change this page to use display values from the parent tables I lose the edit icon.
    Here is the original query that the application builder used:
    select
    "LINK_ID",
    "DIVISION_ID",
    "TEAM_ID",
    "SEASON_EFF",
    "SEASON_TERM"
    from "DIVISION_TEAM_XREF"
    and here is what I would like to change it to:
    select
    XREF.LINK_ID "LINK_ID",
    DIV.DIV_NAME "DIVISION",
    TEAM.TEAM_NAME "TEAM",
    XREF.SEASON_EFF "SEASON_EFF",
    XREF.SEASON_TERM "SEASON_TERM"
    from "DIVISION_TEAM_XREF" XREF, DIVISIONS DIV, TEAMS TEAM
    where XREF.DIVISION_ID = DIV.DIVISION_ID
    and XREF.TEAM_ID = TEAM.TEAM_ID
    Sorry for the long post. Hope that clarifies.
    Chris S.

  • Dimension foreign key on Fact gets updated with same value

    Hi All,
    I'm hoping someone has at least seen this problem and can provide insight.
    Background:
    - We are on OWB 10.2
    - Fact table is Billing_F
    - Fact table has foreign keys to Customer_Dim, SalesOrg_Dim, Time_Dim, etc.
    - Fact table has update mode Update/Insert
    Once in a while, every row in the Billing Fact gets updated with the SAME SalesOrg_Dim foreign key column value. In other words, the data would look like:
    Before:
    Line ID Amt SalesOrg_Key
    1 100 19241
    2 200 21925
    3 140 08585
    After:
    Line ID Amt SalesOrg_Key
    1 100 12345
    2 200 12345
    3 140 12345
    *** The Source tables contain values in the Before table. ***
    We can't reproduce this on a consistent basis. The only way to "correct" the data is to rerun the mapping from source -> staging -> fact again. No other change.
    Please, has anyone else at least experienced this problem? If so, how were you able to fix it permanently?
    Any help is greatly appreciated!
    irene

    Hi Irene
    Difficult to help here without reviewing your mappings/schedule but does SalesOrgKey 12345 represent a particular value e.g. Unknown, Default?
    I suspect it's something to do with your load order in that the data in the dimension is not available/ready when the fact is loaded and therefore a default value is being inserted. When the fact load is rerun I'm guessing the load of the dimension has finished and therefore the key lookup returns the proper keys from the dimension. Is the dimension truncated and reloaded?
    Regards
    Si

  • Foreign keys in SCD2 dimensions and fact tables in data warehouse

    Hello.
    I have datawarehouse in snowflake schema. All dimensions are SCD2, the columns are like that:
    ID (PK) SID NAME ... START_DATE END_DATE IS_ACTUAL
    1 1 XXX 01.01.2000 01.01.2002 0
    2 1 YYX 02.01.2002 01.01.2004 1
    3 2 SYX 02.01.2002 1
    4 3 AYX 02.01.2002 01.01.2004 0
    5 3 YYZ 02.01.2004 1
    On this table there are relations from other dimension and fact table.
    Need I create foreign keys for relation?
    And if I do, on what columns? SID (serial ID) is not unique. If I create on ID, I have to get SID and actual row in any query.

    >
    I have datawarehouse in snowflake schema. All dimensions are SCD2, the columns are like that:
    ID (PK) SID NAME ... START_DATE END_DATE IS_ACTUAL
    1 1 XXX 01.01.2000 01.01.2002 0
    2 1 YYX 02.01.2002 01.01.2004 1
    3 2 SYX 02.01.2002 1
    4 3 AYX 02.01.2002 01.01.2004 0
    5 3 YYZ 02.01.2004 1
    On this table there are relations from other dimension and fact table.
    Need I create foreign keys for relation?
    >
    Are you still designing your system? Why did you choose NOT to use a Star schema? Star schema's are simpler and have some performance benefits over snowflakes. Although there may be some data redundancy that is usually not an issue for data warehouse systems since any DML is usually well-managed and normalization is often sacrificed for better performance.
    Only YOU can determine what foreign keys you need. Generally you will create foreign keys between any child table and its parent table and those need to be created on a primary key or unique key value.
    >
    And if I do, on what columns? SID (serial ID) is not unique. If I create on ID, I have to get SID and actual row in any query.
    >
    I have no idea what that means. There isn't any way to tell from just the DDL for one dimension table that you provided.
    It is not clear if you are saying that your fact table will have a direct relationship to the star-flake dimension tables or only link to them through the top-level dimensions.
    Some types of snowflakes do nothing more than normalize a dimension table to eliminate redundancy. For those types the dimension table is, in a sense, a 'mini' fact table and the other normalized tables become its children. The fact table only has a relation to the main dimension table; any data needed from the dimensions 'child' tables is obtained by joining them to their 'parent'.
    Other snowflake types have the main fact table having relations to one or more of the dimensions 'child' tables. That complicates the maintenance of the fact table since any change to the dimension 'child' table impacts the fact table also. It is not recommended to use that type of snowflake.
    See the 'Snowflake Schemas' section of the Data Warehousing Guide
    http://docs.oracle.com/cd/B28359_01/server.111/b28313/schemas.htm
    >
    Snowflake Schemas
    The snowflake schema is a more complex data warehouse model than a star schema, and is a type of star schema. It is called a snowflake schema because the diagram of the schema resembles a snowflake.
    Snowflake schemas normalize dimensions to eliminate redundancy. That is, the dimension data has been grouped into multiple tables instead of one large table. For example, a product dimension table in a star schema might be normalized into a products table, a product_category table, and a product_manufacturer table in a snowflake schema. While this saves space, it increases the number of dimension tables and requires more foreign key joins. The result is more complex queries and reduced query performance. Figure 19-3 presents a graphical representation of a snowflake schema.

  • Data Modeler 3.0 EA1 - Logical Relation to Foreign Key not generating

    When use "Engineer to Relational Model" the only time it creates foreign keys from my relations is when those relations are of the type many-to-many. I've added a Primary UID for each table and I have tried to use the Apply Naming Standard options but nothing seems to work.
    I tested my design with the design rules feature I have no errors.
    Does anyone have any ideas?
    Greg

    Hi Greg,
    probably you added primary uid after first engineering to relational model. You can check whether those uids are selected in engineering dialog.
    Also you can check log file in datamodeler\datamodeler\log directory for logged problems there.
    Philip

  • Define logical Key on Logical Dimension Table

    It's recommended to define a logical key for any logical dimension table - in 10g there was a function on the right mouse button, as far as I remember - but in 11g there is no such functionality ? the foreign key can be added by "green plus" button, but not the primary key ?? you have to type in the name of the key, then you can choose the column and then you select as primary key ... funny.
    bug or undocumented feature?

    Hi Srini,
    Since my main logical fact table consists of two LTS and the dimension being created from this table will also have 2 LTS, the content level will be set to all levels on which the fact is joined.
    So I would like to create a logical dimension based out of my dimension and then assign the content level at the detail level.
    Please let me know if I am not clear.
    Thanks

  • Regarding Foreign Key Joins

    Hi Gurus,
    I learnt that its not practical to use Foreign Key joins in the Business Model and Mapping layer. Why is that, i tried a simple Sample Star schema that uses only Foreign Key joins instead of Complex Joins in BMM Diagram, The RPD is consistent and is running successfully on BI Server.
    What is the drawback if i did so and why is not recommended?
    Regards,
    Sreekanth.

    Complex joins allow the BI Server to choose the best route between logical tables in the BMM layer based on the phyiscal joins that exist for the Logical table sources within those tables.
    With an FK join your limiting the choices BI server has when it generates the ideal SQL to accomplish the request.
    The complex joins allow :
    easier config,
    BI Server to navigate across different levels (for example Day and Month) when using different level facts.

  • Subquery in IF statement in trigger, without using foreign keys

    Hello,
    I'm investigating ways of writing a subquery in an IF statement, which is placed inside a trigger.
    I wanna write smth like IF (:new.jazz not in (select goldies from T where ... )) etc. I don't know whether the fact that the IF is in a trigger adds some additional restrictions. (Does it?)
    So far I found the solution described here: SubQuery Comparison in If Statement which I find a bit tacky, I could have the 'cooleststarinthegalaxy' instead of 1 and seems you need to do extra light, but still extra lifting.
    I also read about the possibility of using MERGE, which I'm currently researching.
    Is there any other way?
    Thanks
    Edited by: BluShadow on 14-Nov-2012 13:37
    fixed link
    Edite by me: the question is how (if possible) to do this without a foreign key.
    Edited by: questioningq12 on Nov 14, 2012 6:11 AM
    Edited by: questioningq12 on Nov 14, 2012 6:13 AM

    Hi,
    questioningq12 wrote:
    Say I have tables A(namea varchar(10)), B(nameb varchar(10)), and B contains tuples ('1stname','2ndname').
    I wrote a trigger before insertion, for each row, on table A. For a tuple t to be inserted, it should check whether t.namea is in the set of values nameb from B.
    E.g., INSERT INTO A VALUES('1stname') should work. But INSERT INTO A VALUES ('3rdname') should fail. You can use a foreign key constraint for that.
    If the tables already exist, and b.nameb is declared as UNIQUE (or PRIMARY KEY), then you can say:
    ALTER TABLE  a
        ADD CONSTRAINT     a_namea_fk
        FOREIGN KEY  (namea)
        REFERENCES b (nameb)
    ;If you had a situation where you really needed to query a table in PL/SQL, and you weren't sure if the query would find anything, you could put the query in its own BEGIN ... EXCEPTION block, and test for NO_DATA_FOUND.
    If you're just checking to see if a row exists or not, you can always write a query that is guaranteed to return exactly 1 row, like this:
    BEGIN
        SELECT  COUNT (*)
        INTO    x
        FROM    b
        WHERE   nameb = :NEW.namea
        AND         ROWNUM  = 1;
        IF x = 0
        THEN  
            ...        -- print msgs, raise exceptions etc
        END IF;
    END;Edited by: Frank Kulash on Nov 14, 2012 9:22 AM
    Added example

  • Foreign Key Relationships to external associations - Is it really this dodgy or is there a better way?

    Hi All,
    Let's picture that I have a GW service called Search Helps and within that service I have a PersonalAreas Entity Set which acts as a search help for drop down fields effectively that need to select a Personal Area.  I have 3 properties, with Personal Area Id and Company Code being the keys, and the text for Personal Area being the 3rd and last property. You really need to filter PersonalAreas by Company Code otherwise it's a fairly useless result set.
    Now within a different GW service, I have an entity called Position which has a single key of PositionId.  There is also a a property of company code on this Position.
    Now rather than asking the UI developer to get the Company code value and filter PersonalAreas with it directly, I thought it would be nicer for the UI developer just to use the navigation from a specific Position to PossiblePersonalAreas.  e.g. Positions('123')/PossiblePersonalAreas returns the entity set of PersonalAreas filtered by the Position's Company Code.
    So with that in mind, I add the external model reference pointing at the search helps service; then create an external association via the sneaky External Associations Editor button (that doesn't appear on the Wizard just to confuse you), and set up my Dependent entity to point at the Search Helps PersonalAreas entity.
    At this point I really want to tie the Position's Company Code to the PersonalAreas Company Code, but all I can do is set up a referential constraint of PositionId to CompanyCode or have no referential constraint at all (note - in my example I added the referential constraint as there is an issue with navigation keys being provided to external associations from what I can tell - more about this below).
    So, without any other option, I go into my GetEntitySet method of PersonalAreas and write something like the following:
      CASE iv_source_name.
        WHEN 'Position'.
          READ TABLE it_filter_select_options ASSIGNING <filter> INDEX 1.
          CHECK sy-subrc = 0.
          READ TABLE <filter>-select_options assigning <select_option> INDEX 1.
          CHECK sy-subrc = 0.
          position_id = <select_option>-low.
    *     Get company code for position
          TRY.
              CREATE OBJECT o_position
                EXPORTING
                  i_position_id = position_id.
              o_position->get_cost_centre_information(
                IMPORTING
                  e_company_code = company_code
            CATCH zcx_hr_object.
          ENDTRY.
      endcase.
    * Continue with retrieving PersonalAreas for given Company Code
    <Remaining code not shown>
    e.g. I have to assume CompanyCode is actually "Position Id" when the source of this call is from Position (I could also look at the navigation to find this has come from Position but if you're wondering, unfortunately for external associations, the key is not included in this for some reason but the same followup logic of reloading the object would be required).
    So the question I'm hoping the answer to is Yes is: Am I missing something in my understanding here?
    Thanks,
    Matt
    Edit since posting and playing around a bit more: Thinking about this further - it's unfortunate, but the navigation property in odata really implies the dependent entity has knowledge of the principal entity and realistically must know how to instantiate it if it needs to get data based on one of the properties. 
    Now while I'm fine with that (sort of) I think it's wrong that the dependent entity needs to have the required key properties to hold the principal entities as it makes something like a generic search help impossible to do with navigation - Maybe I just need to be done with that and expect filters to be used by UI programmers to find foreign key'ed entities....

    Hi Matt,
    I'm not surprised that you have an issue with this. One bugbear I have with Gateway is that for some reason the designers don't think any context beyond the immediate preceding navigation node is important. They don't support this within the same service,so it's hardly likley to work in a service reference.
    I may be wrong but I don't think GW is OData compliant in this respect. If I have the navigation path /blindservice/FromHereSet(1)/ToAPoints(22)/ToBPoints, it's rather restrictive to say I cannot see the initial key of '1' in the path when I am trying to resolve 'ToBPoints'. If that value - where I started - is key to the context, I have to know it.
    Currently the only way to access this context is to embed the 'key history' in the intermediate entities, i.e. /blindservice/FromHereSet(1)/ToAPoints(1,22)/ToBPoints. In my view that is corrupting the URl to suit the limitations of the SAP OData implementation. What's even more confusing/frustrating is that the technical request context appears to be able to store the stacked navigation keys but doesn't make use of this design. 
    I feel your pain
    Ron.

Maybe you are looking for