Use of Foreign Keys in MDM

Hi All,
Is there any mean by which we can use Foreign Keys in MDM.
Sighting an example.
We have 3 table with fields:
Products(Main Table): Material No( UF)
Product Regions(Flat): Marerial No ( Foreign Key),Region: Lookup
Prices(Flat): Material No( Foreign Key),Region: Lookup(Foreign Key),Price Type: Lookup.
How is it possible to achieve the above mentioned scenerio.
And are Foreign Keys same as Unique Fields in MDM. 
Thanks
Manish
Edited by: manish gupta on Mar 4, 2009 12:30 PM

Hi Manish,
MDM server sits on the database server.
The database server is a DBMS.MDM repository does not work with the tables and fields structure in exactly the same way as an RDBMS.
So we do not use in the real sense the same Primary key Unique key concept.However we have the linkup/lookup field concept in MDM.
Where a field in the main table can reference another field in the lookup table.
So if you relate this to the RDBMS concept.The primary field in one table is the Foriegn key in another table.So in the lookup table we can refer a field of the main table.
say for eg:
You have a field Regions in the main table of type lookup flat.
This field is actually used in the lookup flat table say lookup regions.
This table has a field regions which is holding a legal set of values.
So the field Regions in main table is used in the Lookup table as well.Where in the main table it was the linking field and in the lookup table it is the field holding the lookup values.
So you can to an extent relate these 2 concepts but it does not precisily work in the same way in MDM.
Hope It Helped
Thanks & Regards
Simona Pinto

