How to create a foreign key for the table from two different tables?

Hi All,
I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
code 1:
CREATE TABLE SAMPLE_CONS_CHECK
        (NAME VARCHAR2(10),
        SERIES  VARCHAR2(5)
CREATE TABLE SAMPLE_CONS2_CHECK
        (NAME  VARCHAR2(5),
         MODEL  NUMBER
CREATE TABLE SAMPLE_CONS3_CHECK
        (NAME  VARCHAR2(5),
         MODEL_NO  NUMBER
        )code 2
alter table SAMPLE_CONS_CHECK
add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS2_CHECK
add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS3_CHECK
add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
     NAME
) REFERENCES SAMPLE_CONS_CHECK
    NAME
) ON DELETE CASCADE;
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
     NAME
) REFERENCES SAMPLE_CONS2_CHECK
    NAME
) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
How can i solve this problem? Can anyone halp me about this?
Thanks
Edited by: orasuriya on Aug 8, 2009 2:02 AM

Actually the design is completely incorrect.
What you say is
I have
'foo', 'foo series'
'foo','foo model'
'foo',666
By virtue of table3 referring to both table1 and table2.
This means you actually need to have 1 (one) table:
'foo','foo series','foo model', 666
And the 'problem' disappears.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • How to create a dropdown list to list the values from two different tables?

    Hi,
    I have the following requirement:
    1. I have to create a dropdown list to display all the values from the second column of  a table.
    2. Another dropdown list to display all the values from the second column of another table.
    3. A text box should help me to add the selected values.
    How to get this done in a PDF? Please help.
    Regards,
    Latha

    Is this a LC form? Because Acrobat forms have no concept of tables, just
    individual fields...

  • How to create a report to bring all data from two different Info providers

    Hi All,
    I have a peculier problem while creating a report. I have two custom info providers one DSO and another Cube. There are only two common fields between these two Info providers . I need to create a report such that the report displays all the values from DSO but user can have the selection option on one of the fields in the Cube.
    Here is an example
    DSO Contents:
    DocNum-     DocItem-     DocText-     Amount-      Quantity
    10000----     10----            ABC----          100----           10
    10001----     20----     DSN----     200----     10
    10005----     20----     DSN----     200----     10
    Z1003----     10----     CAN----     500----     1
    Cube Contents
    DocNum-     DocItem-     Date-----          InvoiceAmt
    10000----     10----     1/10/2009----         50
    10001----     20----      2/20/2009----        100
    10005----     20----      2/25/2009----        100
    The report needs to be displayed as shown below when the user selects value for date from 1/10/2009 to 2/20/2009
    DocNum-     DocItem-     DocText-     Amount-      Quantity
    10000----     10----     ABC----     100----     10
    10001----     20----     DSN----     200----     10
    I hope this was clear for you to understand. I would really appricate if any one can answers about how to resolve this problem. I cannot add the date filed to DSO and I also have Doc Num and Item as the user selection fields in the report.
    Thank you all in advance and i would really appreciate for your suggestions.
    Regards
    Chinna
    Edited by: chinna2479 on Mar 3, 2009 7:38 PM
    Edited by: chinna2479 on Mar 3, 2009 7:39 PM

    Hi chinna,
    Two possible options, I can think of now, but both of them may be a compromise with performance.
    1. create an infoset and then a query on top of it, provided we have a one to one relation in both the targets. That is, the combination of doc and item number is not duplicate in either cube or ODS.
    2. Create a master data object of doc and item number and have date as an attribute. Load that from cube data and make date as navigational attr.
    Use this navgntal attr for selection in your report.
    Let us know, if you require any further info.
    Naveen.A

  • How to create a account key for application type M ?

    Hi Guys,
    How to create a account key for application type M ? and link the same with
    Gl account.
    thanks.

    Hi
    Please create the account keys or transaction keys in
    SPRO-> IMG-> MM-> Purchasing-> Conditions-> Define Price Determination Process-> Define Transaction/Event Keys
    Thanks & Regards
    Kishore

  • How to create multi garnishment order for the same garnishment document

    Hi,
    Can anyone tell me how to create multi garnishment order for the same garnishment document. I tried to copy the entry in IT0195 but the sequence field is grayed out so it will just delete the old record. What configuration should I do to make this possible?
    Thanks a lot in advance.

    hi,
    As far as I got it.
    You cannot have multiple Garnishment order but if a need arises you have to maintain it in IT216.
    For that follow this path goto PA30->pernr->194->change->Garnishment->adjustment.
    Since like order you cannot maintain adjustment also directly.
    Regards,
    Amit
    Reward all helpful replies.

  • How to get the spool id or how to create a spool id for the report .

    hi,
    how to get the spool id or how to create a spool id for the report .
    this spool id i have to use it in CONVERT_ABAPSPOOLJOB_2_PDF fm to get the pdf download file.
    my requirement is to download a pdf file from the alv grid list.

    Hi Raghu,
    Execute this program.
    REPORT  ZTEST_3318                              .
    tables: usr01.
    perform send_report_to_spool.
    *&      Form  send_report_to_spool
          text
    form send_report_to_spool.
      data: loc_dest like pri_params-pdest,
            wf_listname type char12,
            wf_listtext like PRI_PARAMS-PRTXT,
            wf_copies type i,
            wf_days type i,
            wf_PARAMS LIKE PRI_PARAMS,     " achieving file PRI_PARAMS.
            wf_valid type c.
      clear : wf_listname , loc_dest , wf_listtext .
      move: 'AP interface' to   wf_listname .
      move: 'AP interface' to   wf_listtext .
    select single spld into usr01-spld from usr01 where bname eq sy-uname .
      if sy-subrc eq 0 .
        move: usr01-spld to loc_dest .
      endif .
      call function 'GET_PRINT_PARAMETERS'
        EXPORTING
          destination    = loc_dest
          copies         = 1
          list_name      = wf_listname
          list_text      = wf_listtext
          immediately    = ' '
          release        = ' '
          new_list_id    = 'X'
          expiration     = 1
          line_size      = 200
          line_count     = 65
          layout         = 'X_65_200'
          sap_cover_page = 'X'
          receiver       = 'SAP*'
          department     = ''
          no_dialog      = 'X'
        IMPORTING
          out_parameters = wf_params
          valid          = wf_valid.
      if wf_valid <> space.
        new-page print on parameters wf_params no dialog.
        perform write_summary .
        new-page print off.
      endif .
    endform.                    "send_report_to_spool
    *&      Form  write_summary
          text
    -->  p1        text
    <--  p2        text
    FORM write_summary .
    data: begin of itab occurs 0,
          matnr type matnr,
          end of itab.
    select matnr
           from mara
           into table itab
           up to 10 rows.
    loop at itab.
    write: / itab-matnr.
    endloop.
    ENDFORM.                    " write_summary
    This will create spool in SP01.What data you want to put in Spool write it in form write_summary.I have done coding for testing purpose
    After that use that spool for your purpose.
    If Useful award point

  • How to Create Interactive report lists for the gross sales, credit ....

    How to Create Interactive report lists for the gross sales, credit returns, and gross weight for the               customer for the current year and comparing the same with that of the previous year for the same period.....
    plz tell me steps to accomplish this....plz ...give me the detail description..plz......many many thnx in advance...

    Hi raja,
    Display a checkbox , customer number on the basic list and also set a GUI STATUS  on the basic list.....
    Select the customer by checking the checkbox and click on the button you create in the GUI status....
    Write the desired code to be displayed in
    AT USER-COMMAND even checking the sy-ucomm....
    so this would make you to into interactive list...
    Hope this would help you.
    Regards
    Narin Nandivada

  • How to create  an alternative bom for the same product

    Hi expert,
       I want to know how to create an alternative bom for the same product. Can i use the different bom usage to create or use the same bom usage? In addition, how can i use the production version to link the alternative bom for the same product?
    Please help me solve the problem.
    Thanks in advance for any assistance.
    George shi

    HI
    you can go with t-code CS01
    if you have the BOM already and you want to create the alternative BOM then just goto create BOM
    and enter the material and plant and uasge system will auto matically prapose the next numner ie, if you have Alt BOM1
    then next system will prappose 2.
    then you can enter the components as per you requirement
    if you go to different BOM usage then sytem will not go for alternative BOM it gives again alt bom 1.
    prodcution version you need to craet from mateial master
    each version you can go woith alternative BOMS
    Version 1 will have alt BOM1
    Version 2 can haev ALT BOM2
    -ashok

  • TS1389 how to authorize computer in itunes for the purchased from another account

    how to authorize computer in itunes for the purchased from another account ??

    Use that account's Apple ID and password; the procedure is otherwise the same as authorizing it for the first account. If the iTunes library contains protected content from more than five iTunes Store accounts, you may not be able to fully sync it.
    (92807)

  • How to compare the contents of two different tables

    hello. can somebody give me an idean on how to compare the contents of two different tables in mysql?
    example, i have a table named Main List and a table named New List.
    The contents of the New List should be compared to the contents of the
    Main List, to check if they are equal. I don't have any idea how to manipulate
    this data. Hoping for your help. Thanks.

    it is better to comapre it using java.. try get the resultset first and store that in collections then comapre the two collections

  • Create one tables from 2 different tables

    Hi,
    How I can create one table from 2 different tables. Source tables have data and I want to include it in new table.
    I try this:
    create table NEW_ONE
    select * from OLD_ONE
    union
    select * from OLD_ONE2;
    But it didn't work correctly :/

    I don't have any error. This syntax create table NEW_ONE, but this table have columns only from OLD_ONE table :/ There aren't any column from OLD_ONE2 :/ Any suggestions?
    I don't forget about "as" in my query, only in this post.
    Edited by: tutus on Sep 8, 2008 6:36 AM

  • Can I sync the songs from two different Apple IDs (HK and JP) into one iPhone?

    I want to buy some songs from a HK Apple ID and a JP Apple ID.
    I just hope the songs of two Apple ID can appear in one iPhone.
    But I don't want can I sync the songs from two different Apple IDs (HK and JP) into one iPhone.

    Are you currently in Japan or Hong Kong ? You have to be in a country (and have a billing address in that country on your account) to buy or download from its store, that is included in the store's terms.
    You can sync content from different accounts from your computer's iTunes library.

  • How to create a connection key for an intranet

    I'm trying to create a connection key for a client of ours to
    update a page on their intranet. The intranet is only available
    internally. How do I go about doing this?

    Hi
    Please create the account keys or transaction keys in
    SPRO-> IMG-> MM-> Purchasing-> Conditions-> Define Price Determination Process-> Define Transaction/Event Keys
    Thanks & Regards
    Kishore

  • How to create a shortcut menu for the pane

    Hi all
    Well - I know how to create a shortcut menu for a control, but how is it created for a pane? There is the possibility to add an event case for a shortcut menu linked to a pane (see picture), but how can I create this menu?
    Message Edited by becktho on 08-01-2006 11:32 AM
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    ScreenShot001.png ‏22 KB

    ahlers option works, sorry but I can't add images from work!
    Just use the shortcut Menu Activation filter event? to create a menu.
    Ton
    Message Edited by TonP on 08-01-2006 12:56 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Example_BD.png ‏4 KB
    Example_BD.png ‏4 KB

  • How to create a shortcut key for email ?

    how to create a short key on mac book pro

    You do not say what OS X you are running.  If it is 10.8.3 you simply can have Mail a 4-finger swipe away.
    No short key neccessary?
    If some earlier OS X see >System Preferences>Keyboard>KeyboardShortcuts>ApplicationsShortcuts

