I'd argue for a person table (employees are people too), an address 
table, and a full join table. A person can have many addresses, and an 
address can have many people.  People move, and you may want to keep 
history on a person's past addresses (especially if there's a payroll or 
tax implication).

Person
id, first_name, last_name, etc, etc
has_many :residences
has_many :addresses, :through => :residences

Address
id, line_1, line_2, city, state, postal_code, etc, etc
has_many :residences
has_many :people, :through => :residences

Residences
person_id
address_id
additional fields, perhaps start_date, end_date, and anything else that 
might be related to an instance of this person at this address.
belongs_to :person
belongs_to :address

Maintenance of residences becomes a bit more involved (do you delete the 
residence, or just end it - which gets to that residence history 
question), but the flexibility might pay off later...

Showing field values is as simple as

@person.addresses.each do |address|
  address.city
  address.state
  address.postal_code

or

@address.people.each do |person|
  person.first_name
  person.last_name
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to