How do I represent this DB structure????

HI all, newbie question, I have the following DB Structure

actors
- id
- name
- age

movie
- id
- name
- year

role
- id
- name
- requiresSwimming
- requiresHorseskills

movie_actor
- actor_id
- movie_id
- role_id

How should I map this in my model in rails? An actor can only have
one role in each movie

Thanks J

It makes a little more sense to me to have the db look like this:

actor

  • id

  • name

  • birth_date

movie

  • id

  • name

  • year

role

  • actor_id

  • movie_id

  • requires_swimming

  • requires_horsemanship

Then your models would look like this

class Actor < ActiveRecord::Base

has_many :roles

has_many :movies, :through => :roles

end

class Movie < ActiveRecord::Base

has_many :roles

has_many :actors, :through => :roles

end

class Role < ActiveRecord::Base

belongs_to :actor

belongs_to :movie

end

Lol? Why did you post that qeustion again? i answered your first
thread 1 hour ago?