Wednesday, 21 August 2013

Setting up database structure

Setting up database structure

I have a rails 4 app that im working on and i think i just figured out my
database structure from a model standpoint but im lost at setting up the
migration file (what id's to include, etc...) Here are my models, also if
the models can be modified to perform better i am open to suggestions.
Organization
has_many :jobs
has_many :workers
Worker
has_many :jobs, through: :organizations
belongs_to :organization, polymorphic: true
Job
belongs_to :organization
has_many :workers, through: :organizations (I was mostly confused
about this one)
Basically in my app an organization can have many jobs and many workers. A
worker belongs to many organizations and has many jobs through each
organization. A job belongs to a single organization and has many workers
working on it. Does the above follow that? Also can a worker decide to
make a new organization?

No comments:

Post a Comment