1 2 3 Previous Next 33 Replies Latest reply on Oct 3, 2012 10:48 AM by philmodjunk

    deleting records

    jb_1

      Title

      deleting records

      Post

           hi ;

           please I have a probleme and I can't resolve it. I have a database That contant 3 tables. A:Cars, B:Peugeot and C:renault.

           In tables B and C , I have to add and delete cars every time , BUT when I delete a Car from the table B , a car deleting from table C, whith the same ID of the one of ather table. I have 2 keys relating the 2 tables with the big one "tableA" , "IDcars" and "TypeCars"...when a cars was deleting in B or C , It was deleting automatically in A and the other table. How can I resolve tghis problem, I must delete Cars from one table of "B" or "C" who will be delete it from A. thanks

        • 1. Re: deleting records
          philmodjunk

               You appear to have these relationships:

               Cars::__pkCarID = Peugeot::_fkCarID

               Cars::__pkCarID = Renault::_fkCarID

               Your description of what happens when you delete a record from either Peugeot or Renault would indicate that you have selected the "Delete" option for Cars in both the relationshp from Cars to Peugeot and also from Cars to Renault. Since this appears to be a one to many relationship from Cars to the other two tables and it appears that Cars is the "parent" table, this option should not be selected. Selecting the delete option for the "child" tables, Renault and Peugeot, on the other hand, would seem to be the option you need here so that deleting a table from Cars deletes any related records from the other two tables, but not the reverse, as is happening now.

                

                

          • 2. Re: deleting records
            jb_1

                 Hi PhilModJunk;

            First I would to thal you for your solution , I found it very nice fr my problem ; then , when I Delete cars from a table " Renault " or " Peuguot" , I wloud delete it , also , from the "parent" table Cars; however, the problem is,when I applied your solution, I can remove cars from any table " child" But it dosent deleting from the table " Cars " .Any other solution or additional solutions...???Thnks again.

            • 3. Re: deleting records
              philmodjunk

                   Now I am confused. First you indicate that deleting a record from Renault or Peuguot deletes a record from Cars and you don't want that. now you say:

                   

               I can remove cars from any table " child" But it dosent deleting from the table " Cars "

              Isn't this what you had originally? Why would you want to delete the record in cars automatically when you delete from one of the other two tables?

              • 4. Re: deleting records
                jb_1

                     I have no langer using filemaker pro ; I will explain what I like to do . I want to delete the record in cars automatically whenI delete from one of the other two tables because when I sell a car , I don't have to keep it in the parent TABLE , when a car was removed from one table , It must be removed from all the DATABASE . But , my problem's, when I remove a cars from table "Renault" , taking for exp "CArId=5_renault "; the car "CarIDPeugeot=5" wil be deliting from the table" Peugot" and table parent "A". however, I would remove the CarId=5_Renault from the table"renault" ans the table"Parent". Is this more clear for you. Thanks again

                • 5. Re: deleting records
                  philmodjunk

                       It is clear but confusing. Why would a car in Renault and a car in Pugeuot have the same Car ID number?

                       If you return to Manage | Database, put back the delete option for "car" in these two relationships, but clear the delete option for Pugeot and Renault, you'll be able to delete a record from either of these two tables and the matching record in Cars will be deleted without deleting any matching records in the other child table.

                       But this looks like the real problem of having different records in Renault and Pugeot with the same Car ID value when they should have unique ID numbers created in the Cars table.

                  • 6. Re: deleting records
                    jb_1

                         "But this looks like the real problem of having different records in Renault and Pugeot with the same Car ID value when they should have unique ID numbers created in the Cars table."

                         It's not a choice to have a same Id in the 2 table(serial number generated on creation ) ; But , I have a FK "TypeCars" that related table "B" and "C" with parent "A"..can I use this Key to resolve the problem of confused Id??!!

                    • 7. Re: deleting records
                      philmodjunk

                           I can't answer that. You need to describe the exact fields used in these relationships and the purpose for each table before I can make any suggestions.

                      • 8. Re: deleting records
                        jb_1

                             Table A:parent

                             TableB,tableC:child

                             I like to:

                             when I ADD record in B or C , I should aded it automatically in A

                             when I DELETE record from B ; I should delete it automatically "just"  from A and not C (by the same Id if exists)

                             when I DELETE record from C ; I should delete it automatically "just"  from A; and not B.(by the same Id if exists)

                             when I DELETE record from A ; I should delete it automatically "just"  from B or C ( it depend of the Id and The TYpe of the records).

                             But:

                             The problem is , some times I have the same Id in the 2 tables B and C; however ,when I delete a record from tyhe first table"B", it will be removed automatically from the second table"C"..

                        • 9. Re: deleting records
                          philmodjunk

                               Apologies in advance, but you are repeating what you have posted before with one new detail--what you want to happen when a new record is added. This does not answer my questions.

                               From what little I know about your database, it seems like a mistake for a Renault car and a Peugeot car to both have the same ID number.

                          • 10. Re: deleting records
                            jb_1

                                 table"B"------------------------------------------------------- Table"A"--------------------------------Table"C"

                                 Id_Peugot (Indexed,Auto enter-serial)     =                Id_cars(Number)                    =       Id_renault (Indexed,Auto enter-serial)     

                                 TypeCarPeugot (text)                               =                   TypeCars (text)       =            TypeCarRenaut (text)                                                 

                                 the id was incremented ever I add a record in any table.begining from 1, ever I add a record , the Id increment by 1 .Thats why I have same Id in many records.All of them (Id_renault,Id_Peugot) begining from 1 and increment by 1 .

                            • 11. Re: deleting records
                              philmodjunk

                                   And this produces records in table A with duplicate ID numbers and this in turn is the source of your confusion.

                                   I still do not have an answer to this question: "...and the purpose for each table"

                                   That answer may change the following recommendations, but from what I see so far, it looks like you need these relationships:

                                   peugot-----Cars-----renault

                                   Cars::__pkCarID = peugot::_fkCarID

                                   Cars::__pkCarID = renault::_fkCarID

                                   where __pkCarID is an autoentered serial number and _fkCarID is not an auto-entered serial number.

                              • 12. Re: deleting records
                                jb_1

                                     I m trying yours solution and It very niice and veru powerfull.. It works BUT, how Can she works if I would make "injection" from an extenal file of records..!!

                                • 13. Re: deleting records
                                  jb_1

                                       Well; When I make a new record ; every thing is OK. But when  I make an injection of record from an .xsl file ; I cant't see recortds in the layout , But I sow them in the layout A of the table Prent "A".?? what's the solution??!!

                                  • 14. Re: deleting records
                                    philmodjunk

                                         The translation from your language to English is making some of your posts hard to understand.

                                         I think by "injection" you mean that you are using Import Records to import records into either of the two child tables: Renault and Peugot.

                                         After importing the records, you would have new records in the child table, but no new records in the Parent table: Cars. But a script can loop through your newly imported records, create new records in Cars and copy the ID numbers generated in Cars to the match field in the child table in order to link them to each other.

                                         Please note that you still have not told me what the main purpose is for the Cars table and the two child tables. If I knew that info, I might be able to provide more detailed and helpful advice.

                                    1 2 3 Previous Next