Post by Uncle Buddy on Jul 11, 2022 4:25:55 GMT -8
This has been a highly experimental process, rewriting the places feature. The places feature has been maybe the hardest part of creating Treebard, since the beginning. When elements with unique IDs (primary keys in the database) have to be combined into complex or compound elements with their own unique IDs, and both sets of IDs are important, the way it's always seemed to me is that this feature is skating on the edge of denormalization, when in order to get the job done, some kind-of important sacred guidelines of database design are gonna have to be sidestepped or compromised.
Recently I moved all the types tables and the place tables out of the tree database into the common database so that the user can create types and places and they will apply to all the user's trees. This comes with a drawback: no foreign key enforcement between the two databases. In the case of types, I don't think it's going to be a problem. The text column such as "spouse" in the kin_type table has a UNIQUE NOT NULL constraint in every types table, so the user will be free to create kin types, event types, media type, etc. without fear of duplicating types that already exist. Compared to nested places, types are simple.
Serious improvements have been made in nested places and place autofill code in the past week. These nested places, which have to be unique, should probably define their primary key as the unique columns themselves instead of the AUTOINCREMENT integer foreign keys I've always used. This would add a unique constraint to the combination of columns (the nested place) that I could have used today when I found that--because many places with different individual place_ids can be called "Paris"--when the GUI seems to be working, the database still has to be checked. It would have been nice if those columns that comprise a nested place that has to be unique anyway... had also comprised a primary key. Then the duplicates wouldn't have been allowed and I wouldn't have posted earlier that things were going well. Things aren't exactly going to hell, but they are going slower than I thought when I posted earlier today.
I don't know that the lack of foreign key enforcement has caused a problem already, but I strongly suspect that when I reference nested_place_id from the finding and assertion tables, I will be happier in the long run if I put the place tables back into the tree database now before the lack of FK constraints teaches me a lesson the hard way. I'll leave the types tables in the common database and see how it goes, but I don't want to see how it's gonna go for something as complex as the nested places feature to try and live without FK constraints.
There are other ways for the user to get his places data into another tree. I can create an import/export tool that will allow place tables from two Treebard databases to be merged. For me, this isn't even a big priority, although there are times when the research involved to try and track a place through its various changes of name, boundary, and enclosing place can get pretty hairy.
I seem to recall from elementary school social studies classes that the maps which show mainly position and boundary vs. terrain are called "political" maps. I can see why, and I don't generally follow many of the shenanigans of politicians as they fiddle around with the borders of places. (Although I have a great true story to tell--with a terrible ending--about how President Bill Clinton took a historical rose quartz mining claim away from me on his way out of office, so he could have a National Park on his CV.) Aside from those rare cases where it affects me personally, I don't care about the border-mongering of politicians until it comes time to determine if a family or individual I'm researching actually lived in the subject place, or if the relevant place name is just plain wrong for the period of time in question.
So tomorrow I'll be creating my first multi-column primary keys and foreign keys? And definitely moving the place tables back into the tree database.
Recently I moved all the types tables and the place tables out of the tree database into the common database so that the user can create types and places and they will apply to all the user's trees. This comes with a drawback: no foreign key enforcement between the two databases. In the case of types, I don't think it's going to be a problem. The text column such as "spouse" in the kin_type table has a UNIQUE NOT NULL constraint in every types table, so the user will be free to create kin types, event types, media type, etc. without fear of duplicating types that already exist. Compared to nested places, types are simple.
Serious improvements have been made in nested places and place autofill code in the past week. These nested places, which have to be unique, should probably define their primary key as the unique columns themselves instead of the AUTOINCREMENT integer foreign keys I've always used. This would add a unique constraint to the combination of columns (the nested place) that I could have used today when I found that--because many places with different individual place_ids can be called "Paris"--when the GUI seems to be working, the database still has to be checked. It would have been nice if those columns that comprise a nested place that has to be unique anyway... had also comprised a primary key. Then the duplicates wouldn't have been allowed and I wouldn't have posted earlier that things were going well. Things aren't exactly going to hell, but they are going slower than I thought when I posted earlier today.
I don't know that the lack of foreign key enforcement has caused a problem already, but I strongly suspect that when I reference nested_place_id from the finding and assertion tables, I will be happier in the long run if I put the place tables back into the tree database now before the lack of FK constraints teaches me a lesson the hard way. I'll leave the types tables in the common database and see how it goes, but I don't want to see how it's gonna go for something as complex as the nested places feature to try and live without FK constraints.
There are other ways for the user to get his places data into another tree. I can create an import/export tool that will allow place tables from two Treebard databases to be merged. For me, this isn't even a big priority, although there are times when the research involved to try and track a place through its various changes of name, boundary, and enclosing place can get pretty hairy.
I seem to recall from elementary school social studies classes that the maps which show mainly position and boundary vs. terrain are called "political" maps. I can see why, and I don't generally follow many of the shenanigans of politicians as they fiddle around with the borders of places. (Although I have a great true story to tell--with a terrible ending--about how President Bill Clinton took a historical rose quartz mining claim away from me on his way out of office, so he could have a National Park on his CV.) Aside from those rare cases where it affects me personally, I don't care about the border-mongering of politicians until it comes time to determine if a family or individual I'm researching actually lived in the subject place, or if the relevant place name is just plain wrong for the period of time in question.
So tomorrow I'll be creating my first multi-column primary keys and foreign keys? And definitely moving the place tables back into the tree database.