Deleting foreign key record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mathewgk80
    New Member
    • Sep 2007
    • 103

    Deleting foreign key record

    Hi all,.

    I have a table Student and the primarykey is studid..

    This studid is the foreign key in another table called Class.

    I want to delete the records in the table Class...

    How can i do it..

    Please help me...

    Regards,

    Mathew
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    you'll need to drop the foreign keys between the two tables delete the required data, and add the foriegn keys once again.

    Comment

    • mathewgk80
      New Member
      • Sep 2007
      • 103

      #3
      Originally posted by jamesd0142
      you'll need to drop the foreign keys between the two tables delete the required data, and add the foriegn keys once again.
      Hi James,

      Is that the only method to delete those records??

      Regards,
      Mathew

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        What error are you getting when you try to delete these records?

        this will help me determine if i have suggested the correct method...

        because you shouldnt really get any issues deleting a row frm the table 'class'

        i can see y u wud get an error deleting a record from Student table however.

        Comment

        • mathewgk80
          New Member
          • Sep 2007
          • 103

          #5
          Originally posted by jamesd0142
          What error are you getting when you try to delete these records?

          this will help me determine if i have suggested the correct method...

          because you shouldnt really get any issues deleting a row frm the table 'class'

          i can see y u wud get an error deleting a record from Student table however.
          Hi all,


          I didnt try to delete record.. i have to do it,, before that i would like to know whether it is possible or not.....

          regards,
          Mathew

          Comment

          • jamesd0142
            Contributor
            • Sep 2007
            • 471

            #6
            Originally posted by mathewgk80
            Hi all,


            I didnt try to delete record.. i have to do it,, before that i would like to know whether it is possible or not.....

            regards,
            Mathew

            Ok, well as i said above, i can's see any problems with deleting from the 'class' table, although you might have a problem deletiung from the 'student' table because;

            The studid field in the 'class' table would no longer have a lookup, so droping the foriegn keys first would allow you to delete a record in 'student', although if you have a value in the 'class' table for studid thats not in the 'student' table you 'shouldnt' be able to create the foriegn keys once again...

            i hope you understand my logic here :s

            Comment

            Working...