Finding Candidates’ Similarities with Self-Join

In database-land, SQL self-joins are queries where the table is compared to itself. Meanwhile, in political-land, people often complain of homogeneous candidates and lack of choices.

Using a self-join on the public voting records of Hillary Clinton, John McCain, and Barack Obama, we can see just how similar these candidates are. VoteSmart.org has compiled the complete voting records for all members of congress. As of March 2008, the three remaining likely presidential candidates are all senators, making it easy to compare their records.

View The Full Report Here

I made a quick database table and imported all the data from VoteSmart.org. The database table included the candidate's name, the issue they voted on, and the vote that was cast. Every senatorial vote is a "Y" (yes/for vote), "N" (no/against vote), or "NV" (No Vote was cast).

                 Table "votes"
    Column    |          Type          | Modifiers
--------------+------------------------+----------
 candidate    | character varying(255) | not null
 issue        | character varying(255) | not null
 vote         | character varying(5)   | not null

Indexes:
    "votes_issue_key" UNIQUE, btree (candidate, issue, vote)

First I wanted to see how responsible each candidate was. The Constitution clearly outlines a Senator's job description. Senators propose and vote on Bills. Bills that pass become laws. If you're a Senator and you're not voting on Bills, you're not doing your job.

A quick SQL count, showed that Obama was actually the least responsible candidate, missing almost 1/5th of his roll calls. I'm not complaining, who wouldn't want to take 1/5th of their work week off...like maybe every Friday?

SELECT 
    vote, 
    count(*)
FROM 
    votes 
WHERE 
    candidate_id = 'Obama' 
GROUP BY 
    vote;

-------+------
 count | vote 
-------+------
    NV | 45
     Y | 153
     N | 57

In terms of not missing votes, Hillary is the most responsible, only missing 9% of her roll calls.

View the full report for all the details.

Analyzing Clinton, McCain, and Obama's records, we can also determine how similar they are. To do this, we bust out the self-join

First, we'll see how many opportunities two candidates cast a vote on the same issue. To do this, we:

  1. pick two candidates
  2. ignore missed votes (NV) by either candidate
  3. self-join on the issue
SELECT 
    count(t1.*)
FROM 
    votes t1, 
    votes t2
WHERE 
        t1.candidate_id  = 'McCain' 
    AND t2.candidate_id  = 'Obama' 
    AND t1.vote         != 'NV'
    AND t2.vote         != 'NV'
    AND t1.issue         = t2.issue ;

-------
 count 
-------
   189

Now to find similarities, we execute the same self-joining select but only include results where both candidates voted the same way. An equality comparison to the vote column on both sides of the self-join.

SELECT 
    count(t1.*)
FROM 
    votes t1, 
    votes t2
WHERE 
        t1.candidate_id  = 'McCain' 
    AND t2.candidate_id  = 'Obama' 
    AND t1.vote         != 'NV'
    AND t2.vote         != 'NV'
    AND t1.issue         = t2.issue 
    AND t1.vote          = t2.vote ;

-------
 count 
-------
   60

Results

  • Clinton and Obama cast the same vote 92% of the time.
  • Clinton and McCain cast the same vote 47% of the time
  • McCain and Obama cast the same vote 31% of the time
  • The three candidates were all present for the same roll call 191 times. 29% of the time they all voted the same way — either all for or all against the issue at hand.

