I am kindof assuming that this is something of a newbie question as
far as ActiveRecord goes, but I've looked through the documentation on
ar.rubyonrails.org and can't seem to figure it. Any advice would be
much appreciated.

I'm trying to setup a small stats tracking webapp in an attempt to
teach myself rails. (previously I've done web development with JSasp
and Micro$oft products) and I'm happy to say that I'm pleased as punch
with rails.  In fact, I've got the site working but I'm using some
pretty hacky calls to ActiveRecord::Base.connection.select_all to pull
data out of the DB and make on my own collections :(.

I have two tables in my DB, one which keeps track of teams and another
which keeps track of matches. (two teams can play a match and there is
one winner and one loser)  The difficult bit seems to be that the
team's id can be stored in either one of two columns in the matches
table.

I feel like I should be able to setup the Team model to have a
collection of the matches which that team has participated in and
here's what I've tried so far:

class Team < ActiveRecord::Base
	has_many :matchess, :finder_sql => 
		"select * from matches " +
		"where matches.one = #{id} " +
		"or matches.two = #{id}"
end

Now this 'works' but it seems that the id that it is inserting into
the SQL string is the ruby unique id for the Team object that is
created. What I want is the id of the team which is stored in the
database. Is this stored in the Team object anywhere? or am I going at
this all backwards?

Is there a resource somewhere that explains when you should use
has_many vs belongs_to or has_and_belongs_to_many?

I'd be happy to clarify if needed, as I wouldn't be supprised if I've
got this basically all wrong. (:

Thanks in advance,
-Harold