MajP
You've got your good things, and you've got mine.
- Local time
- Yesterday, 19:11
- Joined
- May 21, 2018
- Messages
- 9,483
In databases we "normally" do not store a calculated value. For example you store Quantity and Price but never TotalCost (quantity * price). The reason is if something changes like going back and changing the quantity or the price, your database would have to ensure that everywhere this change takes place it updates the TotalCost field. The other reason is TotalCost could get a typo or cleared out. If it is calculated it is always correct. When you run a query you simply calculate the total cost. Same principle with a spread sheet. You would never have a column TotalCost that you manually filled in. It would be a formula.
With that said you can calculate GMA on the fly as well. Find the current MOT, and then that MOT's MOT. But this is a little different because this is not a simple function because you are not just working on current fields you have to search the database. With thousands of records this is not problem with 100 thousands records this could be very resource expensive and slow. Especially in hierarchical data you may need to store things, that technically can be calculated on the fly but will take a lot of resources to try to do on the fly.
Data integrity in a hierarchical database is super important. If one MOT or GMA is a typo or not correct. It can through off a lot of data. Assume you are trying to get all the offspring (several generations deep). If the first MOT is "LRN" and it was supposed to be "LEN" then you will lose all the records from all the below generations.
Now with all that said, I have no idea how accurate that GMA field is. It could be 100%. Not sure how the data was entered, but I assume manually. However, I can run my functions in an update query now or at any time to ensure the data is 100% accurate because it will do the calculation and update the table. So this method can be nearly as accurate as a calculated field since you can update the complete database at anytime, but removes the resource burden of trying to do on the fly.
In this case there a few other things that can be stored to make your life easier. I can make and update tables in a similar manner. I would run code to do the following
Referential integrity. When you have a related child table you want to establish referential integrity to ensure data accuracy. Assume I have TblEmployee and TblChildren. TblChildren stores a foreign key to an Employee in the database. With referential integrity set it ensures when I add a child its parent reference must be a valid ID to an Employee. Also you cannot delete an employee from the DB without first deleting the associated children (this avoid creating orphans). You can do this in a self referencing database as well. In your case you cannot because you have MOTs that are not included in the database (LUC, LEA, LAN). If it was me I would do an update query to add these to the database. They could be identified as somehow as "dummy" records if you do not have complete information on them. But then you could have referential integrity on GMA and MOT.
So I would not do anything until I see the real data. As I said data integrity is even more important with hierarchical data. So besides RI you want to ensure you have other table properties in place for unique indices, required fields, etc.
If I understand the output was not complete and the missing data was mainly due to being deceased.
You can have many views (show all, show deceased, show living, show males, show females, etc.). You can color code or format different nodes and use Icon. You can make males blue, females pink, and have little angel icons by the deceased. See demos. All of this is relatively easy once you learn how to code a Treeview, but that learning is pretty hard if not experienced in vba. So I can build that for you very quickly since I have a ton of code that already does this.
This one shows icons (and I would download the final demo)
This one shows colors for male and female
IMO there is not better way to analyze and look at this type of hierarchical data. Unfortunately this is not a native control of Access and has some issues.
With that said you can calculate GMA on the fly as well. Find the current MOT, and then that MOT's MOT. But this is a little different because this is not a simple function because you are not just working on current fields you have to search the database. With thousands of records this is not problem with 100 thousands records this could be very resource expensive and slow. Especially in hierarchical data you may need to store things, that technically can be calculated on the fly but will take a lot of resources to try to do on the fly.
Data integrity in a hierarchical database is super important. If one MOT or GMA is a typo or not correct. It can through off a lot of data. Assume you are trying to get all the offspring (several generations deep). If the first MOT is "LRN" and it was supposed to be "LEN" then you will lose all the records from all the below generations.
Now with all that said, I have no idea how accurate that GMA field is. It could be 100%. Not sure how the data was entered, but I assume manually. However, I can run my functions in an update query now or at any time to ensure the data is 100% accurate because it will do the calculation and update the table. So this method can be nearly as accurate as a calculated field since you can update the complete database at anytime, but removes the resource burden of trying to do on the fly.
In this case there a few other things that can be stored to make your life easier. I can make and update tables in a similar manner. I would run code to do the following
Referential integrity. When you have a related child table you want to establish referential integrity to ensure data accuracy. Assume I have TblEmployee and TblChildren. TblChildren stores a foreign key to an Employee in the database. With referential integrity set it ensures when I add a child its parent reference must be a valid ID to an Employee. Also you cannot delete an employee from the DB without first deleting the associated children (this avoid creating orphans). You can do this in a self referencing database as well. In your case you cannot because you have MOTs that are not included in the database (LUC, LEA, LAN). If it was me I would do an update query to add these to the database. They could be identified as somehow as "dummy" records if you do not have complete information on them. But then you could have referential integrity on GMA and MOT.
So I would not do anything until I see the real data. As I said data integrity is even more important with hierarchical data. So besides RI you want to ensure you have other table properties in place for unique indices, required fields, etc.
If I understand the output was not complete and the missing data was mainly due to being deceased.
Getting the sorting in a tree is actually much easier, because you can step through it and put things where you want. So imagine you could write a query and then add more code after the fact to add rows where you want. You can do something more like the sorting PDF. You could add all the Oldest sister's and their offspring first. Then add the code to put all the sisters below and their offspring. Then come back and do cousins and brothers.Would be very cool to have a tree for both - expanded includes everyone forever with an asterisk if they're dead, 1st collapse shows only the living, complete collapse shows only the families listed.. sounds v challenging to me with the required sorting?
You can have many views (show all, show deceased, show living, show males, show females, etc.). You can color code or format different nodes and use Icon. You can make males blue, females pink, and have little angel icons by the deceased. See demos. All of this is relatively easy once you learn how to code a Treeview, but that learning is pretty hard if not experienced in vba. So I can build that for you very quickly since I have a ton of code that already does this.
This one shows icons (and I would download the final demo)
Hierarchical Data, Recursion, Tree-Views, and a Custom Class to Assist
Would monitor size or resolution have anything to do with it and/or having a modal form? I'll try again when I get back home.
www.access-programmers.co.uk
This one shows colors for male and female
Question - calculate inbreeding
Cheers. I am having a look at isladogs ColourConverter to see if it will work for me.
www.access-programmers.co.uk
IMO there is not better way to analyze and look at this type of hierarchical data. Unfortunately this is not a native control of Access and has some issues.
Last edited: