SQL and ruby Questions