Cannot use Foreign Keys

Help
Lemonie
2012-11-28
2013-06-06
  • Lemonie
    Lemonie
    2012-11-28

    Hi

    I do not understand how to use the foreign key, or if I am honest, what it can do.

    I have been using Zoho which is all singing all dancing does it all for you and am trying to teach myself.

    I have a table > Rescues .. which contains a column = name (varchar 200)
    I have a table > Dogs in Need .. which contains a column = rescue (enum dropdown with plugin)

    I want to link the 2 columns so that when I add a rescue into the rescue table, the name shows up in the dropdown list on the dogs in need table.  Is this what a foreign key does and if so how do I do it?

     
  • Jakub Vrána
    Jakub Vrána
    2012-12-01

    This question is not related to Admner.

    You want this table structure:

    rescue: id, name
    dog_in_need: id, rescue_id, …

    The dog_in_need.rescue_id is a foreign key to rescue.id.

    With this table structure, any new rescue will show up in editing Dogs in Need in http://www.adminer.org/editor/.