Forum

Forum breadcrumbs - You are here:ForumGeneral: Chit-chatCousin Marriages
Please or Register to create posts and topics.

Cousin Marriages

Page 1 of 2Next

Has anyone by chance developed a script to report Cousin marriages?

I have seen this in other software. I was going try and write one, but was looking for some ideas -- basically it would be any marriage where both (couple) share at least one common ancestor  (Maybe excluding 2nd  marriages )

 

Kevin

 

This is just sort of thinking out loud. This project would definitely need to use one or more recursive CTE's. With that in mind, I think I would approach it as a series of nested sub-queries as follows. Working from innermost to outermost, I think the queries would be something like the following.

Query #1. Make a list of PersonID's of everybody in your database who has no parents. This would be people who do not appear as a ChildID in the FamilyTable. This would not need to be a recursive CTE. Call that one column in the query the AncestorID.

Query #2. Make a list of AncestorID's and DescendantID's. This would be a two column query. The AncestorID's would be from Query #1. The DescendantID's would be the PersonID's of all direct descendants. AncestorID's with no DescendantID's would drop out of the query. This would have to be a recursive CTE.

Query #3 and Query #4 would be identical except that one would do a JOIN between DescendantID in Query#2 and FatherID in the FamilyTable and the other would do a JOIN between DescendantID in Query#2 and MotherID in the FamilyTable. Query #3 and Query #4 would both retain the AncestorID. These queries would not need to be recursive CTE's.

Finally, Query #5 would do a JOIN between Query #3 and Query #4 on the FamilyID. That would identify all the cousin marriages. This query would not need to be a recursive CTE.

I think a little more thought needs to go into one issue. Namely, the way I have described it, two people would be cousins who married if, for example, they were descended  from the same fourth great grandfather and they would cousins who married a second time if, for example, from the same fourth great grandmother, even though the fourth great grandfather and the fourth great grandmother were spouses. So Query #1 surely needs to take FamilyID into account.

I may be missing something obvious, but I think that's about it. All the queries should extremely easy except for Query #2 which would have to be a recursive CTE.

I posed this question to Gemini Flash 2.5 and got what appears to be a comprehensive solution which might be a good solution for you to build on. I did not factor in any exclusion for 2nd Marriage - that would indeed complicate the procedure which is already more complex than I would ever think up! You can see the dialog and code at https://g.co/gemini/share/ad5e204a68e9. Here's a screenshot of some results:

 

Uploaded files:
  • Screenshot-cousin-couples.png
kevync has reacted to this post.
kevync

wow !! that is really slick

Certainly, I can work with thank you so much --- AI is getting scary

 

 

Thanks Jerry

What you describe below was one of the challenges I was trying figure out -- who was in both sets or neither etc).

 

think a little more thought needs to go into one issue. Namely, the way I have described it, two people would be cousins who married if, for example, they were descended from the same fourth great grandfather and they would cousins who married a second time if, for example, from the same fourth great grandmother, even though the fourth great grandfather and the fourth great grandmother were spouses. So Query #1 surely needs to take FamilyID into account.

I've gone through a number of iterations of the query with Gemini and have arrived at the attached script which is

  • some 30x faster than the original I reported,
  • more succinct by listing only the relationship via the Most Recent Common Ancestor(s)
  • more informative by including:
    • names of both MRCA's when they are the family from which the cousin couple is descended
    • half-cousin relationships
    • number of children for each cousin couple

Here's a sample output:

FatherNameMotherNameCommonAncestorRelationshipDescriptionNumberOfChildrenFatherGenerationsBackMotherGenerationsBacktotal_generations_back
Wyatt Wxxxx-1476Sarah M. A. Exxxx-1472Joseph Bxxxxxx-911=Sallie Jxxxx-912Full First Cousins0224
David Dxxxxx Bxxxx-6512Mary Bxxxx-440David Bxxxx-62Half First Cousins0224
Abraham Pxxxxx-25237Dixie Axxxxx-27989Archibald Pxxxxx-5955=Malinda Axxxxx-5951Full 1th Cousin 1 time(s) removed7235

On a RM10 database having ca 17,000 couples in its FamilyTable, the query returned 294 results in under 9 seconds. The query should work on all versions of RM databases from RM4 to RM10 but has been tested only with RM10 databases.

Uploaded files:
kevync has reacted to this post.
kevync

Wow! that is great!  I assume you have a pro account to do that?

Thank you so much -- might take me a few mins to digest what all of the code is going -- but this should definitely help me and hopefully it helps others.

 

 

I used a free account on Google Gemini 2.5 Flash. A few months back, I tried to develop a SQLite3 equivalent to RM Set Relationships with the help of free DeepSeek. We succeeded as far as the basic relationships but bombed out trying to cover half relatives. I may give it another try with Gemini.

kevync has reacted to this post.
kevync

Yeah--- that was on my to-do list -- also  some immediate "extended" relationship -- siblings  and parents of non blood spouse  (of cousin /aunt/ uncle)

 

Tom's query seems to run perfectly on my old fashioned and simple minded SQLiteSpy. The output is not quite as pretty as Tom's, but the output all seems to be correct.

It took a little better than 4 seconds to return 127 rows on my database of about 40,000 people.

kevync has reacted to this post.
kevync
Page 1 of 2Next