9 Replies Latest reply on Feb 18, 2010 7:45 PM by comment_1

    Deleting a related record

    dvra

      Title

      Deleting a related record

      Post

      This question has probably been answered before but cant seem to find the answer. 

       

      I have a table of contacts and a table of contactgroups which has 2 fields "Group Name" and "ContactIDs" , in the ContactsIDs field i have all contactIDs from my contact table. So for example my contactgroups table would look like.

      ....

       

      Group Name                  ContactIDs

      MyGroupname1                10 22 48 32 

      MyGroupName2                18 14 23 33

       

       

      Im displaying the related contactIds in a portal but when i delete the portal records it also deletes the parent Contact records. How do i simply delete the id from the field without deleting the parent record?

       

      I have a relationship between the 2 tables and i do not have any of the relationship options checked

       

      Im using filemaker pro advance 9 

       

      is it also possible to add to the groupname a additional id? if you can help with the first question it will be greatly appreciated.

       

      Thank you  

        • 2. Re: Deleting a related record
          comment_1
            

          This is not a good arrangement to have. I am assuming a contact can belong to more than one group, so the relationship between Groups and Contacts is many-to-many.

           

          Ideally, you should use a join table to associate a contact with a group. Alternatively, you could use a checkbox field in the Contacts table(!) to assign a contact to one or more group. This is easier to implement, but lacks some reporting/finding features that are available with a join table.

          • 3. Re: Deleting a related record
            dataWolf
              

            I don't really understand your question. If you want to delete text from a field, why don't you simply press the delete button while in the field? It sounds like you are using Delete Record, which you do not need to do.

             

            • 4. Re: Deleting a related record
              comment_1
                 I believe the original question was how to remove "22" from "10 22 48 32" when contact record #22 is deleted.
              • 5. Re: Deleting a related record
                dataWolf
                  

                1) What is ContactIDs and how is it structured? Is it a 'text' field that you have typed data into and now want to update? Is it stored? I don't understand what this field is. It looks like a very bad idea if it is a text field.

                 

                2) Usually when I go to delete a portal record it asks whether I want to delete the related record or the current record. I guess you wouldn't get that option if you don't have marked the ability to delete related records. So it is just deleting the 'current' record. But I don't think you want to delete the current OR the related record.

                 

                3) Yes you can and SHOULD have a GroupID that is separate from the ContactIDs

                • 6. Re: Deleting a related record
                  dvra
                    

                  Thank you for your responses.

                   

                  The contactgoups table is actually structured as follows

                   

                   

                  ContacGroupID(Number Index) ContactGroupName(Text)  ContactIDs(Text)

                   

                  I store all contact ID from the contacts table in the ContactIDs in the groups table. I insert multiple contact ids in the ContactIDs feild

                   

                  I can normalize the contactgroups table lilke so

                   

                  ContactGroupName            ContactIDs

                  GroupName1                           12

                  GroupName2                            8

                  GroupName3                           15

                   

                   

                  but I see i will probably run into the same problem

                   

                   

                  either way can I simply delete  "22" from "10 22 48 32"

                   

                  or is this structure a bad idea to begin with? I actually obtained this solution from this forum. 

                   

                   

                  The end result is to add contacts to a distribution list (Grouping Contacts) and have the ability to remove or add contacts to the lists I create. A pretty common requirements fora contact database.

                   

                  Your helps is greatly appreciated

                  • 7. Re: Deleting a related record
                    comment_1
                      

                    dvra wrote:
                    I can normalize the contactgroups table lilke so

                     

                     

                    ContactGroupName            ContactIDs

                    GroupName1                           12

                    GroupName2                            8

                    GroupName3                           15

                     

                     

                    but I see i will probably run into the same problem


                     

                     

                    Not really, because then you can set the relationship to automatically delete related records in the join table when a contact is deleted.

                     

                     

                     


                    dvra wrote:

                    is this structure a bad idea to begin with?


                    I don't even see how your relationship can work that way (at the very least, the numbers should be return separated).

                     


                    • 8. Re: Deleting a related record
                      dvra
                        

                      It does work. If i create a relationship from contactID (Contact Table) to ContactIDs (ContactGroups) the portal will show up correctly. Som how filemaker converts the field to a array of some sort (Just as long as there is a carriage return between each number (ContactID).

                       

                      Im not looking to delete the contact at all; Im looking to delete the contact ID from the contactgroups table without deleting the contact in the Contacts table.

                       When i go to my Contact Groups Layout I am able to view all my groups and the portal displays all contacts in the group via a relationship.

                       

                      if i remove a contact from the group the contact is also deleted from the contacts table. I only want to delete a contact ID from the group or add a contact to the group. I think i can add one with a simply script. 

                       

                       

                       

                       

                      • 9. Re: Deleting a related record
                        comment_1
                          

                        dvra wrote:

                        if i remove a contact from the group the contact is also deleted from the contacts table.


                        I must be missing something: how do you remove a contact from the group? For that matter, how do you add one?