Maybe you are looking for

  • IDVD 6 or Toast 8 - ADVICE PLEASE!

    I have some old video that I want to transfer to DVD. They are in all sorts of formats: MOV, AVI, WMV, ASF, MPG. If that weren't enough, I also want to transfer some video from VHS. I am planning to buy eyeTV to do the conversion, but also to capture

  • Aperture 2.1.3 crashes after install of 10.5.7 when creating MobileMe Album

    Looks like I'll have to archive and install 10.5.6 I repaired permissions and trashed the user/library/com.aperture.plist but no joy. Totally reproducible. Kernel exception crashes Aperture. I sent in the log to Apple. Computer is new MP (early 09) w

  • Query string is null while dispatching the request in Websphere for Endeca pages

    Hi, When AssemblerPipelineServlet forward the request with dispatcher the query string is missing from the request in Websphere 7.0 only(works fine in JBOSS). This is happening only for the pages those are created in the Experience Manager. Ex: /stor

  • Module pool using ABAP Objects

    Hi All ,      I have a requirement for creating a transaction/module pool prog using OO ABAP  .     Can you please send some sample documents to guide completely about the creation and execution of the transaction . Rewards are assured !! Regards, Ra

  • [svn:osmf:] 13848: Pre-PARB'ing Layout API:

    Revision: 13848 Revision: 13848 Author:   [email protected] Date:     2010-01-28 03:31:07 -0800 (Thu, 28 Jan 2010) Log Message: Pre-PARB'ing Layout API: - Removal of ILayoutContext (merged with ILayoutTarget). - Layout targets no longer get their wi