referential integrity distributed

Hi, I have a question. If I'm on the wrong forum please direct me because I couldn't find a specific forum for distrituted databases and it can be a matter of application development.

I implement a simple distributed database application. At this point I fear that with the creation of two tables of each on a different server. For the simplicity I will be their name table1 and table2. This is the scheme if the tables were not distributed and were located on the same server.

CREATE TABLE table1)
PRIMARY KEY of the CONSTRAINT of the NUMBER of table1_pk table1_id
);

CREATE TABLE table2)
NUMBER of table2_id
NUMBER of table1_id
CONSTRAINTtable2_pk PRIMARY KEY (table2_id, table1_id),
CONSTRAINT table2_fk FOREIGN KEY (table1_id) REFERENCES table1 (table1_id)
);

I talked about literature in the database Oracle® 10g Release 2 Administrator's Guide (10.2) and the Oracle database applications developer's Guide. I know I can't use declarative referential integrity, but how can I distribute the tables so that I can be sure that when I insert a row in table2, I can check to see if there is a corresponding line in table 1 for table1_id?

Actually, I expect that you will review your architecture.

It makes no sense to search one matching row in table1 a remote database when the data is inserted in table2 in a local database. The best scenario would be that each insertion in table2 would be overloading a network round trip plus costs of querying the table in the remote database. If the network is down or if one of the two databases is down, the application fails, that beats in general the object of a distributed application. In addition, there will be all sorts of concurrency issues (i.e. I remove a line, but before I commit to you ask the line, to see there and insert a child line.) I agree, leaving your orphan line).

Assuming that you really do need a distributed architecture, you want to replicate table1 to the nodes the and remote. Then, you would report to referential integrity between your local copy of table1 and table2 (as well as between table1 and table2 on the remote database, assuming you wanted to table2 data available here as well). Your replication process (preferably using stream but potentially use the multi master materialized views rather) will then be coded to process the errors due to the asynchronous nature of replication (that is to notice that database1 deleted a parent row that you just inserted a child line for and solve the conflict in an appropriate manner).

Justin

Tags: Database

