Stable Marriages Using SQL Server

  • Glen Cooper

    SSCommitted

    Points: 1697

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

    R Glen Cooper

  • skeleton567

    SSCertifiable

    Points: 5050

    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

    The only thing worse than being an influencer
    is believing one.

  • Mike Scalise

    SSCrazy Eights

    Points: 8129

    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

  • Eric M Russell

    SSC Guru

    Points: 125089

    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

  • Eric M Russell

    SSC Guru

    Points: 125089

    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

  • skeleton567

    SSCertifiable

    Points: 5050

    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

    The only thing worse than being an influencer
    is believing one.

  • jcelko212 32090

    SSCrazy Eights

    Points: 9012

    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. 

  • Glen Cooper

    SSCommitted

    Points: 1697

    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