Stable Marriages Using SQL Server

  • Comments posted to this topic are about the item Stable Marriages Using SQL Server

    R Glen Cooper

  • Caution:  do not attempt to read this logic until you have had at least two mugs of coffee.

    I did that , and now I need a few shots

    Rick

    One of the best days of my IT career was the day I told my boss if the problem was so simple he should go fix it himself.

  • Anyone else read the title and think the article was related to (stable) married couples using SQL Server, like Paul Randal and Kimberly Tripp, and Sean and Jen McCown?

    No? Just me? Ok...

    Mike Scalise, PMP
    https://www.michaelscalise.com

  • Based on the title, I thought this was going to be an article about how to balance SQL Server with spending more quality time with our spouse.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Of course, now that you're got this code working perfectly, someone's going to ask that you refactor it to support same sex pairings as well.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Eric M Russell wrote:

    Of course, now that you're got this code working perfectly, someone's going to ask that you refactor it to support same sex pairings as well.

    That logic won't work.  Gets in an endless loop...

    Rick

    One of the best days of my IT career was the day I told my boss if the problem was so simple he should go fix it himself.

  • You might want to look at the book "The Stable Marriage Problem." By Dan Gisfield and Robert W. Irving. (ISBN-10 02620171185) MIT press. I also posted a solution to this problem in SQL several years ago. .

    Look at my book, "Joe Celko's SQL Puzzles and Answers (second edition)" when we discussed this in detail in puzzle #67. The important thing to remember about this problem is that there's always a solution but often more than one solution. Some solutions favor the husbands, while others favored the wives. The question is, at a higher level, whose happiness do you want to maximize?

     

    Please post DDL and follow ANSI/ISO standards when asking for help. 

  • This sole purpose of this article was to give a rigorous proof of why the algorithm always stops with a stable mapping.

     

    R Glen Cooper

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply