Update primary key that’s also a foreign key in another table

Hi Developers,
I need to update the primary key for a record but it's also the foreign key in another table.
Example,
Table 1 Details
Name : Parent_Table
Columns : ID, Name, Age
Primary Key : ID
Table 2 Details
Name : Child_Table
Columns : ID, Parent_ID, Name, Age
Primary Key : ID
Foreign Key : Parent_ID (Primary Key in Parent_Table)
Parent_Table
ID Name Age
1001 Sam 26
1002 George 25
Child_Table
ID Parent_ID Name Age
1010 1001 Sam 26
1020 1002 George 25
Now I want to update ID (1001) in Parent_table as 2001 and also, I want to update Parent_ID (1001) in Child_Table as 2001.
How we will write the java code to update these columns.
Thanks in advance.

dcminter wrote:
If you're looking at changing the primary keys in your data then there's probably something wrong with your data structure.Depends how you feel about business primary keys versus surrogates. Personally I prefer the latter so I'm with you in theory. In practice, however, a DB that uses a business PK may well find that it's a legitimate use case to change the key value (but then that's why I like surrogates in the first place!)Primary keys should not have meaning.

Similar Messages

  • How can I have multiple instances of a column that itself holds a foreign key reference?

    I am new to Visual Studio so to start learning it I first of all downloaded a sample available at https://code.msdn.microsoft.com/ADPNET-Entity-Framework-2d1160cb and started working around it. Since I have fairly good knowledge of VB6 and SQL it did
    not take much time for me to understand the whole pattern the sample is based on. Had Microsoft given a detail explanation or a walk through of the sample it would have been much easier to understand the basics. However, I somehow managed to work around it
    and have build a small desktop application in wpf using Entity Framework and MVVM. But a point has come where I have got completely stuck up finding no way out. The problem is as under:
    I have two tables. 1 Advocate and 2 Party. Table Advocate would contain names of advocates and would have a primary key. Similarly Party would have names and their respective primary keys.
    Then I have another two tables 1. Case and 2 CaseDetail. Table Case would simply hold three columns: 1. CaseId 2. CaseNo and 3. Year. Table CaseDetail would have CaseDetailId as a primary key the CaseId as a Foreign Key. Now what I need is that a particular
    case could have multiple advocates and multiple petitioners. So the table CaseDetail would have two columns to hold advocateId and PartyId as a Foreign Keys. 
    If you look at the sample referred above you would not find how to deal with such a case. When I follow the pattern of the sample I get host of design time and runtime errors. 
    Therefore, please suggest what strategy should be adopted in a scenario described above while developing WPF application using Entity Framework and MVVM.

    I am new to Visual Studio so to start learning it I first of all downloaded a sample available at https://code.msdn.microsoft.com/ADPNET-Entity-Framework-2d1160cb and started working around it. Since I have fairly good knowledge of VB6 and SQL it did not
    take much time for me to understand the whole pattern the sample is based on. Had Microsoft given a detail explanation or a walk through of the sample it would have been much easier to understand the basics. However, I somehow managed to work around it and
    have build a small desktop application in wpf using Entity Framework and MVVM. But a point has come where I have got completely stuck up finding no way out. The problem is as under:
    I have two tables. 1 Advocate and 2 Party. Table Advocate would contain names of advocates and would have a primary key. Similarly Party would have names and their respective primary keys.
    Then I have another two tables 1. Case and 2 CaseDetail. Table Case would simply hold three columns: 1. CaseId 2. CaseNo and 3. Year. Table CaseDetail would have CaseDetailId as a primary key the CaseId as a Foreign Key. Now what I need is that a particular
    case could have multiple advocates and multiple petitioners. So the table CaseDetail would have two columns to hold advocateId and PartyId as a Foreign Keys. 
    If you look at the sample referred above you would not find how to deal with such a case. When I follow the pattern of the sample I get host of design time and runtime errors. 
    Therefore, please suggest what strategy should be adopted in a scenario described above while developing WPF application using Entity Framework and MVVM.

  • Primary key  ID ... Foreign key iD ???

    Here is the setup. I have a database on a SQL server and have
    created a form to input data into this database (with Dreamweaver
    and CF).
    Let me start out by telling you basically how this data base
    is setup:
    3 tables:
    - tblPatients (which is the main table). Primary key is ID
    (an auto number field).
    - tblDiagnosis (which only houses an ID field and code field
    called DSMIV). The ID in the tblDiagnosis table is a foreign key
    and is linked to the tblPatients table’s ID.
    -tlkpDiagnosis just house all the possible diagnosis.
    I am able to input data into both tblPatients table and the
    tblDiagnosis table, BUT the ID (foreign key) field in the
    tblDiagnosis table is left empty thus left orphaned with no way to
    tight it back to the data in the patient table. My code is below.
    Thank you for any help you can provide me.
    PROCESS PAGE CODE:
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfif IsDefined("FORM.MM_InsertRecord") AND
    FORM.MM_InsertRecord EQ "form1">
    <cfquery datasource="dsnPsychiatry">
    INSERT INTO dbo.tblPatients (NewContinuous, ResidentID,
    ResidentInitial, Age, Race, Sex, EmploymentStatus, HP, MedCheck,
    Therapy30Minute, Therapy60Minute, TherapyGroup, ECT, Inpatient,
    Outpatient, EmergencyRoom)
    VALUES (
    <cfif IsDefined("FORM.NewContinuous") AND
    #FORM.NewContinuous# NEQ "">
    <cfqueryparam value="#FORM.NewContinuous#"
    cfsqltype="cf_sql_clob" maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.ResidentID") AND #FORM.ResidentID#
    NEQ "">
    <cfqueryparam value="#FORM.ResidentID#"
    cfsqltype="cf_sql_clob" maxlength="10">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.ResidentInitial") AND
    #FORM.ResidentInitial# NEQ "">
    <cfqueryparam value="#FORM.ResidentInitial#"
    cfsqltype="cf_sql_clob" maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.Age") AND #FORM.Age# NEQ "">
    <cfqueryparam value="#FORM.Age#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Race") AND #FORM.Race# NEQ "">
    <cfqueryparam value="#FORM.Race#" cfsqltype="cf_sql_clob"
    maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.Sex") AND #FORM.Sex# NEQ "">
    <cfqueryparam value="#FORM.Sex#" cfsqltype="cf_sql_clob"
    maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.EmploymentStatus") AND
    #FORM.EmploymentStatus# NEQ "">
    <cfqueryparam value="#FORM.EmploymentStatus#"
    cfsqltype="cf_sql_clob" maxlength="10">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.HP") AND #FORM.HP# NEQ "">
    <cfqueryparam value="#FORM.HP#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.MedCheck") AND #FORM.MedCheck# NEQ
    "">
    <cfqueryparam value="#FORM.MedCheck#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Therapy30Minute") AND
    #FORM.Therapy30Minute# NEQ "">
    <cfqueryparam value="#FORM.Therapy30Minute#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Therapy60Minute") AND
    #FORM.Therapy60Minute# NEQ "">
    <cfqueryparam value="#FORM.Therapy60Minute#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.TherapyGroup") AND
    #FORM.TherapyGroup# NEQ "">
    <cfqueryparam value="#FORM.TherapyGroup#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.ECT") AND #FORM.ECT# NEQ "">
    <cfqueryparam value="#FORM.ECT#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Inpatient") AND #FORM.Inpatient#
    NEQ "">
    <cfqueryparam value="#FORM.Inpatient#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Outpatient") AND #FORM.Outpatient#
    NEQ "">
    <cfqueryparam value="#FORM.Outpatient#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.EmergencyRoom") AND
    #FORM.EmergencyRoom# NEQ "">
    <cfqueryparam value="#FORM.EmergencyRoom#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    </cfquery>
    <cfloop list="#FORM.DSMIV#" index="diagnosis">
    <cfif IsDefined("FORM.DSMIV") AND #FORM.DSMIV# NEQ "">
    <cfquery datasource="dsnPsychiatry">
    INSERT INTO dbo.tblDiagnosis (DSMIV)
    VALUES (
    <cfqueryparam value="#diagnosis#" cfsqltype="cf_sql_clob"
    maxlength="50">
    </cfquery>
    </cfif>
    </cfloop>
    </cfif>

    Ok that didn't work. Most likely due to my lack of knowledge
    when it comes to this.
    I've been doing some research on Stored Prcedures, and
    thought it might be the answer to my problems.
    Here is the code I came up with.
    First is the Stored Procedure (on the SQL Server):
    CREATE PROCEDURE spInsertDiagnosis
    @ID integer,
    @DSMIV varchar(25)
    AS
    insert into tblDiagnosis (ID, DSMIV) values (@ID, @DSMIV)
    GO
    Second, is the CF on my process page
    <cfif IsDefined ("ID") AND #ID# NEQ "">
    <cfif IsDefined("FORM.DSMIV") AND #FORM.DSMIV# NEQ "">
    <CFSTOREDPROC procedure="dbo.spInsertDiagnosis"
    datasource="dsnPsychiatry">
    <CFPROCPARAM type="IN" dbvarname="@ID" value="#ID#"
    cfsqltype="CF_SQL_INTEGER">
    <CFPROCPARAM type="IN" dbvarname="@DSMIV" value="#DSMIV#"
    cfsqltype="CF_SQL_VARCHAR">
    </CFSTOREDPROC>
    </cfif>
    </cfif>
    NOTE: The above CF code replaced the below on my process page
    (ref to first post).
    <cfloop list="#FORM.DSMIV#" index="diagnosis">
    <cfif IsDefined("FORM.DSMIV") AND #FORM.DSMIV# NEQ "">
    <cfquery datasource="dsnPsychiatry">
    INSERT INTO dbo.tblDiagnosis (DSMIV)
    VALUES (
    <cfqueryparam value="#diagnosis#" cfsqltype="cf_sql_clob"
    maxlength="50">
    </cfquery>
    </cfif>
    </cfloop>
    PROBLEM now is, in doing this now nothing gets inserted into
    the Diagnosis table. Obviously I do not know how to correctly
    insert the stored procedure into my process page.

  • CMR - Can a primary key also be a foreign key?

    Hi,
    Has anyone come across the following problem? Although I mention Jdeveloper below I believe it is a general J2EE issue!
    I have two tables
    customer
    customer_id (PK)
    individual
    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

    Hi Kevin,
    I would not pursue this model if I was you. The only thing OC4J supports without killing yourself is to let each table has its own primary key (preferably not composed) and to make all foreign key's optional !
    We have spent months trying to make it work and we are getting little or no support from oracle, even though we are paying many euros for a partnering contract.
    greetz,
    Jurgen

  • 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

  • Two columns in the same table that are foreign keys to the same master key

    i want to create a table let say X, which have two columns that are foreign key that reference the same column in the master table, so does this count as bad database design.

    here is the full ddl for the two table, where in the second table there are two columns that represent the primary key and they are also two foreign keys to the same columns in the master table (items)
    Desc item table;
    Item_id
    Item_name
    Item_price
    Item_quantitiy
    Create table item_recommendation ( item_id varchar(20), recommended_item varchar(20),
    CONSTRAINT recom_primary PRIMARY KEY (item_id, recommended_item),
    CONSTRAINT F1 FOREIGN KEY (item_id) REFERENCES items(item_id), ),
    CONSTRAINT F2 FOREIGN KEY (recommended_item) REFERENCES items(item_id));

  • Primary key foreign key dependencies

    hi gems...
    I have a table with composite primary key (COL1, COL2)..
    create table TABLE1 (COL1, COL2);
    alter table TABLE1 add constraint PK_TABLE1 primary key (COL1, COL2);
    Now i am trying to make another table which will refer to the COL1 of the first table.
    create table TABLE2 (COL3, COL4);
    alter table TABLE2 add constarint FK_TABLE2 (COL3) references TABLE1(COL1);
    but it is failing with "no matching unique or primary key" error.

    You have created a composite primary key, so there must be composite foreign key that references the composite primary key. You cannot create Foreign key that references to single column of the composite primary key.

  • Foreign key constraint on multi-column primary key accepts 1 empty column!?

    Hi, we have a reference table with a two-column primary key. In the child table there is a non-mandatory foreign key constraint to this table. So if both child columns are null it's ok too. But now we see that if one of the two child table columns that build up the foreign key is null, the other column can have any (non-existant in the master-tabel) value you like!? That does not make sense.
    Can anyone explain this to me???
    Regards, Paul.

    Paul, I believe that this is in accordance to the ANSI SQL standard requirement for the treatment of nulls in a multi-column FK. In any case Oracle specifically states this is the way FK work From the 10 Concepts manual, Ch 21 Data Integrity, topic Nulls and Foreign Keys:
    The relational model permits the value of foreign keys either to match the referenced primary or unique key value, or be null. If any column of a composite foreign key is null, then the non-null portions of the key do not have to match any corresponding portion of a parent key. <<HTH -- Mark D Powell --

  • Primary key and Foreign key on same column

    Hi, I am able to create below tables , primary and foreign keys as below.
    But Is this valid design? Can I define a column (ckey2 in table "child") as
    primary key and as well as foreign key?
    CREATE TABLE parent (
    col1 NUMBER,
    col2 NUMBER
    CREATE TABLE child (
    ckey1 NUMBER,
    ckey2 NUMBER,
    ckey3 NUMBER
    alter table parent add constraint parent_pk primary key( col1 );
    alter table child add constraint child_pk primary key( ckey2 );
    alter table child add constraint child_fk foreign key( ckey2 ) references parent( col1);
    Thanks.

    Can I define a column (ckey2 in table "child") as primary key and as well as foreign key?You mean you want to define a one-to-one relationship between parent and child tables.. why would you want to do that ? You might as well merge the 2 tables into one.

  • Using FOreign key constraints on tables in database.

    I am student and novice in the field of ORACLE and PL/SQL and Database Creation. I had created a database consisting tables and got problem while applying foreign key constraints.
    CUST_MSTR
    CREATE TABLE "DBA_BANKSYS"."CUST_MSTR"("CUST_NO" VARCHAR2(10),
    "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25), "LNAME" VARCHAR2(25),
    "DOB_INC" DATE NOT NULL,      "OCCUP" VARCHAR2(25), "PHOTOGRAPH" VARCHAR2(25),
    "SIGNATURE" VARCHAR2(25), "PANCOPY" VARCHAR2(1),      "FORM60" VARCHAR2(1));
    (CUST_NO is PRIMARY KEY, )
    -- EMP_MSTR
    CREATE TABLE "DBA_BANKSYS"."EMP_MSTR"("EMP_NO" VARCHAR2(10),
    "BRANCH_NO" VARCHAR2(10), "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25),
    "LNAME" VARCHAR2(25), "DEPT" VARCHAR2(30), "DESIG" VARCHAR2(30));
    (EMP_NO is primary key )
    --NOMINEE_MSTR
    CREATE TABLE "DBA_BANKSYS"."NOMINEE_MSTR"("NOMINEE_NO" VARCHAR2(10),
    "ACCT_FD_NO" VARCHAR2(10), "NAME" VARCHAR2(75), "DOB" DATE,
    RELATIONSHIP" VARCHAR2(25));
    (NOMINEE_NO is primary key )
    --ADDR_DTLS
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6));
    ( ADDR_NO is primary key )
    Problem: I want to apply foreign key constraints on ADDR_DTLS table so that Before inserting value in ADDR_DTLS table it must check, VALUE in ADDR_DTLS.CODE_NO must be PRESENT either in attribute value CUST_MSTR.CODE_NO or EMP_MSTR.CODE_NO or NOMINEE_MSTR.CODE_NO table .
    I applied the foreign key constraints using this syntax
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6),
    constraints fk_add foreign key CODE_NO references CUST_MSTR. CODE_NO,
    constraints fk_add1 foreign key CODE_NO references EMP_MSTR. CODE_NO,
    constraints fk_add2 foreign key CODE_NO references NOMINEE_MSTR.CODE_NO);
    (foreign key)
    ADDR_DTLS.CODE_NO ->CUST_MSTR.CUST_NO
    ADDR_DTLS.CODE_NO ->NOMINEE_MSTR.NOMINEE_NO
    ADDR_DTLS.CODE_NO ->BRANCH_MSTR.BRANCH_NO
    ADDR_DTLS.CODE_NO ->EMP_MSTR.EMP_NO
    When I applied foreign key constraints this way, its gives a error called foreign key constraints violation. (I understand that, its searches the attribute value of ADDR_DTLS.CODE_NO in all the three tables must be present then the value will be inserted. But I want, if the value is in any of the three table then its should insert the value or its gives an error.)
    Please help me out, though i put the question and i want too know how to apply the forign key in this way. and is there any other option if foreign key implementation is not pssible.

    If you are on 11g you can use ON DELETE SET NULL:
    CREATE TABLE addr_dtls
    ( addr_no          NUMBER(6)  CONSTRAINT addr_pk PRIMARY KEY
    , addr_cust_no     CONSTRAINT addr_cust_fk    REFERENCES cust_mstr    ON DELETE SET NULL
    , addr_emp_no      CONSTRAINT addr_emp_fk     REFERENCES emp_mstr     ON DELETE SET NULL
    , addr_nominee_no  CONSTRAINT addr_nominee_fk REFERENCES nominee_mstr ON DELETE SET NULL
    , addr_type        VARCHAR2(1)
    , addr1            VARCHAR2(50)
    , addr2            VARCHAR2(50)
    , city             VARCHAR2(25)
    , state            VARCHAR2(25)
    , pincode          VARCHAR2(6) );In earlier versions you'll need to code some application logic to do something similar when a parent row is deleted, as otherwise the only options are to delete the dependent rows or raise an error.
    btw table names can be up to 30 characters and don't need to end with MSTR or DTLS, so for example CUSTOMERS and ADDRESSES might be more readable than CUST_MSTR and ADDR_DTLS. Also if the Customer/Employee/Nominee PKs are generated from a sequence they should be numeric.
    Edited by: William Robertson on Aug 15, 2010 6:47 PM

  • Dropdown List in table - multicolumn foreign key

    Hello,
    Steve Muench has a nice screencast how to create a dropdown list in an editable adf table.
    Is there a way how to update this example to work with multicolumn foreign key between edited table and lookup table?
    Let's say lookup table has Code, Line attributes as primary key and edited table has foreign key attributes MasterCode and MasterLine. How populate the FK attributes by dropdown list?
    For editable table it's probably not possible directly from dropdown list. I tried to find a solution but I had problem to identify which lookup row was selected.
    Rado

    ok i have checked that for the past few days but its not what i want.
    i am using wizard to do this and i need to populate the database table records (individual field names) and display in the table control dropdown list.
    what the demo shows is only how to display a dropdown list with reference to the table names.

  • Question on indexing foreign key for replicated table

    Hi everybody,
    I have 2 tables with following script
    create table
    parent(parent_id number(2) not null,
    parent_name varchar(20),
    constraint parent_pk primary key(parent_id))
    create table child(child_id number(2) not null,
    parent_id number(2) not null,
    child_name varchar2(20),
    constraint pk_child primary key(child_id,parent_id),
    constraint fk_child foreign key (parent_id) references parenr(parent_id)
    I want to replicate them and I know to replicate these 2 tables i should add them to my replication group, my question is that the child_id has foreign key so as below link says
    http://dbataj.blogspot.com/2007/11/advance-replication-part-ii-master.html
    I should put an index on the foreign key.What type of index should it be and is the following script correct for my purpose?
    CREATE BITMAP
    INDEX "fk_child"
    ON child ("PARENT_ID")
    TABLESPACE "USERS"
    I would appreciate your help in advance.
    Mery

    A bitmap index is almost certainly not the sort of index you'd want to create. You would normally want just a normal index, i.e.
    CREATE INDEX fk_child
      ON child( parent_id )on the master database just to support normal DML operations (otherwise, deleting a row from the parent table requires doing a full table scan on the child table to see if there are any orphaned child records).
    If you are trying to set up a multi-master replication environment, you would also need to replicate this index, since you'll want to support basic DML on both nodes.
    Justin

  • Data Modeler foreign key names

    Hi,
    I've been using Data modeller for a while now and it works beautifully, anyhow there is an issue I would appreciate if anybody can help me in.
    For foreign keys, if the master table primary key is names ID, the foriegn key will be ID also, and if already there is an ID column column in the detail table, it will be ID1, ID2 ....
    Can I change the naming method to be like the oracle designer, or any convention I would like ??
    Thanks
    AK

    I'm using the Logical Model V 1.5.1Paul,
    it's pre-production release. Data Modeler is free now and you can download current published release - it.s version 2.0.0.584.
    There is "Attributes" page in relationship dialog (version 2.0) and you can see attributes generated by that relationship.
    For foreign keys in relational model - there is "Associated columns" page, you also can see referred key there.
    Naming templates for FK columns and attributes can be defined in version 2.0.0.584.
    Philip

  • How to get multiple row data in single row for one value of foreign key

    i want to get data from a table in a way that all the emp_id corresponding to one manager_id
    in employee table come in one row. (emp_id is the primary key and manager_id is the foreign key) Since there are different emp_id whose manager_id is same
    so how can i get all the emp_id in one row .

    One way with 10g:
    select mgr,
           rtrim(xmlagg(xmlelement(empno,empno||',').extract('//text()')),',')  emps
    from emp
    where mgr is not null
    group by mgr;10g:
    -- define this function:
    create or replace
    function concatenate(c Sys_refcursor, sep varchar2 default null) return varchar2
    as
      val varchar2(100);
      return_value varchar2(4000);
    begin
    --  open c;
      loop
      fetch c into val;
      exit when c%notfound;
      if return_value is null then
        return_value:=val;
      else
        return_value:=return_value||sep||val;
      end if;
      end loop;
      return return_value;
    end;
    select mgr,
           concatenate(cursor(select empno from emp e where e.mgr=emp.mgr order by empno),',')
    from emp
    where mgr is not null
    group by mgr;With 11g:
    select mgr,
           listagg(empno,',') within group (order by empno) emps
    from emp
    where mgr is not null
    group by mgr;

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

Maybe you are looking for

  • Created an image using Apple 10.6.5 with Acrobat Pro 9.4.1 and CS 5

    Greetings All.  Have a Happy, Healty New Year. As I open Acrobat Pro I am instructed to open Photoshop (or other App) first, which I did. Again I opened Acrobat Pro and rec'v message stating Acrobat Pro was installed as part of a suite and in order t

  • "Skype Home Unavailable"

    I've got this problem for more than a year every time i enter skype this is what i see "Skype Home Unavailable Skype home is unavailable at the moment. Check back later to see your news and alerts. its easy to start a conversation on skype: -Choose a

  • Repeated columns in export to excel

    Dear all, I ve gone thr. many forums for this problem bt cud nt find the rite soln. I m trying to export the data from web dynpro table to excel sheet but when the numeric column is transported then that column gets repeated with alias '#agg'. Please

  • How does this query work?

      UPDATE medfileinfo mf       SET total_tap_count = total_tap_count-                                (SELECT   COUNT (1)                                     FROM rating_temp rt                                    WHERE ( ( ( (calledcallzone IS NULL) OR

  • Adobe CS5.5 Master collection not installing

    Adobe CS5.5 Master collection not installing