1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

lookup table check constraint??

Discussion in 'General' started by Eika, Mar 12, 2009.

  1. Eika

    Eika Guest

    Hi, I`m new in oracle.
    Here is my problem:

    I have a table "PossibleLayout {roomNo, layout}
    and a second table "Layout {possLayout}

    The layout field in "PossibleLayout" can have only values from the "Layout" table.
    How can I do that?
    I thought about some kind of check constraint but I don`t know how to do it.

    Please help!

    thanks
     
  2. apps_expert

    apps_expert Forum Expert

    Messages:
    325
    Likes Received:
    28
    Trophy Points:
    330
    Location:
    Chennai, India
    what you are looking for can be achieved very simply with pre-insert triggers. Look them up.
     
  3. simply_dba

    simply_dba Forum Advisor

    Messages:
    95
    Likes Received:
    5
    Trophy Points:
    140
    Location:
    Kolkata, India
    What you need is a foreign key constraint. Create foreign key (PossibleLayout.layout) to (Layout.possLayout)
     
  4. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    The Following link will be the beginners a quick start.

    Constraints

    There are some criteria to be satisfied before establishing foreign keys as described in the above link.

    It is advised to establish the business rules using foreign constraints whenever possible before going applying it through pre-insert trigger. triggers are always last resort.
     
  5. apps_expert

    apps_expert Forum Expert

    Messages:
    325
    Likes Received:
    28
    Trophy Points:
    330
    Location:
    Chennai, India
    ahh.. FK constraint... :)

    of course of course... (Was i asleep when i said trigger?? ..scratching head... ;) )