Topic: Parent-Child Relationships

Hi Everyone,
Belated Happy Mothers Day  smile
.
I have an issue with Parent/Child relationships.
Please see the attached file.
.
When I delete a piece of Equipment it does not delete the corresponding Service record
.
Vessel - main parent table
     Equip - Equipment table
            Service - Service table
.
If I delete a Vessel it does delete the related equipment records...but NOT the related service records?
If I delete just an Equipment record it does delete the piece of equipment...but NOT the related service record.
.
I have Cascade set in both relationships.
.
Hopefully you can see what I might be doing wrong.
.
Thanks
Frank

Post's attachments

Attachment icon Parent-Child Relationships.pdf 168 kb, 148 downloads since 2022-05-09 

2 (edited by sparrow 2022-05-10 09:19:14)

Re: Parent-Child Relationships

Hi Frank

If you have everything set up correctly for table fields, the reason that records are not deleted may be the presence
of NULL or other number instead of an true ID number.
You can create a table in the validation form and display the values of the columns
in the sequence (tbl_Vessel - ID), (tbl_Equip - id_Tbl_Vessel, ID), (tbl_Service - id_tbl_Equip).
You will have four columns.
Where, in case of correct filling, the values of 1.2 columns and 3.4 columns will be equal and not empty (NULL).
For example. If everything is correct:
1 1 4 4
3 3 7 7
9 9 8 8

Any other match or presence of NULL is incorrect.
Check for yourself.

3 (edited by papafrankc 2022-05-12 01:28:59)

Re: Parent-Child Relationships

Sparrow,
Thanks for your suggestion.
I tried to create a table as you suggested but didn't have much luck.
.
But that's OK because I'm using SQLiteStudio to look at the data in all of the fields in all of my tables.  In case some folks aren't familiar with it, here's the link https://sqlitestudio.pl/.  It shows all the ID nbrs and the data in each of the fields.  I think it's a pretty neat application.  The more I use it the more I like it.  And best of all it's FREE Open Source software.  Once you link it to the sqlite.db file in your MVD application, you can check out all of the data in the tables and see exactly what's going on.  There may be better ways to check out the data, but for a novice like me, it's been a big help.
.
Your suggestion to check the ID's to see if there were any broken links was a good one as I found a couple of issues.  I had to remove some code I had in my original program.  Then it looks like I was able to fix the link problem.
.
Note: I'm sure you could create a form showing all of the data including the ID's but to me SQLiteStudio is really easy and will show you the data, no matter what you do to the tables.
.
Thanks again for your help.
Frank

Re: Parent-Child Relationships

Hi Frank,

Too bad you didn't make it. I just showed you an easier way to see the relation in TableGrid MVD.
It's good that you are using SQLiteStudio. With sufficient skills in writing queries,
you can see everything you need in the studio and not just single tables.
For example, what I suggested to you in the program, you can get in the studio with the request:

SELECT tbl_Vessel.id, tbl_Equip.id_Tbl_Vessel, tbl_Equip.id, tbl_Service.id_tbl_Equip
FROM tbl_Vessel, tbl_Equip, tbl_Service
WHERE tbl_Vessel.id=tbl_Equip.id_Tbl_Vessel
AND tbl_Equip.id=tbl_Service.id_tbl_Equip