Similar Messages

  • Use of foreign key check in ABAP reports

    Hi,
    I'm trying to understand if it's possible to use a foreign key integrity check in an ABAP reports. I have understood that this kind of check is deactivated for performance reasons, is it right?
    In this case I'd like to know if it is possible to activate the foreign key check "on demand", or just for a particular table.
    As an example, I'd like to use the foreign key defined on attribute AKONT of table KNB1, that points on the related attribute of table SKB1.
    Thanks,
    Gabriele

    Welcome on SCN!
    I'm trying to understand if it's possible to use a foreign key integrity check in an ABAP reports. I have understood that this kind of check is deactivated for performance reasons, is it right?
    Most likely yes. Integrity is turned OFF for Open SQL statements but is turned ON for screen fields.
    If you just create screen parameter like
    parameters pa_akont type knb1-akont.
    ...then input help for that field will be automatically provided. This means that you will not be able to pick or enter value different that this allowed from SKB1 table (foreign key relationship will be checked).
    You can explicitly assign different input help or search help for certain screen field independently of type it is refering i.e by means of fm F4IF_FIELD_VALUE_REQUEST .
    This however still relates only to screen fields, not fields used directly in ABAP statement.
    Regards
    Marcin

  • Publish: dropping index when it is used for foreign key constraint enforcement

    Hi,
    I'm trying to update a target schema from a reference database via Publish. Among the changes to apply, there's an index that needs to be dropped. Since it's linked to a foreign key constraint, it cannot be deleted unless the foreign key is temporarily dropped
    (I saw somewhere that disabling the foreign key should be enough but it doesn't seem to work either).
    Since there are other changes to be made on the same table, this foreign key also has to be dropped before the script can delete the table and re-create it. This part of the script is correctly generated. The problem is that this part appears after the 'DROP
    INDEX' instruction.
    So when generating the update script, SSDT tries to drop the index BEFORE dropping the foreign key. And I can't drop the foreign key in my custom pre-deployment script, otherwise the update script would fail when trying to delete it again.
    Shouldn't SSDT be smart enough to drop the constraint before the index? Is it a bug or did I forget to set an option? If it's not a bug, what can I do apart from doing it manually?
    Thank you for your help

    Hi Elsa,
    That sounds like a bug. Could you please file a Connect issue for this at
    https://connect.microsoft.com/SQLServer/feedback/CreateFeedback.aspx using the category "Developer Tools (SSDT, BIDS, etc.)"? We're trying to track all bugs through
    Connect so that you can tell when we have fixed the issue and we can request more information.
    A workaround for this issue might be to write a pre-deployment script for your project to drop the foreign key prior to deployment. A pre-deployment script can be added to your project by right-clicking on the
    project in solution explorer and then clicking on Add > Script... and selecting Pre-Deployment Script from the list.
    Thanks!

  • 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

  • How to choose the right foreign key to be used when processing a dimension

    Hi,
    here is the problem I'm facing : I need to create a dimension in my cube from the table dimDocumentVente.
    Here are the relations between my tables in SQLServer.
    dimDocumentVente
        ID
        ID Article
        ID GroupeComptaProduitTVA
    dimArticle
       ID
       ID GroupeComptaProduitTVA
    dimGroupeComptaProduit
       ID
       Code
    with Foreign keys between :
    - IDGroupeComptaProduit  in dimDocumentVente and ID in dimGroupeComptaProduit
    - IDGroupeComptaProduit in dimArticle and ID in dimGroupeComptaProduit
    - IDArticle in dimDocumentVente and ID in dimArticle
    In this dimension (based on dimDocumentVente), I add the information ID from dimGroupeComptaProduit.
    When I process the dimension, I see in SQL Profiler that the relation between the 2 tables is done using dimArticle, which is not what I want to do. I want to use the relation which is between dimGroupeComptaProduit and dimDocumentVente.
    Is there a way to tell SSAS, that I want to use the foreign key between dimDocumentVente and dimGroupeComptaProduit to calculate this attribute ?
    From the user point of view, the information contained in the table dimGroupeComptaProduit contains information linked the the VAT rate. This information is linked to the items in our ERP (Dynamics NAV), and when we create a new order, this information is
    copied in the order line and the user has the possibility to override it. So in the cube, it's interesting to both analyse from the value stored in the item and the value stored in the order. That's the reason why !
    Thanks in advance for your help.

    Thanks for your answer but unfortunately, that's not exactly what I'm looking for.
    I mean, I want to create a dimension based on table dimDocumentVente in which I want to include the information "code" coming from dimGroupeComptaProduitTVA table.
    Please see below.
    As you may notice, I have several foreign keys.
    When I process the dimension, I see in SQL profiler that SQLServer is using the relation between dimDocumentVente and dimArticle plus between dimArticle and dimGroupeComptaProduitTVA to process my dimension. It's necessary for me that instead, it uses directly the
    relation between dimDocumentVente and dimGroupeComptaProduitTVA. Is there a way to change this  ?
    Thanks.

  • Creating Column in table or use Foreign Key

    I have a bunch of tables that are year specific, so I need to store the year in the record. I'm not sure if I should create a column in each table called 'year' or create a master 'Year' table and use a foreign key to it in all my other tables. Any advice?
    PK_ID NUMBER Constraint pk1
    PRIMARY KEY
    YEAR VARCHAR2(4)
    --- or----
    PK_ID NUMBER Constraint pk1
    PRIMARY KEY
    FK_YEAR NUMBER Constraint fk_year
    REFERENCES year_table(PK_ID)

    Does your "year" entity have any attributes ?
    Why do you have a year, which to most people seems to be a number, stored as a varchar2(4) ? And what are you going to do about the Y10K problem ?
    How about making the ID of year the numeric value of the year you are storing - then you have eat your cake and have it ;)
    Seriously, though, why do you want a table to say that the year 2008 is the year identified by a meaningless unique number ?
    Regards
    Jonathan Lewis
    http:/jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • [PHP-MYSQL] tutorial on using ADDT and dynamic list/form with self-foreign keys?

    Hi all,
    I have a 3 levels catagoris product catalog and would like to manage it
    using dynamic list/forms.
    I'm searching info about using self-foreign keys on dynamic list/forms.
    Is there any tutorial on how to manage this kind of tables using addt?
    tia
    tony

    Hello Tom,
    You were offered the solution on the InterAKT forums, I am not sure why you are posting this problem again. There's also another thread here that presents the same issue and solution:
    http://www.adobeforums.com/cgi-bin/webx/.3bc42a90/0
    Regards,
    Ionut

  • FOREIGN KEY IS PRIMARY KEY

    Hi,
    Has anyone come across the following problem?
    I have two tables
    customer individual
    customer_id (PK) customer_id (PK)
    customer_id in individual is the primary key for that table. It is also a foreign key ( related back to customer).
    If I use JDeveloper to drag in the two tables ( into a class diagraqm), I have a problem.
    JDeveloper "sees" the Individual bean foreign key mapping and generates a getCustomer() method (which returns a handle to the appropriate customer bean).
    However as it "removes" the getCustomer_id() method(which returns the actual customer_id), the primary_key reference is dropped.
    When I try and compile, JDeveloper quite rightly complains with "where is the primary key".
    Can anyone help? Do I need to make it a rule that the foreign key is not also the primary key?
    thanks in advance,
    Kevin

    Hello,
    I am having the same problem attempting to use a foreign key as a primary key in an EJB 2.0 CMR running on WLS 6.1. If I do not set the foreign key portion of my composite key in the ejbCreate() method I get an error stating that the field cannot be null (and must be set), when I set the field in the ejbCreate I then get an Error in the ejbPostCreate stating that CMR fields cannot be set using the setXXX methods. The entity relations are as follows:
    SalesOrder <--------------------------------------->SalesOrderProduct
    SalesOrder = (orderid(PK)+orderstatus+salesrepid+contractdate+processdate)
    SalesOrderProduct = (orderid(PK/FK)+productid(PK)+qty+unitcost)
    The CMR relationship is bi-directional. The SalesOrder entity bean's ejbPostCreate() method
    invokes a helper method that attempts to create the salesOrder product entity as part of the salesorder create transaction and that's when I get the errors stated above.
    Have or anyone found out how to handle this kind of cmr using the Weblogic server (6.1) and ejb 2.0??
    Thanks,
    Darryl

  • Caching problem w/ primary-foreign key mapping

    I have seen this a couple of times now. It is not consistent enough to
    create a simple reproducible test case, so I will have to describe it to you
    with an example and hope you can track it down. It only occurs when caching
    is enabled.
    Here are the classes:
    class C1 { int id; C2 c2; }
    class C2 { int id; C1 c1; }
    Each class uses application identity using static nested Id classes: C1.Id
    and C2.Id. What is unusual is that the same value is used for both
    instances:
    int id = nextId();
    C1 c1 = new C1(id);
    C2 c2 = new C2(id);
    c1.c2 = c2;
    c2.c1 = c1;
    This all works fine using optimistic transactions with caching disabled.
    Although the integer values are the same, the oids are unique because each
    class defines its own unique oid class.
    Here is the schema and mapping (this works with caching disabled but fails
    with caching enabled):
    table t1: column id integer, column revision integer, primary key (id)
    table t2: column id integer, column revision integer, primary key (id)
    <jdo>
    <package name="test">
    <class name="C1" objectid-class="C1$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t1"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c2">
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="column.id" value="id"/>
    </extension>
    </field>
    </class>
    <class name="C2" objectid-class="C2$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t2"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c1">
    <extension vendor-name="kodo" key="dependent" value="true"/>
    <extension vendor-name="kodo" key="inverse-owner" value="c2"/>
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="table" value="t1"/>
    <extension vendor-name="kodo" key="ref-column.id" value="id"/>
    <extension vendor-name="kodo" key="column.id" value="id"/>
    </extension>
    </field>
    </class>
    </package>
    </jdo>
    Because the ids are known to be the same, the primary key values are also
    used as foreign key values. Accessing C2.c1 is always non-null when caching
    is disabled. With caching is enabled C2.c1 is usually non-null but sometimes
    null. When it is null we get warnings about dangling references to deleted
    instances with id values of 0 and other similar warnings.
    The workaround is to add a redundant column with the same value. For some
    reason this works around the caching problem (this is unnecessary with
    caching disabled):
    table t1: column id integer, column id2 integer, column revision integer,
    primary key (id), unique index (id2)
    table t2: column id integer, column revision integer, primary key (id)
    <jdo>
    <package name="test">
    <class name="C1" objectid-class="C1$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t1"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c2">
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="column.id" value="id2"/>
    </extension>
    </field>
    </class>
    <class name="C2" objectid-class="C2$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t2"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c1">
    <extension vendor-name="kodo" key="dependent" value="true"/>
    <extension vendor-name="kodo" key="inverse-owner" value="c2"/>
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="table" value="t1"/>
    <extension vendor-name="kodo" key="ref-column.id" value="id2"/>
    <extension vendor-name="kodo" key="column.id" value="id"/>
    </extension>
    </field>
    </class>
    </package>
    </jdo>
    Needless to say, the extra column adds a lot of overhead, including the
    addition of a second unique index, for no value other than working around
    the caching defect.

    Tom-
    The first thing that I think of whenever I see a problem like this is
    that the equals() and hashCode() methods of your application identity
    classes are not correct. Can you check them to ensure that they are
    written in accordance to the guidelines at:
    http://docs.solarmetric.com/manual.html#jdo_overview_pc_identity_application
    If that doesn't help address the problem, can you post the code for your
    application identity classes so we can double-check, and we will try to
    determine what might be causing the problem.
    In article <[email protected]>, Tom Landon wrote:
    I have seen this a couple of times now. It is not consistent enough to
    create a simple reproducible test case, so I will have to describe it to you
    with an example and hope you can track it down. It only occurs when caching
    is enabled.
    Here are the classes:
    class C1 { int id; C2 c2; }
    class C2 { int id; C1 c1; }
    Each class uses application identity using static nested Id classes: C1.Id
    and C2.Id. What is unusual is that the same value is used for both
    instances:
    int id = nextId();
    C1 c1 = new C1(id);
    C2 c2 = new C2(id);
    c1.c2 = c2;
    c2.c1 = c1;
    This all works fine using optimistic transactions with caching disabled.
    Although the integer values are the same, the oids are unique because each
    class defines its own unique oid class.
    Here is the schema and mapping (this works with caching disabled but fails
    with caching enabled):
    table t1: column id integer, column revision integer, primary key (id)
    table t2: column id integer, column revision integer, primary key (id)
    <jdo>
    <package name="test">
    <class name="C1" objectid-class="C1$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t1"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c2">
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="column.id" value="id"/>
    </extension>
    </field>
    </class>
    <class name="C2" objectid-class="C2$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t2"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c1">
    <extension vendor-name="kodo" key="dependent" value="true"/>
    <extension vendor-name="kodo" key="inverse-owner" value="c2"/>
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="table" value="t1"/>
    <extension vendor-name="kodo" key="ref-column.id" value="id"/>
    <extension vendor-name="kodo" key="column.id" value="id"/>
    </extension>
    </field>
    </class>
    </package>
    </jdo>
    Because the ids are known to be the same, the primary key values are also
    used as foreign key values. Accessing C2.c1 is always non-null when caching
    is disabled. With caching is enabled C2.c1 is usually non-null but sometimes
    null. When it is null we get warnings about dangling references to deleted
    instances with id values of 0 and other similar warnings.
    The workaround is to add a redundant column with the same value. For some
    reason this works around the caching problem (this is unnecessary with
    caching disabled):
    table t1: column id integer, column id2 integer, column revision integer,
    primary key (id), unique index (id2)
    table t2: column id integer, column revision integer, primary key (id)
    <jdo>
    <package name="test">
    <class name="C1" objectid-class="C1$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t1"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c2">
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="column.id" value="id2"/>
    </extension>
    </field>
    </class>
    <class name="C2" objectid-class="C2$Id">
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="t2"/>
    </extension>
    <extension vendor-name="kodo" key="jdbc-version-ind"
    value="version-number">
    <extension vendor-name="kodo" key="column" value="revision"/>
    </extension>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-field-map" value="value">
    <extension vendor-name="kodo" key="column" value="id"/>
    </extension>
    </field>
    <field name="c1">
    <extension vendor-name="kodo" key="dependent" value="true"/>
    <extension vendor-name="kodo" key="inverse-owner" value="c2"/>
    <extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
    <extension vendor-name="kodo" key="table" value="t1"/>
    <extension vendor-name="kodo" key="ref-column.id" value="id2"/>
    <extension vendor-name="kodo" key="column.id" value="id"/>
    </extension>
    </field>
    </class>
    </package>
    </jdo>
    Needless to say, the extra column adds a lot of overhead, including the
    addition of a second unique index, for no value other than working around
    the caching defect.
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Legacy Mapping Problem: Compound PK is Foreign Key

    My job is to map beans using JPA onto a legacy database schema that must not get modified. I am stuck with doing the relation between two tables.
    The schema is:
    CREATE TABLE A (
         a1 INTEGER NOT NULL,
         a2 INTEGER NOT NULL,
         PRIMARY KEY (a1, a2)
    CREATE TABLE B (
         b1 INTEGER NOT NULL,
         b2 INTEGER NOT NULL,
         b3 INTEGER NOT NULL,
         FOREIGN KEY f (b1, b2) REFERENCES A (a1, b2) ON UPDATE CASCADE ON DELETE CASCADE,
         PRIMARY KEY (b1, b2, b3)
    )As you can see, both tables have compound primary keys, and the primary key of table B contains a foreign key to table A. This is typical in our DB because B in fact acts like a "inner table" (in the sense of "inner class") to A.
    So far I defined both classes and provided a primary key, but the question now is, how to provide the relation between both? The relation shall be unidirectional, so that I can query all Bs belonging to one A by "myA.getBs(): Collection".
    The code I have written so far is:
    @Entity
    public class A {
         @EmbeddedId
         private APK primaryKey;
         @OneToMany
         private Collection<B> characteristics;
    @Embeddable
    public class APK {
         private String a1;
         private String a2;
    @Entity
    public class B {
         @EmbeddedId
         private BPK primaryKey;
    @Embeddable
    public class BPK {
         private String b1;
         private String b2;
         private String b3;
    }Unfortunately that is not working, because the JPA Provider (here: TopLink Essentials) tries to map the relationship on a third table named "A_B" that actually is not there.
    So how to tell TopLink to find the mapping information in table B (just like using the foreign key f)?
    Please help, I am driving nuts!

    OK
    So i found out the real problem
    And the problem is that my CustomerHistory has a Text Field, as in a MS SQL Server TEXT Field
    When i changed it to a VARCHAR, it started working
    The strangest thing is that Customer also has a TEXT Field (mapped to a String) and i can do Finds without any problems
    So my question now is how can i work with TEXT in CMPs ?
    Thanks

  • 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 !

  • Why do you expose the accessors of a foreign key association in an Entity?

    Hello Everyone:
    I am working on our re-usable Business Components .jar file. I am re-doing the one we had created in 10g from scratch in 11.1.2 in order to utilize all of the features of 11.1.2 and remove the problems we were having with re-factor in 10g.
    In 10g there was also a bug that gave us an error if we exposed the source and destination accessors of foreign keys if there were multiple similarly named source accessors for a number of foreign keys on a table. So we removed all the foreign key source and destination accessors. We only exposed the accessors for parent/child relationships and uniquely named them eg. Person_parent_to_PersonAddress. We have used a number of these parent/child accessors in customized coding logic, but not the foreign key accessors.
    Is anyone using the foreign key accessors and what function are you using them for? In moving forward with starting this re-usable Business Components .jar file, I am trying to determine if we should be exposing the foreign key source and destination accessors.
    Thanks in advance for any replies.
    Mary
    UofW

    Many thanks for the response. Don't think I can make use of synchronous replication with lookup tables given our own requirements.
    I was thinking however, by employing a hub-and-spoke replication model instead of an N-WAY, that this would avoid foreign key conflicts altogether.

  • 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

  • Oracle 9i primary and foreign key constraint

    I had created table in the following way
    create table dept(deptno number,dname varchar2(20));
    create table emp(empno number primary key,ename varchar2(25), deptno number references dept(deptno));
    One can get constraint name and constraint type from user_constraints table. But I want to know name of the column of table from which column is used as foreign key in another table. How to get such information?

    SQL> Select *From user_cons_columns  A
      2   Where Constraint_Name In (Select r_Constraint_Name
      3                           From User_Constraints B
      4        Where Table_Name='EMP'
      5          And Constraint_Type='R'
      6          Group By r_Constraint_Name
      7          )
      8  /
    OWNER                          CONSTRAINT_NAME                TABLE_NAME                     COLUMN_NAME                       
    SCOTT                          PK_DEPTNO                      DEPT                           DEPTNO                             Edited by: babaravi on Oct 5, 2009 3:34 PM

  • [JPA] Primary key = Foreign key = Failure.

    Hello:
    I've a question regarding the Java Persistence API and a DB design which I'm facing just now. I'm making JPA entities based on a DB schema which is already created. Although sometimes it's not a good idea, I'm going to use a simplified example so you can understand it easily and help me (if you want, of course).
    Let's suppose that I've a table of discs (called "disc", built into a class as "Disc.class") and another one of used discs (called "disc_used", built as "DiscUsed.class"). The first one employs a composite key formed by columns "key1" and "key2". The second one employs the same primary key (conceptually, not physically) which, at the same time, is foreign key respect to the first table.
    I've used the @EmbeddedId annotation on the first case and built a class for the composite key (called "DiscPK.class"). I've done the same task for the second table (calling it "DiscUsedPK.class"). I also have added the corresponding mappings between both classes (of type @OneToOne). This design pattern works fine when employing "Disc.class", but not "DiscUsed.class". I've came to the conclusion that it's because of using the same fields to make an @EmbeddedId and map the @OneToOne relation.
    I've been taking a deep look to the possible annotations which JPA offers, but I've not found anything useful.
    In the past I faced another problem with JPA and composite keys, which made me come to the conclusion that it was my DB design what was faulty (I was combining an auto-numerical field with others to make a composite key, which helped me to understand the logic but was absurd and against the relational logic). May it be a similar misconception on the DB design? I mean, since both tables represent different concepts (discs and used discs), each one with their own attributes (columns), Should the second table use its own auto-numerical primary key instead of re-use the foreign key? Would it be the right approach according to the relational logic?
    Obviously, modifying the original DB by hand and adding its own primary key, it works flawless. However I still need to know the truth (other-way I won't be able to sleep :P ).
    Thank you for your help and interest.

    gimbal2: I'm really sorry, but I didn't get any e-mail notification about your message :S . After having looked for help on several places on the Internet I finally decided not to employ exactly the same columns for a primary key if they were already being employed by a foreign key. The answer from javaUserMuser has also left this matter clarified to me. Thanks for your time also ;) .
    javaUserMuser: I thought that was a problem from my implementation. If it's a common case, then I guess that I did right choosing the easy "path" for one time :) . I agree with you, it's a big frustration. But since I depend on the JPA for my projects, I'll try to set my mind to avoid always this match and employ another primary key instead. Thank you a lot for your explanation :D .

Maybe you are looking for

  • Email is not working in my Nokia Asha 501

    I have a nokia asha 501 and there is mail. But we cant read the mail. What is the use of giving us an app which not even useful. Moderator's Note: We have changed the title into a subject-related title. This is to keep the forum organized and let oth

  • How to installl sun access manager in windows xp

    Hi, Can any one guide me how to install sun access managment in windows xp. I have downloaded access managment 7.x version i didnt find any installation shield nor exe file to install. More over i didnt find any document regarding installation for su

  • HELP! BATTERY DOES NOT CHARGE FUL

    I installed the firmware from the webbie, and now my zen stone plus mp3 player has problem charging fully. The media lite programme says it is only 2% charged but the mp3 player is blinking. I on the mp3 player and it is only 2 bar charged. I tried t

  • Driver Development

    We seeking persons or companies with experience in writing hardware drivers for LabView and Visual Basic. Thank You Sam Caldwell BMIC

  • Edit Std. IDoc Segments

    Dear All, Hope you guys are doing good. I have a requirement where i have to change the field length of IDoc DELVRY05 segment E1EDL24 Release 700 for the field LGMNG from 15 to 9. Can someone tell me how can i achieve this? Regards, Raj