Updates, SQL and Ruby Triangle Problem