On 6/7/05, Kieran Johnson
<endlessinfinity-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''m attempting my first rails app and wanted some advice on the
best db schema.
> I will be using mysql and this is how I thought I would create it
>
> ...
>
> The relationships I need to define are:
> Client has_many Projects
> Projects has_many Images
> Project belongs_to Client
> Image belongs_to Project
> Image belongs_to Category
> Category has_many Images
>
> Would anyone suggest doing anything differently? I had looked at using
> join tables for the Client/Project relationship and Project/Image
> relationship. Then defining then as habtm in the models, but
wasn''t
> sure if this was necessary.
This really depends on if you need to have multiple clients on one
project, or multiple projects per image, etc. Figure out your needs,
and define the relations accordingly. If an image ever only belongs
to one projects, then don''t bother with habtm. Same holds for
client/project relation.
Only you know what the requirements are. I would suggest you start
coding, and if you realize you made a mistake, just go back and change
it. It would be simple enough to change once you''ve started working
anyway. That''s why god invented "alter table" syntax :)
Good luck, and have fun!
Jason