Similar Questions

  • ODI - deactivation and activation of referential integrity

    Hi all

    To run load ETL I must disable and then enable referential integrity of one of my paintings. I can do this by using the procedure. But after loading the disbabled interface and then, how can I automatically reverse-engineering of the table? Must she be dom = do manually or y at - it an option to automate the reverse engineering as well.

    Thanks for your time and your help.

    Just to clarify: you sound like foreign key in the Oracle database? Or are you talking about a foreign key defined in ODI logic?

    In the first case, you will need to reactivate the key on the database. Reverse engineering, something in ODI just get the metadata of ODI to be conscious, but nothing in the database changes.
    In the second case, you can disable checking of the constraint on the control tab (or you can set the flow control to false if you do not need at all).

    It is possible to reverse engineer the tables using the SDK, but I don't think you need: https://blogs.oracle.com/dataintegration/entry/odi_11g_scripting_a_reverse

  • Checking the referential integrity of a form before the presentation of the Page element

    Hi, OTN,.

    I have a form on a table with multiple columns, some of which are foreign keys to other tables. Rather than validate the columns for referential integrity when the user inserts/changes in shape, I would use a dynamic action to attract the attention of the user with a javascript alert() when the user loses focus of the element. After a user enters a value into the text box and moves to the next item, I want to be able to query the table, check the existence of the value of the user and issue a javascript alert() if there is no match.

    What is the best way to go about this?

    I created a dynamic action-to run PL/SQL code on one of the elements of the page, with a code similar to the following:

    DECLARE
    rf_check varchar2 (30);
    BEGIN
    SELECT col1 INTO table_a FROM rf_check
    WHERE col1 =: P1_ITEM_FK;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    HTP.p ("< script type =" text/javascript"> ');
    HTP.p ("alert ("ERROR");");
    HTP.p ("< /script >" ");
    END;

    I could not get the dynamic action of delivering javascript. Any thoughts?

    Thank you

    Matthew Moisen

    Published by: Matthew Moisen on 25 October 2012 14:22

    Matthew Moisen wrote:
    What is the best way to go about this?

    I have to admit that I've never tried, but I would be surprised if Javascript back via statements made htp.p that they are actually executed by the browser.

    I would do something like that, by a dynamic action that calls an application process. The PL/SQL procedure request would return via htp.p OK or ERROR. From this result, the javascript would determine to issue the alert. Something like the following (not fully tested):

    Javascipt
    
     var get = new htmldb_Get(null,html_GetElement('pFlowId').value, 'APPLICATION_PROCESS=FK_CHECK',0);
     var fk_check = get.get();
    
     if (fk_check=='ERROR')
      {
       alert('ERROR');
      }
    
    Application Process FK_CHECK
    
    DECLARE
      rf_check varchar2(30);
    BEGIN
      SELECT col1 INTO rf_check FROM table_a
      WHERE col1 = :P1_ITEM_FK;
      HTP.p('OK');
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
         HTP.p('ERROR');
    END;
    
  • Referential integrity does not not for attributes 'user defined '.

    Hello

    I have trouble getting the referntial integrity to work with auxiliary attributes. I have a custom scheme I imported to the ODSEE that I would like to have referential integrity enabled for all DN links.

    To activate the referential integrity, I have done:

    (1) dsconf game-server-prop - h host Ref port - p-integrity - attr:attribute - name-Ref-integrity - attr:attribute - name (it gave me an error if there were spaces around the------so I removed the)
    (2) dsconf game-server-prop - h: host Pei Ref-integrity-enabled port: on
    (3) adds an index for each attribute (equal) in the suffix whetre objects are
    (4) restart the DS instance

    Referential integrity works for members, but not one of my custom attributes. I have also no log instance-path/logs/referint file...

    Any ideas?

    Yes, pluginarg3 and more should be your attributes syntax DN you want to maintain on referential integrity. You have over 100 separate DN syntax of the attributes that you want to enable referential integrity for? It is waay more than I've seen before.

    You don't want to change the dse.ldif file while the server is in place. If you do, you will lose your changes when the server restarts. I think it's weird that your dsconf command did not work. If you want to solve problems which you can activate the audit log and run the dsconf commands to see what changes the tool brings to the config.

    Maybe this syntax does not work:

    dsconf game-server-prop - h host Ref port - p-integrity - attr:attribute - name-Ref-integrity - attr:attribute - name

    I think I only used the plugin properties to configure this in the past, but to be honest, I usually run just a ldapmodify with an LDIF.

  • referential integrity with a view to the parent table

    Is it possible to create a foreign key that uses a view as the parent table?

    CREATE TABLE one
    + (id NUMBER CONSTRAINT a_pk PRIMARY KEY, +)
    name VARCHAR2 (32));

    CREATE TABLE b
    + (name of the b_pk VARCHAR2 (32) CONSTRAINT PRIMARY KEY, +)
    address VARCHAR2 (32));

    CREATE VIEW b_view AS SELECT * FROM b;

    ALTER VIEW b_view ADD CONSTRAINT b_view_pk PRIMARY KEY (name) DISABLE NOVALIDATE;

    ALTER TABLE an ADD CONSTRAINT a_fk
    B_view (name) REFERENCES of FOREIGN KEY (name);

    "After issuing the last alter statement I get the error: ' ORA-02270: no unique or primary key corresponding to this list of columns.

    If I use just the table b of referential integrity, everything works. Is this just a limitation of the use of the view with a PK defined as disable novalidate? Is there a workaround to use the view?

    Thank you
    mcslain

    AFAIK, you can create constraints on views, purely for the sake of documentation.
    Sense: these constraints are never implemented, they must be defined using the NOVALIDATE keywords to DISABLE.

    And since these constraints, say the b_view_pk in your case, are DISABLED/NOVALIDATE, you cannot have a foreign key (ENABLED), which points to them.

    Pouvez have you a foreign key pointing at them is DISABLED/NOVALIDATE too, however.
    But I bet it's not what you want.

  • Referential integrity constraints - Impact on performance

    Y at - it any performance overhead to create constraints in referential integrity on the tables (not seen)? Can someone tell me please a documentation of oracle on the impact of the creation of RIs on peformance on the db tables?

    Thank you
    Kevin

    Please check that it has everything you need

    http://tonguc.WordPress.com/2007/01/19/what-is-the-overhead-of-referential-integrity-on-the-database/

    and don't forget to create indexes on the keys

    Coskan Gundogar

    http://Coskan.WordPress.com

  • triggers to enforce referential integrity

    I have trouble to configure a trigger for me to ensure referential integrity. I choose a trigger because I do believe that it is possible to configure using constraints.

    My parent (HAB) table is the following structure:

    H_ID NUMBER PK
    H_CODE VARCHAR2
    H_DESCRIPTION

    The child table (ATT) is as follows

    so_id NUMBER PK
    COLUMN-NAME VARCHAR2 PK
    VALUE VARCHAR

    The ATT table contains information of documents referring to the HAB table, in these instances col_name = "HAB" (it may also contain several other value that does not refer to the table of HAB)
    When the COL_NAME = "HAB" I want to check that the VALUE column contains a value that is present in H_ID inhabitants.

    Is it possible to do with relaxation, I can't understand how to add a where clause clause, so I apply the trigger only when the column column_name = 'HAB '.

    Here is my code so far:

    CREATE OR REPLACE TRIGGER TRG_BRYO_ATT_HAB
    BEFORE THE INSERT OR UPDATE
    VALUE
    ON SO_BRY_ATT
    REFERENCING NEW AS new OLD IN the old
    FOR EACH LINE
    WHEN
    (NEW. VALUE IS NOT NULL)

    DECLARE
    INTEGER model; -used for the extraction of slider below
    Invalid_habitat EXCEPTION;
    Valid_habitat EXCEPTION;
    Mutating_table EXCEPTION;
    PRAGMA EXCEPTION_INIT (Mutating_table,-4091);

    CURSOR Dummy_cursor (hc NUMBER) IS
    SELECT h_id FROM hab
    WHERE h_id = hc
    FOR the UPDATE OF h_id.


    BEGIN

    OPEN Dummy_cursor (: New.value);
    EXTRACT Dummy_cursor IN model;


    IF Dummy_cursor % NOTFOUND THEN
    RAISE Invalid_hab;
    ON THE OTHER
    RAISE valid_hab;
    END IF;
    CLOSE Dummy_cursor;
    EXCEPTION
    WHEN Invalid_hab THEN
    CLOSE Dummy_cursor;
    Raise_application_error (-20000, 'invalid hab'
    || "code" | To_char (:New.value));
    WHEN Valid_hab THEN
    CLOSE Dummy_cursor;
    WHEN Mutating_table THEN
    NULL;

    END TRG_BRYO_ATT_HAB;



    /

    No indication on how to do this, or suggestions for the best ways to enforce this would be very appreciated.

    Thank you

    Stef

    Hello

    The reason why I want to separate data atts of standard data, it's that I want to if ensure that the database is extensible, for example if we start obtain additional data of a type new stadium for example, I don't want to have to enter a new column in the standard data column, but rather power to att in the atts table as a new type of name of column

    The short answer is, STOP! Don't, don't.

    You want to ensure that the database is expandable? -It is, just add the columns when you need it. As you say yourself, "* if * we start obtain additional data of a new type."

    When you create this kind of datamodel (that you should not), you are bound to run into all kinds of problems. One being your current with referential integrity. Other people in trouble by querying your data to produce reports, general performance, a.s.o., a.s.o. problems.

    I've only seen a situation where such a design could be claimed. It's an application where a requirement was that end-users should be able to create new entities and attributes to use immediately in the application. This doesn't seem to be the case in your situation.

    Concerning
    Peter

  • exact number of lines deleted when on_delete_cascade is active in the referential integrity

    Hi all

    I have here the question (restructured for simplicity):

    Suppose that I have a table used, which has a primary key emp_id and a mgr_id foreign key referencing emp_id:

    create table abc () number Middle eid number

    constraint of pk primary key(eid),

    constraint of fk stranger key (mid) referencing abc(eid) on delete cascade

    )

    Select * de abc

    EIDMID
    4
    1
    21
    31
    51
    62

    If I issue a delete as below:

    delete from abc where eid = 1

    After running above sql, the number of rows sql % gives me the deleted rows = 1, but in fact, had to remove cascade, 5 rows are deleted.

    My question is how can I the exact number of rows deleted from the table in this scenario?

    What SQL ROWCOUNT percentage watch you is correct because it shows the number of lines made directly by the statement you issue.  All knock on effects by cascading deletes, or triggers are not included.

    The only real way you'd be able to get a number of lines (assuming nothing else bothers while you do) this is to count the lines service based on your business logic for related lines and then remove them, or maybe put a trigger delete (be aware of the drop in performance) on deletions for lines that puts something like the primary key for a global temporary table (available lines only for your session) that you can then query after how many rows have been completed.

  • Indexes and referential integrity

    I'm working on a database with 1000's of tables with a lot of RI. We used the traditional approach, where each column with a relationship is indexed for performance... This has caused our database index to more than double the size of the data... Some of the larger tables were 15 indices on them in support of RI.

    Given the changes with oracle over the years, I have 2 questions

    (1) with skipscan, can I go out with composite indexes? I think combining some columns that would be wise for queries in a single index (I must watch null values to make sure that I get the best order). Ths is great for performance or it deteriorate too... Someone at - he experiences?

    (2) compression and presentations by oracle Exadata all end with the same statement "you need not even index more... Someone at - it really to see what it means for RI? We would not have to index each referenced column? If oracle saying "you don't need index except for support of RI.

    (3) what about creating unusable index on the column kid make the option optimize see a clue... I think it was a good practice to index the parent and child to help the optimizer, or maybe I'm not remembering right. Maybe something to do with the child column statistics help?

    All backback power would be appreciated.

    Published by: Bryan Greene on September 12, 2009 06:42

    (1) with skipscan, can I go out with composite indexes?

    No, not completely.

    (2) compression and presentations by oracle Exadata all end with the same statement "you need not even index more... Someone at - it really to see what it means for RI? We would not have to index each referenced column? If oracle saying "you don't need index except for support of RI.

    Think about why index is needed on the FK column. One of the main reasons for FK index columns is to avoid different locking issues to simultaneous environment. Oracle recommends index FKs. what Exadata whitepapers means almost no 'need index to support SELECT performance since Exadata provides speeds of sweeping pending'.

    (3) what about creating unusable index on the column kid make the option optimize see a clue... I think it was a good practice to index the parent and child to help the optimizer, or maybe I'm not remembering right. Maybe something to do with the child column statistics help?

    Sometimes the index could help get more accurate estimates of cardinality from of NDV in the index, but this is not the usual case.

  • Referential integrity when you use the account of APEX

    Hello
    I use authentication userid APEX in the app I am building. I would like to use the username in the table as a foreign key. However, given that the user ID is managed by APEX and not in a table that I created, I'm confused that how can I configure a FK on user name when you use the authentication of the APEX.
    I have to configure my own user table if I want to create FKs on the user name?

    Thanks for your help!
    -Reid

    Hey Reid,

    Yes, create your own table to the user. Make a function that takes the user name and password and returns a Boolean value. According to your criteria it should return TRUE for authenticated users and FALSE otherwise.

    Use custom authentication. Make a copy of the plan of Application Express users. Change the function of authentication - built in - to your own function. Read this prudent property by clicking on the label.

    The table user may be related to table all you want with a foreign key.

    Kind regards
    Learco

  • Integrity of referential data across schemas

    Is it possible to define referential integrity across schemas (foreign key with the father and child the table table in different schemas)?

    Yes, also make sure that the schema of the table parent gave rights REFERENCES to this schema to another.

    Khurram

  • Referentail error integrity when changing the name of the entity

    I've updated the metadata file to change an entity name and when I tried to load I received an error of integrity because of some old Journal entries of 2001 to 2003. Is there a way to get around this without changing journal entries?

    Audit of the referential integrity of metadata began at 14:46:19
    ---------------------------------------------------------
    Journals::ACT_APR_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::April has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACT_FEB_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::February has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACT_JAN_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::January has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACT_JUL_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::July has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACT_JUN_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::June has 8 discs Changed: [ENTITY::CAMPINAS]
    Journals::ACT_MAR_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::March has 8 discs Changed: [ENTITY::CAMPINAS]
    Journals::ACT_MAY_TAXADJ Scenario::ACTUAL Year::2003 value: < Parent Curr Adjs > Period::May has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACTUAL2001APR282 Scenario::ActPara Year::2001 value: < Parent Curr Adjs > Period::April has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACTUAL2001DEC282 Scenario::ActPara Year::2001 value: < Parent Curr Adjs > Period::December has 5 documents Changed: [ENTITY::CAMPINAS]
    Journals::ACTUAL2001FEB282 Scenario::ActPara Year::2001 value: < Parent Curr Adjs > Period::February has 2 records Changed: [ENTITY::CAMPINAS]
    Journals::ACTUAL2001MAR282 Scenario::ActPara Year::2001 value: < Parent Curr Adjs > Period::March has 2 records Changed: [ENTITY::CAMPINAS]

    As long as you only change the name of a parent that you will only be affected by any adjustment of currency Parent reviews that have been made to this combination of Parent or entity. The solution to unpost magazines, change the parent and repost reviews will solve the problem for now. You are assuming that this is not recommended. Part of the beauty of HFM is having several organizational structures (hierarchies) and for journals following entities when you move them or change the names (rarely). If you assign a currency parent newspaper to a specific combination of parent/entity and you organizational changes on the road you meet this time. Guard against this by the presence of a default hierarchy that contains all basic entities. You need for each group of currencies. All of our parents are USD, so we only need a group, USD_Journals. Use it as a parent for all entires in Journal of currency Parent. Then, it does not matter what hierarchy the entity appears in the journal will follow and the combination of USD_Journals/Entitiy will never disappear.

    This solution is for parent entities only. Base entities must not change forever the names or the default currency. He created the mess, I was describing earlier and dangerous loss of historical data.

    Published by: GCAPO on March 18, 2013 07:08

  • Question of the integrity of the data during the copy of application

    Hi people

    I get the following error message when you copy of my application to another code. The same error occurs if I copy since in the generator, or export it and re - import using SQL Developer.

    ORA-02091: transaction restored return ORA-02291: integrity (APEX_040100.WWV_FLOW_PAGE_DA_A_AR_FK) violated constraint - found parent key

    I'm guessing that the DA is synonymous with dynamic action, which I did a lot of work on these days. Perhaps A is for stocks, but I don't see what could mean AR. affected Region? I wouldn't have missed clues if the error message mentioned the name or page number of the DA, the origin of the problem.

    Y at - it anyway find out what could be causing the violation of referential integrity so that I can fix or remove? There are a lot of DAs in my application? I could start looking through those with actions that affect the regions, but if someone has a better idea, I'd love to hear it.
    Concerning
    CS

    Hello Chris,

    This is APEX 4.1 bug #13441441 - "DYNAMIC ACTION AFFECTED REGION ID NOT CORRECTLY DELETED WHEN IT SHOULD BE" filed by @Anthony Rayner.

    This might help:

    {: identifier of the thread = 2332962}

    I hope that helps!
    Kind regards
    Kiran

  • integrity constraint

    I am really confused about a question, I received in a job interview...

    Which of the following is not considered to be integrity constraint?

    a. non-Null
    key b.Primary
    c.Unique
    key d.Foreign


    Please tell me... .with reason

    I would say they are all integrity constraints. These documentation says:

    Integrity constraints

    An integrity constraint is a declarative method to set a company for a column of a table. An integrity constraint is a statement about the data in the table is always true but who follows these rules:

    * If an integrity constraint is created for a table and a few data in the existing table do not satisfy the constraint, the constraint cannot be applied.
    * After that a constraint is defined, if the results of a DML statement violates the integrity constraint, then the statement is canceled and an error is returned.

    Integrity constraints are defined with a table and are stored as part of the definition of the table in the data dictionary, so that all database applications follow the same set of rules. When a rule has changed, it should be changed once at the database level and not many times for each application.

    The following integrity constraints are supported by Oracle:

    * NON-NULL: Does not allow null (empty entries) values in a table column.
    * UNIQUE KEY: Does not allow duplicate values in a column or set of columns.
    * PRIMARY KEY: Does not allow duplicate values and NULL values in a column or set of columns.
    * FOREIGN KEY: Requires that each value in a column or set of columns to match a value in a related table, UNIQUE or PRIMARY KEY. Also, FOREIGN KEY integrity constraints define referential integrity actions which dictate that Oracle has to do with dependent data if the data it references is corrupted.
    * CHECK: Does not allow values that do not satisfy the logical expression of the constraint.

  • How can I make sure that changes in a primary key (in the parent table) would also appear directly in the FOREIGN KEY in the child table?

    Forgive my question. I am very new to Oracle.

    How can I make sure that changes in the key primary supplier_id (concerning the supplier table) would also appear directly in the FOREIGN KEY (supplier_id) in the products table?

    Is that not all the primary key and FOREIGN KEY on?

    My paintings:

    I created 2 tables and connect to apply in the data base referential integrity, as I learned.

    CREATE TABLE - parent provider

    (the numeric (10) of supplier_id not null,)

    supplier_name varchar2 (50) not null,

    Contact_Name varchar2 (50).

    CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)

    );

    CREATE TABLE - child products

    (the numeric (10) of product_id not null,)

    supplier_id numeric (10) not null,

    CONSTRAINT fk_supplier

    FOREIGN KEY (supplier_id)

    REFERENCES beg (supplier_id)

    );

    I inserted the following text:

    INSERT INTO provider

    (supplier_id, supplier_name, contact_name)

    VALUES

    (5000, 'Apple', 'first name');

    I expect that the supplier_id (5000) to the provider of the table also appears in the products table under key supplier_id having the same value which is 5000. But this does not happen.

    How to get there?

    Thanks in advance!

    Hello

    What is a foreign key in Oracle?

    A foreign key is a way to ensure referential integrity in your Oracle database. A foreign key means that the values of a table must appear also in another table.

    Ok!??

    What is now the right way to implement referential integrity in your Oracle database that the values of a table must also be included in another table?

    A foreign key referential integrity indeed enfore in ensuring that the value in the child table must have a corresponding parent key (otherwise you will encounter an error, as evidenced by "SomeoneElse"). However, it will never automatically insert a row in the other table.

    If you are looking for a solution that automatically inserts a record in the other table, maybe you should go for triggers:

    See:

Maybe you are looking for