Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Foreign key

Foreign key

Scheduled Pinned Locked Moved C#
databasequestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    ppp001
    wrote on last edited by
    #1

    Hi, for a database table having a foreign key refered to another table, what advantage will it gain to have the foreign key ? Will it faster in joining the refered and referring table ? or something else ? Thanks

    W A 2 Replies Last reply
    0
    • P ppp001

      Hi, for a database table having a foreign key refered to another table, what advantage will it gain to have the foreign key ? Will it faster in joining the refered and referring table ? or something else ? Thanks

      W Offline
      W Offline
      whizzs
      wrote on last edited by
      #2

      Typically they are used for inner joins to prevent cartesian products

      1 Reply Last reply
      0
      • P ppp001

        Hi, for a database table having a foreign key refered to another table, what advantage will it gain to have the foreign key ? Will it faster in joining the refered and referring table ? or something else ? Thanks

        A Offline
        A Offline
        Andre Ziegler
        wrote on last edited by
        #3

        foreign keys are used for checking references between records in different tables. With a constraint defined a record cannot be removed as there is a reference to a record in an another table. 'A programmer ist just a tool which converts caffeine into code'

        P 1 Reply Last reply
        0
        • A Andre Ziegler

          foreign keys are used for checking references between records in different tables. With a constraint defined a record cannot be removed as there is a reference to a record in an another table. 'A programmer ist just a tool which converts caffeine into code'

          P Offline
          P Offline
          ppp001
          wrote on last edited by
          #4

          Thanks. So what will happen in the database if the foreign key relation are violate in MySQL, will the database return an exception or something else ?

          S 1 Reply Last reply
          0
          • P ppp001

            Thanks. So what will happen in the database if the foreign key relation are violate in MySQL, will the database return an exception or something else ?

            S Offline
            S Offline
            seee sharp
            wrote on last edited by
            #5

            In that case database suppose to give constraint error. - ashish

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups