Foreign Key or Referential Integrity

Hi All,
I would like to know whether Sun Java System Directory Server supports the concept of foreign key or referential integrity? I would like to have LDAP entries point to other LDAP entries in a different subtree of the same DIT. Is this possible?
Please help.
Rgds,
anna
(http://missingrainbow.blogspot.com)

What you're asking is called Aliases in the LDAP terminology.
Sun Directory Server does support creating alias objects, but does not support dereferencing them during searches or reads.
Referential Integrity is about removing or changing attributes with the DN syntax when the entry they reference is deleted or renamed. Sun DS does support referential integrity via a plugin. The list of attributes for which it's enforced is configurable (and should be indexed).
Regards,
Ludovic.

Similar Messages

  • One-to-many/foreign keys howto

    I have a situation where I'm trying to assemble a web of data and not make
    JDO mad.
    Here's the structure. I load this data in in batches, with an entry being
    placed in a load history table (H) to track each batch. Each batch
    contains primary (M) records associated with 0..n qualifying records from
    one or both of two auxiliary tables (D, L). All liberally salted with
    primary and foreign keys for referential integrity, and most of the keys
    are compounds, since the "M" identifiers get recycled for each batch load.
    Or, in other words, the "M" key is an ID plus an H key.
    Here's a map:
    H--0..n-->M
    __ +--0..n-->D
    __ +--0..n-->L
    Just to make things even more fun, the primary key of the H table is an
    Oracle 8 "DATE" type, which -- unlike ANSI SQL -- is actually a
    "TIMESTAMP". Kodo is rendering this as a java.util.Date rather than
    java.sql.Date, which is fine, because I need the full millisecond
    resolution. Interestingly, when I altered the schema type to "timestamp",
    load operations failed because the "column value was too big" according to
    Oracle.
    Also adding to the enjoyment, the actual order of presentation of data is
    that ALL M records come in, then ALL D records and finally ALL L records.
    I create my own H when the load starts.
    Now ideally, the whole shooting match will be a single pass/fail
    transaction, but that's for later.
    Right now, I can create the H, no problem and M's no problem. However,
    adding the D's and L's fails come commit time:
    kodo.util.FatalUserException: Attempt to set column "OFAC_ADDRESS.LOAD_ID"
    to two different values: "7/9/04 9:41 AM", "7/9/04 9:41 AM" This can occur
    when you fail to set both sides of a two-sided relation between objects,
    or when you map different fields to the same column, but you do not keep
    the values of these fields in synch.
    The granularity of the timestamps printed isn't making life easier, so I
    double-checked the D record's actual local value
    ADDRESS SERIALIZER A: Fri Jul 09 09:41:58 EDT 2004/Fri Jul 09 09:41:58 EDT
    2004
    ADDRESS SERIALIZER B: 1089380518179/1089380518179 (getTime())
    ADDRESS SERIALIZER C: -1541174818/-1541174818 (hashCode())
    I think I need a clearer understanding of what actions cascade here and
    what actions require manual help. For M, I did a setH(H) plus a
    setHid(H.getId()) and that made it happy. For D's and L's, of course, I
    also have to do a setM(M), where, because of the way the data comes in, I
    had to lookup the previously-stored M based on the M.id plus H.id.
    Now the parent objects contain sets of child objects. In theory, I should
    be adding the newly-created children to those sets, but in practice,
    setting the parent on the child appears to cause this to happen
    automagically, though I still have to manually set the local value of the
    foreign key field.
    I really need to find a good FM to RT. Online (and in the Kodo docs), I
    find a lot about setting up the XML for one-to-many mapping, but the Java
    coding side is taken as obvious. Regrettably, few things are obvious to me.
    I suppose I should excerpt the schema just for completeness:
    <table name="LOAD_HISTORY">
    <pk name="SYS_C0036906" column="LOAD_ID"/>
    <column name="LIST_TYPE" type="varchar" size="32"/>
    <column name="LOADED_BY" type="varchar" size="32"/>
    <column name="LOAD_ID" type="date" not-null="true" size="7"/>
    <column name="SUNSET_TIME" type="date" size="7"/>
    <fk name="FK_LOADHISTORY_LOADEDBY" delete-action="exception"
    to-table="OFAC.OFAC_USERS" column="LOADED_BY"/>
    </table>
    <table name="OFAC_ADDRESS">
    <pk name="SYS_C0036904">
    <on column="ADDRESS_ID"/>
    <on column="LOAD_ID"/>
    </pk>
    <column name="ADDRESS" type="varchar" size="125"/>
    <column name="ADDRESS_ID" type="decimal" not-null="true"
    size="22"/>
    <column name="CITY" type="varchar" size="64"/>
    <column name="COUNTRY" type="varchar" size="64"/>
    <column name="ID" type="decimal" size="22"/>
    <column name="LOAD_ID" type="date" not-null="true" size="7"/>
    <column name="REMARKS" type="varchar" size="300"/>
    <fk name="FK_OFACADDRESS_ID" delete-action="exception"
    to-table="OFAC.OFAC_MAIN">
    <join column="ID" to-column="ID"/>
    <join column="LOAD_ID" to-column="LOAD_ID"/>
    </fk>
    <fk name="FK_OFACADDRESS_LOADID" delete-action="exception"
    to-table="OFAC.LOAD_HISTORY" column="LOAD_ID"/>
    </table>
    <table name="OFAC_ALIAS">
    <pk name="SYS_C0036905">
    <on column="ALIAS_ID"/>
    <on column="LOAD_ID"/>
    </pk>
    <column name="ALIAS" type="varchar" size="200"/>
    <column name="ALIAS_ID" type="decimal" not-null="true"
    size="22"/>
    <column name="ID" type="decimal" size="22"/>
    <column name="LOAD_ID" type="date" not-null="true" size="7"/>
    <column name="REMARKS" type="varchar" size="300"/>
    <fk name="FK_OFACALIAS_ID" delete-action="exception"
    to-table="OFAC.OFAC_MAIN">
    <join column="ID" to-column="ID"/>
    <join column="LOAD_ID" to-column="LOAD_ID"/>
    </fk>
    <fk name="FK_OFACALIAS_LOADID" delete-action="exception"
    to-table="OFAC.LOAD_HISTORY" column="LOAD_ID"/>
    </table>
    <table name="OFAC_MAIN">
    <pk name="SYS_C0036903">
    <on column="ID"/>
    <on column="LOAD_ID"/>
    </pk>
    <column name="ID" type="decimal" not-null="true" size="22"/>
    <column name="LOAD_ID" type="date" not-null="true" size="7"/>
    <column name="REMARKS" type="varchar" size="300"/>
    <fk name="FK_OFACMAIN_LOADID" delete-action="exception"
    to-table="OFAC.LOAD_HISTORY" column="LOAD_ID"/>
    </table>

    Hi Greg,
    I'm just using the unmodified schema-to-mapping output. The one thing that
    might be unusual is that I've broken up related tables into discrete
    packages, but I believe all the items in question are in this package.
    Here it is:
    <?xml version="1.0" encoding="UTF-8"?>
    <mapping>
    <package name="com.everbank.finance.ofac3.jdo.sdn">
    <class name="LoadHistory">
    <jdbc-class-map type="base" table="OFAC.LOAD_HISTORY"/>
    <jdbc-version-ind type="state-image"/>
    <field name="listType">
    <jdbc-field-map type="value" column="LIST_TYPE"/>
    </field>
    <field name="loadId">
    <jdbc-field-map type="value" column="LOAD_ID"/>
    </field>
    <field name="ofacAddress">
    <jdbc-field-map type="one-many"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.OFAC_ADDRESS"/>
    </field>
    <field name="ofacAlias">
    <jdbc-field-map type="one-many"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.OFAC_ALIAS"/>
    </field>
    <field name="ofacMains">
    <jdbc-field-map type="one-many"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.OFAC_MAIN"/>
    </field>
    <field name="ofacUsers">
    <jdbc-field-map type="one-one" column.USER_ID="LOADED_BY"/>
    </field>
    <field name="runInfoLoadIdents">
    <jdbc-field-map type="one-many"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.RUN_INFO_LOAD_ID"/>
    </field>
    <field name="sunsetTime">
    <jdbc-field-map type="value" column="SUNSET_TIME"/>
    </field>
    </class>
    <class name="OfacAddress">
    <jdbc-class-map type="base" table="OFAC.OFAC_ADDRESS"/>
    <jdbc-version-ind type="state-image"/>
    <field name="address">
    <jdbc-field-map type="value" column="ADDRESS"/>
    </field>
    <field name="addressId">
    <jdbc-field-map type="value" column="ADDRESS_ID"/>
    </field>
    <field name="addressMp1">
    <jdbc-field-map type="value" column="ADDRESS_MP1"/>
    </field>
    <field name="addressMp2">
    <jdbc-field-map type="value" column="ADDRESS_MP2"/>
    </field>
    <field name="city">
    <jdbc-field-map type="value" column="CITY"/>
    </field>
    <field name="cityMp1">
    <jdbc-field-map type="value" column="CITY_MP1"/>
    </field>
    <field name="cityMp2">
    <jdbc-field-map type="value" column="CITY_MP2"/>
    </field>
    <field name="country">
    <jdbc-field-map type="value" column="COUNTRY"/>
    </field>
    <field name="countryMp1">
    <jdbc-field-map type="value" column="COUNTRY_MP1"/>
    </field>
    <field name="countryMp2">
    <jdbc-field-map type="value" column="COUNTRY_MP2"/>
    </field>
    <field name="loadHistory">
    <jdbc-field-map type="one-one" column.LOAD_ID="LOAD_ID"/>
    </field>
    <field name="loadId">
    <jdbc-field-map type="value" column="LOAD_ID"/>
    </field>
    <field name="ofacMain">
    <jdbc-field-map type="one-one" column.ID="ID"
    column.LOAD_ID="LOAD_ID"/>
    </field>
    <field name="remarks">
    <jdbc-field-map type="value" column="REMARKS"/>
    </field>
    </class>
    <class name="OfacAlias">
    <jdbc-class-map type="base" table="OFAC.OFAC_ALIAS"/>
    <jdbc-version-ind type="state-image"/>
    <field name="alias">
    <jdbc-field-map type="value" column="ALIAS"/>
    </field>
    <field name="aliasId">
    <jdbc-field-map type="value" column="ALIAS_ID"/>
    </field>
    <field name="aliasMp1">
    <jdbc-field-map type="value" column="ALIAS_MP1"/>
    </field>
    <field name="aliasMp2">
    <jdbc-field-map type="value" column="ALIAS_MP2"/>
    </field>
    <field name="aliasType">
    <jdbc-field-map type="value" column="ALIAS_TYPE"/>
    </field>
    <field name="loadHistory">
    <jdbc-field-map type="one-one" column.LOAD_ID="LOAD_ID"/>
    </field>
    <field name="loadId">
    <jdbc-field-map type="value" column="LOAD_ID"/>
    </field>
    <field name="ofacMain">
    <jdbc-field-map type="one-one" column.ID="ID"
    column.LOAD_ID="LOAD_ID"/>
    </field>
    <field name="remarks">
    <jdbc-field-map type="value" column="REMARKS"/>
    </field>
    </class>
    <class name="OfacMain">
    <jdbc-class-map type="base" table="OFAC.OFAC_MAIN"/>
    <jdbc-version-ind type="state-image"/>
    <field name="callSign">
    <jdbc-field-map type="value" column="CALL_SIGN"/>
    </field>
    <field name="callSignMp1">
    <jdbc-field-map type="value" column="CALL_SIGN_MP1"/>
    </field>
    <field name="callSignMp2">
    <jdbc-field-map type="value" column="CALL_SIGN_MP2"/>
    </field>
    <field name="grt">
    <jdbc-field-map type="value" column="GRT"/>
    </field>
    <field name="id">
    <jdbc-field-map type="value" column="ID"/>
    </field>
    <field name="loadHistory">
    <jdbc-field-map type="one-one" column.LOAD_ID="LOAD_ID"/>
    </field>
    <field name="loadId">
    <jdbc-field-map type="value" column="LOAD_ID"/>
    </field>
    <field name="matchInfos">
    <jdbc-field-map type="one-many" ref-column.ID="ID"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.MATCH_INFO"/>
    </field>
    <field name="ofacAddress">
    <jdbc-field-map type="one-many" ref-column.ID="ID"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.OFAC_ADDRESS"/>
    </field>
    <field name="ofacAlias">
    <jdbc-field-map type="one-many" ref-column.ID="ID"
    ref-column.LOAD_ID="LOAD_ID" table="OFAC.OFAC_ALIAS"/>
    </field>
    <field name="pName">
    <jdbc-field-map type="value" column="P_NAME"/>
    </field>
    <field name="pNameMp1">
    <jdbc-field-map type="value" column="P_NAME_MP1"/>
    </field>
    <field name="pNameMp2">
    <jdbc-field-map type="value" column="P_NAME_MP2"/>
    </field>
    <field name="program">
    <jdbc-field-map type="value" column="PROGRAM"/>
    </field>
    <field name="remarks">
    <jdbc-field-map type="value" column="REMARKS"/>
    </field>
    <field name="sName">
    <jdbc-field-map type="value" column="S_NAME"/>
    </field>
    <field name="sNameMp1">
    <jdbc-field-map type="value" column="S_NAME_MP1"/>
    </field>
    <field name="sNameMp2">
    <jdbc-field-map type="value" column="S_NAME_MP2"/>
    </field>
    <field name="sdnType">
    <jdbc-field-map type="value" column="SDN_TYPE"/>
    </field>
    <field name="ssn">
    <jdbc-field-map type="value" column="SSN"/>
    </field>
    <field name="title">
    <jdbc-field-map type="value" column="TITLE"/>
    </field>
    <field name="tonnage">
    <jdbc-field-map type="value" column="TONNAGE"/>
    </field>
    <field name="vesselFlag">
    <jdbc-field-map type="value" column="VESSEL_FLAG"/>
    </field>
    <field name="vesselOwner">
    <jdbc-field-map type="value" column="VESSEL_OWNER"/>
    </field>
    <field name="vesselOwnerMp1">
    <jdbc-field-map type="value" column="VESSEL_OWNER_MP1"/>
    </field>
    <field name="vesselOwnerMp2">
    <jdbc-field-map type="value" column="VESSEL_OWNER_MP2"/>
    </field>
    <field name="vesselType">
    <jdbc-field-map type="value" column="VESSEL_TYPE"/>
    </field>
    </class>
    </package>
    </mapping>
    Als, just for giggles, the JDO file
    <?xml version="1.0" encoding="UTF-8"?>
    <jdo>
    <package name="com.everbank.finance.ofac3.jdo.sdn">
    <class name="LoadHistory"
    objectid-class="com.everbank.finance.ofac3.jdo.LoadHistoryId">
    <field name="loadId" primary-key="true"/>
    <field name="ofacAddress">
    <collection element-type="OfacAddress"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="loadHistory"/>
    </field>
    <field name="ofacAlias">
    <collection element-type="OfacAlias"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="loadHistory"/>
    </field>
    <field name="ofacMains">
    <collection element-type="OfacMain"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="loadHistory"/>
    </field>
    <field name="runInfoLoadIdents">
    <collection
    element-type="com.everbank.finance.ofac3.jdo.match.RunInfoLoadIdent"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="loadHistory"/>
    </field>
    </class>
    <class name="OfacAddress"
    objectid-class="com.everbank.finance.ofac3.jdo.OfacAddressId">
    <field name="addressId" primary-key="true"/>
    <field name="loadId" primary-key="true"/>
    </class>
    <class name="OfacAlias"
    objectid-class="com.everbank.finance.ofac3.jdo.OfacAliasId">
    <field name="aliasId" primary-key="true"/>
    <field name="loadId" primary-key="true"/>
    </class>
    <class name="OfacMain"
    objectid-class="com.everbank.finance.ofac3.jdo.OfacMainId">
    <field name="id" primary-key="true"/>
    <field name="loadId" primary-key="true"/>
    <field name="matchInfos">
    <collection
    element-type="com.everbank.finance.ofac3.jdo.match.MatchInfo"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="ofacMain"/>
    </field>
    <field name="ofacAddress">
    <collection element-type="OfacAddress"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="ofacMain"/>
    </field>
    <field name="ofacAlias">
    <collection element-type="OfacAlias"/>
    <extension vendor-name="kodo" key="inverse-owner"
    value="ofacMain"/>
    </field>
    </class>
    </package>
    Greg Campbell wrote:
    Hi Tim,
    Could you send the your mapping information corresponding to the class that
    maps to table: OFAC_ADDRESS. In particular, I'm looking for what fields
    map to OFAC_ADDRESS.LOAD_ID. This will hopefully give us a hint as to
    what's going wrong.
    Thanks,
    Greg
    "Tim Holloway" <[email protected]> wrote in message
    news:[email protected]...
    I have a situation where I'm trying to assemble a web of data and not make
    JDO mad.
    <snipped>

  • CDG-01141 ERROR: Module Component Table Usage ...  Table usage ... requires primary key column for referential integrity

    For some strange reason when I modified a form, (commented out some code in a when-window-activated trigger) I now get the following error.
    CDG-01141 ERROR: Module Component Table Usage GR1130A.CUSTOMER.GR_CUSTOMER.GC: Table usage GR_CUSTOMER requires primary key column for referential integrity
    I am sure this is not related to my change, but do not know what may have caused this or how to fix it.
    Anyone seen this error before? been able to fix it?
    Thanks!
    Windows 7
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Designer Version 6.5.95.4.8

    You know that Developer/Designer 6i is not certified for Windows 7, right? Also, your version is not the latest one, so you can try to install the latest patch set first.
    >Table usage GR_CUSTOMER requires primary key column for referential integrity
    Check if there is a PK in the table definition (not in the database, but in Designer).

  • ORA-02292: integrity constraint - foreign key delete

    I am getting the above error message when attempting to delete an entry with a foreign key constraint. I have the standard delete button and the standard DML process for inset, update, delete, and a page validation conditioned on the delete button for EXISTS with the following code:
    select 1 from dual
    where (select count(*) from mdeccommitments
    where producer = :P25_COREID
    and receiver = :P25_COREID) = 0
    and (select count(*) from mdecbriefcal
    where primarytarget = :P25_COREID
    and primaryowner = :P25_COREID) = 0
    This code works in SQL directly. However, when I try to run this, I do not get the inline error associated with the validation routine, I just get the popup for the delete and then the very user-unfriendly Oracle error, almost as if the validation wasn't there. I tried removing the popup associated with the delete button, but it did not make a difference.
    I want to provide a friendly intercept and return. I do not want to cascade the delete. What am I missing here?
    Thanks.
    Gillian

    Thanks Varad, by running the debug, I realized I misinterpreted what the validation did - I had used EXISTS instead of NOT EXISTS. Making this change resulted in the correct processing. Being a newbie, I wasn't sufficiently familiar with the debug option to think about it.

  • Unable to drop foreign key on a version-enabled table

    Hi,
    We're using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit and I'm trying to delete a foreign key from a version-enabled table.
    The constraint shows in ALL_WM_RIC_INFO view. I run exec dbms_wm.beginddl('tablename'), when I inspect the generated <tablename>_LTS I don't see any referential integrity constraints generated on that table ? The constraint i'm trying to delete is from a version-enabled table to a non-version enabled table if that makes a difference.
    From what I understand the referential integrity constraint would be generated and I would be able to run something like:
    ALTER TABLE <tablename>_LTS DROP CONSTRAINT <constraintname>.
    I tried running the above statement using the RIC_NAME from ALL_WM_RIC_INFO view but it fails predictably with:
    ORA-02443: Cannot drop constraint - nonexistent constraint
    Cause: alter table drop constraint <constraint_name>
    Action: make sure you supply correct constraint name.

    as I ran into this today as well I feel like answering this question, as I suppose that the thread opener did the same mistake as I did, and maybe
    some others do it as well :)
    of course you need to open a DDL session on the parent table as well in order to drop foreign key constraints, just as you do when you add them.
    so the correct order to make it work would be:
    EXECUTE DBMS_WM.BeginDDL('PARENT_TABLE');
    EXECUTE DBMS_WM.BeginDDL('CHILD_TABLE');
    ALTER TABLE CHILD_TABLE_LTS
    DROP CONSTRAINT FOREIGN_KEY_NAME
    EXECUTE DBMS_WM.CommitDDL('CHILD_TABLE');
    EXECUTE DBMS_WM.CommitDDL('PARENT_TABLE');I felt kind of stupid that it took me 1 hour to figure this out ;)
    regards,
    Andreas

  • Ora-2270 Error while adding foreign key constraint on top a view

    While adding a constraint, referencing a foreign key column from a view raises error. However, it works fine over a table.
    Here's the sample script:
    create table t_temp (
    sample_id number,
    text varchar2(40))
    alter table t_temp add constraint temp_pk
    primary key (sample_id);
    create view tempvw as select sample_id,text from t_temp;
    create table t_sample (
    uniq_id number,
    sample_id number,
    sample_text varchar(40));
    =========
    ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp
         FOREIGN KEY (sample_id) REFERENCES t_temp (sample_id);
    This works fine.
    =========
    ==============
    The following raises ERROR....
    ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp1
         FOREIGN KEY (sample_id) REFERENCES tempvw (sample_id);
    Error starting at line 1 in command:
    ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp1
         FOREIGN KEY (sample_id) REFERENCES tempvw (sample_id)
    Error report:
    SQL Error: ORA-02270: no matching unique or primary key for this column-list
    02270. 00000 - "no matching unique or primary key for this column-list"
    *Cause:    A REFERENCES clause in a CREATE/ALTER TABLE statement
    gives a column-list for which there is no matching unique or primary
    key constraint in the referenced table.
    *Action:   Find the correct column names using the ALL_CONS_COLUMNS
    catalog view

    What exactly are you trying to accomplish by having a
    referential integrity constraint on a view (which is
    not allowed). PKs and FKs are allowed on views. DISABLE NOVALIDATE is the only allowed state for them. View constraints are used for query rewriting: http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/qradv.htm#sthref1457
    Regards,
    Dima

  • Basic doubt about Primary Key/Foreign Key in Oracle Tables

    Hi,
    I have a doubt whether Primary Keys/Foreign Keys are allowed in Oracle. Some of the people I know are telling me that Oracle does not encourage having Primary Keys/Foreign keys in its database tables.
    However if I go to the ETRM and look for information about some of the Oracle Tables, I am informed that Primary Keys do exist. However I am being told that ETRM is not a reliable way of having correct information about table structure.
    It would be great if any one of you provides me with some insight in this. Any pointers to a document would be great.
    Thanks

    It is not that PK/FKs are disallowed in Oracle Apps (there are some on the standard Oracle Apps tables), but they are typically not used. I am not positive what the logic behind this is, but my guess is that it was party due to the earlier versions of Oracle Apps pre-dating declarative database referential integrity in Oracle DB and also on performance issues with the standard referential integrity with the earlier versions of declarative database referential integrity.
    As far as eTRM is concerned - I understood that the data is based on a design repository rather than a physical Oracle Apps DB. So all of the information in there is logically correct, but not necessarily enforced via the standard Oracle DB declarative referential integrity (rather by the application code or APIs).

  • JDeveloper 9i, Foreign Keys and LOVs.

    Greetings all,
    I'm using Jdev 9i to try and create some maintenance applications quickly. These applications are pretty standard; insert, update, delete, some validation, including foreign keys.
    The problem is, I can't figure out how to get JDev to generate the JSPs with LOV pages on the foreign keys.
    I've tried setting the validation properties of the entity object to validate from a query, as well as, tried using View objects for the same validation. Neither get me results.
    I've also tried embedding the LOV directly using the LOVInputSelect (or whatever it is called). That works partially by displaying a field and a button, but when I click on it, I get an error with no explanation. Very helpful.
    I can use a InputSelect datatag, but it is not the best choice for foreign keys with hundreds of values.
    Also, since the Wizards are generating the DataEdit tag for the JSP I'm using, it appears that I cannot override them to display the LOV. They display a Calendar page for dates, automatically, but won't display an LOV for referential integrity. At least, I can't figure out how to make them.
    Thanks in advance.
    Ed Dana
    Software Developer.

    It's really beyond me why Oracle haven't provided a fairly complete set of Renderers (and a bit more BC4J oriented than the one's mentioned in the HOWTO).
    Basically, you have two choices:
    1/ develop your own Renderers (make your own conventions with Properties on Entities/ViewObjects) and use InputRender
    2/ generate the JSP's yourself using the usual jbo tags (probably again based on some meta data in the properties). You may have to fiddle around a bit with inputselectlov etc.
    Again, it's hard for me to understand why Oracle haven't substantially improved their default generated BC4J JSP pages, it looks to me that it is not so hard (compared to some of the other things they're trying to pull off) and gives maximum benefit for the customers.
    Alternatively, there is JHeadstart (do a search on otn, you'll find some pointers). It generates lots of screens nicely for you (a la Designer, if you're familiar with that). Some teething problems, but really very productive otherwise. The disadvantage here is that if you want to start to make a few little changes outside what it supports, you're up against a fairly steep learning curve to master UIX and MVC framework. Apparently there's some hope that they will generate to Struts (taglibs & controller, if I understand well) soon.

  • What  is self referential integrity? How does it effect the Database?

    Hello Gurus,
    What is self referential integrity?
    How could it is achieved and implemented?
    and what is effect on the Database?
    Thanks in advance.
    ~ SubbaReddy .M

    Self referential integrity simple means that the parent end of a foreign key constraint is in the same table as the child end. Consider the SCOTT.EMP table. Every manager is also an employee. Hence there is a foreign key between the MGR column and the EMPNO column.
    rgds, APC

  • Maintaining referential integrity using MS SQL server

    Some time ago I posted a question relating to the following extension:
    <extension vendor-name="kodo" key="jdbc-delete-action" value="null"/>
    Kodo generates a "on delete set null" constraint for this, however ms sql
    server does not support this. Since I don't want to matain this referential
    integrity in my java code (meaning as soon as an object is deleted, setting
    all references to it to null), I tried to implement a custom dictionary with
    the default ms sql server solution for this problem: creating a trigger by
    overriding the "getAddForeignKeySQL" method. This works fine when creating a
    database from scratch using the schema tool, however, when updating an
    existing databasebase schema, this is ignored, thereby not solving the
    problem of having the database maintenance automated. I suppose I have to
    write code for checking whether the trigger already exists. Browsing through
    the code, I couldn't figure out how this is done. Can someone give me
    suggestions on how to do this (and if this takes a lot of effort).
    I also would like to know whether solarmetric has intentions to deal with
    this problem in their framework. To be honest, I was quite surprised that
    Kodo doesnt take care of this, leaving my database in an inconsistent state.
    kind regards,
    Christiaan

    "Abe White" <[email protected]> schreef in bericht
    news:caaunu$ecj$[email protected]..
    >
    I also would like to know whether solarmetric has intentions to dealwith
    this problem in their framework. To be honest, I was quite surprisedthat
    Kodo doesnt take care of this, leaving my database in an inconsistentstate.
    >
    Well, I would say that you're the one leaving the database in an
    inconsistent state by not keeping your object model consistent :)From the manual:
    6.2.2.12. jdbc-delete-action
    If a field holds a relation to another object, you can use the
    jdbc-delete-action field extension to control the delete action of the
    database foreign key that models this relation. Possible values are:
    null: Null the column(s) of this foreign key when the related record is
    deleted.
    It does mean that if the primary key record is deleted, all foreign keys to
    the record are set to null, right? Since the jdo framework is about database
    independence, not writing sql code (and of course lots more;) and Kodo
    supports ms sql server, I would have expected that kodo to set the foreign
    key to null if the object is deleted. Even if I do know sql server supports
    does not support a 'on delete set null' sql statement;)
    >
    We have no plans to create triggers at this time.
    What do you mean when you say "it is ignored" when you're updating?
    Exactly what tool are you running, what actions are you running with, is
    the foreign key extension present, and what is the outcome?Like I said, I wrote code in the "getAddForeignKeySQL" in the dictionary, so
    a trigger is created when creating the database in the workbench (by running
    the schematool). However, if the table already exists, but not the trigger,
    refreshing the database from the workbench does not call the
    getAddForeignKeySql to add the trigger to the table.

  • Does a foreign key have to be a primary key

    Hey all.I was checking on the database code written by sambapos.To my surprise, I found a foreign key that is not a primary key anywhere.
    Is that possible?
    If, so why?
    I am really astonished.

    Limitations and Restrictions
    A foreign key constraint does not have to be linked only to a primary key constraint in another table; it can also be defined to reference the columns of a UNIQUE constraint in another table.
    When a value other than NULL is entered into the column of a FOREIGN KEY constraint, the value must exist in the referenced column; otherwise, a foreign key violation error message is returned. To make sure that all values of a composite foreign key constraint
    are verified, specify NOT NULL on all the participating columns.
    FOREIGN KEY constraints can reference only tables within the same database on the same server. Cross-database referential integrity must be implemented through triggers. For more information, see
    CREATE TRIGGER (Transact-SQL).
    FOREIGN KEY constraints can reference another column in the same table. This is referred to as a self-reference.
    A FOREIGN KEY constraint specified at the column level can list only one reference column. This column must have the same data type as the column on which the constraint is defined.
    A FOREIGN KEY constraint specified at the table level must have the same number of reference columns as the number of columns in the constraint column list. The data type of each reference column must also be the same as the corresponding column in the column
    list.
    The Database Engine does not have a predefined limit on either the number of FOREIGN KEY constraints a table can contain that reference other tables, or the number of FOREIGN KEY constraints that are owned by other tables that reference a specific table.
    Nevertheless, the actual number of FOREIGN KEY constraints that can be used is limited by the hardware configuration and by the design of the database and application. We recommend that a table contain no more than 253 FOREIGN KEY constraints, and that it
    be referenced by no more than 253 FOREIGN KEY constraints.
    FOREIGN KEY constraints are not enforced on temporary tables.
    If a foreign key is defined on a CLR user-defined type column, the implementation of the type must support binary ordering. For more information, see
    CLR User-Defined Types.
    A column of type varchar(max) can participate in a FOREIGN KEY constraint only if the primary key it references is also defined as type
    varchar(max).
    Read this article
    http://msdn.microsoft.com/en-us/library/ms189049.aspx
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • Foreign Key Constraint Failure on Self-Referencing Table

    In a recent data deletion project, I ran into a problem where Oracle allowed for a record (the parent) to be deleted when there still existed a child record in the same table which referred to the parent.
    An abbreviated version of the table is as follows:
    create table test (
    template_id number not null,
    customer_id number null,
    parent_id number null,
    constraint pk_test primary key (template_id),
    constraint r_parent foreign key (parent_id) references test (template_id));
    The parent and child records are as follows:
    Parent: template_id = 100, customer_id = 200, parent_id = null
    Child: template_id = 101, customer_id = null, parent_id = 100
    Records were deleted from this table using:
    DELETE FROM test WHERE customer_id = 200;
    When this statement is executed, is it being executed as part of 155 delete statements using PL/SQL, and tens of thousands of records from 155 tables are being deleted. These delete statements have been ordered taking into account foreign key constraints. All 155 statements are being deleted in a single transaction. The delete statement above was the 23rd statement of the set to be executed. I would have expected when this delete statement was executed, an error would have been thrown. However, all 155 delete statements successfully complete, and after committing the results, the child record above still exists in the DB as an orphan. I also tried executing the first 23 statements manually in SQL*Plus (still one transaction), and the problem still occurs: the parent is deleted and the child is orphaned.
    If I execute the very simple example above, I do indeed get an referential constraint error.
    Has anyone ever encountered this situation? And does anyone have any ideas how to go about troubleshooting this problem. We need to know the cause of this, as we have a small handful of table with a similar self-referential foreign key constraint set-up.
    Thank you very much in advance,
    Mark

    First of all, the very simple example that I outlined above I have already tried and it worked: when I attempted to delete the parent a referential integrity error was thrown as one would expect. This small example was my test case to see if I could reproduce what I'm seeing in our application in a more manageable and demonstrable example. But as it worked, I'm still perplexed in reconciling the differences between what I'm seeing in our application (which I can't demonstrate in this help group) and the test case. When I used the test case in my first posting in this thread, I used it to help describe the problem I'm encountered, even though that small example works.
    Below is more of the table you've asked for.
    OWNER           CONSTRAINT_NAME          CONSTRAINT_TYPE     TABLE_NAME     SEARCH_CONDITION     R_OWNER            R_CONSTRAINT_NAME     DELETE_RULE     STATUS          DEFERRABLE            DEFERRED         VALIDATED     GENERATED     BAD     RELY     LAST_CHANGE           INDEX_OWNER  INDEX_NAME       INVALID     VIEW_RELATED
    "DOCPADMIN"     "R_TEMPLATE_PARENT"     "R"             "DCR_TEMPLATE"      (null)                  "DOCPADMIN"     "XPKDCR_TEMPLATE"     "NO ACTION"  "ENABLED"   "NOT DEFERRABLE"    "IMMEDIATE"  "VALIDATED"      "USER NAME"     (null)     (null)     "2010-01-13 19:01:21"     (null)        (null)         (null)       (null)
    "DOCPADMIN"     "XPKDCR_TEMPLATE"       "P"             "DCR_TEMPLATE"      (null)                       (null)     (null)                      (null)          "ENABLED"     "NOT DEFERRABLE"    "IMMEDIATE"      "VALIDATED"     "USER NAME"     (null)     (null)     "2010-01-13 15:48:31"     (null)     "XPKDCR_TEMPLATE"   (null)     (null)Overall, I haven't said that Oracle's FK mechanism is broken. What I've said is that I've got a situation that I'm trying to understand. My first attempt at my test case didn't work because the test case worked as it should. I'm trying to figure out another course of action to try and figure this situation out.

  • How to avoid shared locks when validating foreign keys?

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

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

  • DRI (declarative referential integrity) and speed improvements.

    EDITED: See my second post--in my testing, the relevant consideration is whether the parent table has a compound primary key or a single primary key.  If the parent has a simple primary key, and there is a trusted (checked) DRI relation
    with the child, and a query requests only records from the child on an inner join with the parent, then sql server (correctly) skips performing the join (shown in the execution plan).  However, if the parent has a compound primary key, then sql server
    performs a useless join between parent and child.   tested on sql 2008 r2 and denali.  If anyone can get sql server NOT to perform the join with compound primary keys on the parent, let me know.
    ORIGINAL POST: I'm not seeing the join behavior in the execution plan given in the link provided (namely that the optimizer does not bother performing a join to the parent tbl when a query needs information from the child side only AND
    trusted DRI exists between the tables AND the columns are defined as not null).  The foreign key relation "is trusted" by Sql server ("is not trusted" is false), but the plan always picks both tables for the join although only one is needed. 
    If anyone has comments on whether declarative ref integrity does produce speed improvements on certain joins, please post.  thanks.
    http://dinesql.blogspot.com/2011/04/does-referential-integrity-improve.html

    I'm running sql denali ctp3 x64 and sql 2008 r2 x64, on windows 7 sp1. I've tested it on dozens of tables, and I defy anyone to provide a counter-example (you can create ANY parent table with two ints as a composite primary key, and then a child table using
    that compound as a foreign key, and create a trusted dri link between them and use the above queries I posted)--any table with a compound foreign key relation as the basis for the DRI apparently does not benefit from referential integrity between those tables
    (in terms of performance). Or to be more precise, the execution plan reveals that sql server performs a costly and unnecessary join in these cases, but not when the trusted DRI relation between them is a single primary key. If anyone has seen a different result,
    please let me know, since it does influence my design decisions.
    fwiw, a similar behavior is true of sql server's date correlation optimization: it doesn't work if the tables are joined by a composite key, only if they are a joined by a single column:
    "There must be a single-column
    foreign key relationship between the tables. "
    So I speculate, knowing absolutely nothing, that there must be something deep in the bowels of the engine that doesn't optimize compound key relations as well as single column ones.
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[parent](
    [pId1] [int] NOT NULL,
    [pId2] [int] NOT NULL,
    CONSTRAINT [PK_parent] PRIMARY KEY CLUSTERED
    [pId1] ASC,
    [pId2] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    CREATE TABLE [dbo].[Children](
    [cId] [int] IDENTITY(1,1) NOT NULL,
    [pid1] [int] NOT NULL,
    [pid2] [int] NOT NULL,
    CONSTRAINT [PK_Children] PRIMARY KEY CLUSTERED
    [cId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    ALTER TABLE [dbo].[Children] WITH CHECK ADD CONSTRAINT [FK_Children_TO_parent] FOREIGN KEY([pid1], [pid2])
    REFERENCES [dbo].[parent] ([pId1], [pId2])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    /* the dri MUST be trusted to work, but it doesn't work anyway*/
    ALTER TABLE [dbo].[Children] CHECK CONSTRAINT [FK_Children_TO_parent]
    GO
    /* Enter data in parent and children */
    select c.cId FROM dbo.Children c INNER JOIN Parent p
    ON p.pId1 = c.pId1 AND p.pId2 = c.pId2;
    /* Execution plan will be blind to the trusted DRI--performs the join!*/

  • Self Referential integrity constraint?

    What is self-referential integrity constraint? Is it a foreign key where the same column acts as the parent key too.

    The good old EMP table in the SCOTT schema is one example. Managers are employees, so the MGR column refers back to the EMPNO primary key. If I wanted to create my own table...
      1  create table emp2 (
      2   empno number primary key,
      3   mgr   number references emp2( empno )
      4* )
    SCOTT @ hp92 Local> /
    Table created.Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • Acrobat Pro 10.1.10 always freezes in OS X Mavericks 10.9.4

    Double-clicking a PDF in the Finder launches Acrobat Pro, but functionality is limited. Turning a page freezes it. Performing a Find freezes. Performing a Force Quit shows it is Not Responding. I can re-launch it, but not open a PDF. This is part of

  • DVD won't play in player, only on pc?

    I made a dvd through DSP and it doesn't play on my DVD player. I can see the burn in in the DVD itself but the player just doesn't seem to load it up to the menu. In DSP, I set the Target for the Disc in Property Inspector to the Menu. What else do I

  • Migrating from 10.4.11 to 10.5.1 on a new machine

    I want to migrate my tiger server to a leopard server which will be on a new machine. What is the best way to deal with two computers have the same server name? Install the leopard sever when unplugged from the network and give it the same name as my

  • MS Project 2010: SQL Query Expansion to custom field

    In a further forum topic I got the solution for searching for server admins approvals pending, not publisched projects and team members not sended times. We defined a new enterprise custom field called "Status reporting" from type Flag (yes/no). Can

  • Change number mandatory Routing for a particular Plant

    Dear All, i have requirement to make change no field mandatory for only one plant. this field should not be mandatory for other plant. I tried with OP5A tcode, using plant as influencing field, change no as modified field and content as plant no. so