(This part is edited from the original post afterJess Turcotte pointed out the errors in my conclusion — Originally, I thought it was Clinton's record that changed. I was wrong.)

One question that stood out was how could Clinton and Obama be identical, while showing a 16% difference when compared to McCain? Since Clinton and McCain were both in office four years before Obama, they must have been more similar when it was just the two of them. One of them must have drastically changed their voting pattern around 2005.

John McCain did.

  • Jan 2001–Jan 2005, Clinton and McCain were 73% similar. They cast the same vote 76 times in 109 opportunities.
  • After 2005, Clinton and McCain are only 34% similar, casting the same vote 65 times in 190 opportunities.

Comparing each candidate to a control subject, makes it pretty obvious that Hillary was consistent from 2001–2008, and John McCain changed notably after 2005. Before 2005 McCain voted 60%–70% in-line with either Clinton or Ted Kennedy (my control subject). After 2005, he only voted similarly with those two democrats 32% of the time.

What made McCain’s voting record change so drastically?

Conclusion

The results seem to prove that the Democratic candidate will be at least 50% different from the Republican candidate this coming November. To paraphrase Ralph Nader circa 2000, a vote for Obama or Clinton will not be a vote for McCain…unless McCain reverts back to his pre-2005 voting patterns.

For more political detail and less technical detail, view the full report.

Comments

Friday, Mar 7, 2008 / 3:27pm jess turcotte said…

i would hypothesize that mccain's voting tendencies have changed substantially, rather than clinton's.

Friday, Mar 7, 2008 / 4:41pm Craig Henry said…

Everyone should vote Hillary. It pains me to say that....but, better of 3 evils.

RIP Mitt.

Friday, Mar 7, 2008 / 9:02pm Dave Tufts said…

@Jess - you're 100% correct. Clinton is the consistent one. I just updated the blog with more accurate into. Thanks!

Friday, Mar 7, 2008 / 11:40pm jess turcotte said…

@dave: woot! glad i could help. go hrc!

Monday, Mar 10, 2008 / 2:31pm Bill Bushee said…

Cool insight into the candidates and an excellent example in the use of SQL self joins.

Saturday, Apr 12, 2008 / 3:00pm JSW said…

This was a very interesting technical analysis of the candidates' votes, it would be interesting if someone political expert could help interpret the data for us.

Monday, Apr 14, 2008 / 2:51pm Kaypers said…

Dave, I must say, this is terrific - very insightful results and a nice rolled up summary of what is clearly a massive database. That said, I think it basically just confirms what we all have been both hearing and thinking about these three candidates. I'm not sure I'm quite at the point of voting for Mrs. Bill Clinton as Craig mentioned above, but it's certainly a tough spot we are all in this time around - that said, the lesser of the three evils is still evil.

Hillary is consistent, I'll give her that, but that's very much the part that scares me - she HAS the ability if put in power to get things done along her agenda, and to be honest - her agenda is socialism - something I'm not a fan of. What we need, is an Ayn Rand like candidate - someone who stands for individual responsibility - someone who believes that the best type of government is the one which governs the least. Unfortunately, it appears that such a view is simply not fashionable any longer - it's easier to be a looter...a leach on the remaining few who try to do the right thing...and then get raped in taxes... I'm all for helping people who really need it - but those who need it need to want to help themselves, and I'm afraid that's more rare than ever these days..

As usual - I'm way off topic...my bad.

Comments have been turned off on this blog.
Read something more recent.

Statements and opinions expressed in this blog and any comments made are the private opinions of the respective poster, and, as such, iMarc LLC is neither responsible nor liable for such content.

Meet The Author

Dave Tufts

Vice President, Director of Technology

Search

Recent Blog Posts

Recent Comments

  • 10 years and a Les Paul

    Jaime commented: Is that Dave Despres in the flesh?

  • The Scientific Method

    TJ Kelly commented: "After 2 seconds on the Chamber page, she realized that she wasn't interested and wanted to get back to iMarc." Therein lies my favorite argument for opening links in the same window.

  • The Scientific Method

    Angelo Simeoni commented: Our issue tracker has a user option to open issue links in a new window. I can't remember if that's enabled by default, but that's one good use case. Imagine if it were default browser behavior to open all links in a new window. I'm going to mention that the next time someone suggests that interaction. Ironically…

  • The Scientific Method

    Marc Amos commented: When somebody who's signing my checks asks me to make their links automatically open in a new window, the scenario you describe above is pretty much the same scenario I describe to them as 'my professional opinion.' I ask them to consider what happens when the user aims for the Back button and it doesn't…

  • The Scientific Method

    Errol Sayre commented: Your key point says it all: "anyone who wanted that behavior was sophisticated enough to create the behavior on demand" My favorite are sites that go to such great lengths to produce open in a new-window-links that they make it impossible for you to right-click and choose "open in new tab". (Generally due to a…

We heart Visitors

  • iMarc
  • 14 Inn Street
  • Newburyport, MA 01950
  • Phone: (978) 462-8848
  • Fax: (978) 462-8807
  • Directions

Contact Us

Whether you have a huge project specification or just want to talk about updating your site, we’re here to help. Fill out the form, and we’ll get right back to you.

Contact Us
  • All Fields Required

Close