Ruby on Rails Wednesday, August 1, 2012

On 1 August 2012 08:55, John Blaze <lists@ruby-forum.com> wrote:
> Thank you so much for your reply Colin.
>
> I believe you are spot on with your answer and what you suggest will
> work and is the correct solution.
>
> For sake of my sanity though, is this solution more of a Rails
> convention or have I been getting standard database design confused in
> my head for a number of years? To my previous understanding I still see
> it as one vehicle has one vehicle_type. Almost like vehicle_type is a
> child table to the parent vehicle. Is this wrong thinking for all
> database design or just Rails conventions?

vehicle_type cannot be like a child to the vehicle, because it is
associated with multiple vehicles, how can it be a child of multiple
parents? It is the other way round if you want to think of child and
parent. A parent (vehicle type) has many children (vehicles), but a
child (vehicle) belongs to a single parent. If you are thinking in
conventional database design just remember that it is the table that
includes the foreign key (vehicle.vehicle_type_id in this case) that
must specify the belongs_to association.

Colin

>
> --
> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment