Help me with choosing relations between tables

12 views
Skip to first unread message

Barry

unread,
Apr 17, 2013, 10:07:31 AM4/17/13
to rubyonra...@googlegroups.com
My app lets users to create educational tests on various subjects, and then another users can complete them.
Each User has some kind of Profile. There should be opportunity to add tests they like in their profiles, so they don't need to seatch it it then they want to complete it again. The problem is that I don't know what relations should be between test and profile.
I don't want them belong to each other, because the logic is not like they belong to each other, User can simly add shortcut and easily find required test from his profile. 
So I can do this without a relation? Or I can't?

Colin Law

unread,
Apr 17, 2013, 10:12:17 AM4/17/13
to rubyonra...@googlegroups.com
What are the attributes of a Profile object?
Can a use have more than one profile?
Can a profile be associated with more that one user?
I presume a profile can have multiple tests
Can a test be in more than one profile?

Colin

>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/VmLPlgEGeW4J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Barry

unread,
Apr 17, 2013, 10:46:26 AM4/17/13
to rubyonra...@googlegroups.com, cla...@googlemail.com
1) Just Added Tests
2) No
3)No
4) Yes
5) Yes
Basically it is like has many tests and belongs to many tests

среда, 17 апреля 2013 г., 18:12:17 UTC+4 пользователь Colin Law написал:

Colin Law

unread,
Apr 17, 2013, 11:59:52 AM4/17/13
to rubyonra...@googlegroups.com
On 17 April 2013 15:46, Barry <bur...@mail.ru> wrote:

I have re-ordered your reply so it makes sense, please don't top post. Thanks

>
> среда, 17 апреля 2013 г., 18:12:17 UTC+4 пользователь Colin Law написал:
>>
>> On 17 April 2013 15:07, Barry <bur...@mail.ru> wrote:
>> > My app lets users to create educational tests on various subjects, and
>> > then
>> > another users can complete them.
>> > Each User has some kind of Profile. There should be opportunity to add
>> > tests
>> > they like in their profiles, so they don't need to seatch it it then
>> > they
>> > want to complete it again. The problem is that I don't know what
>> > relations
>> > should be between test and profile.
>> > I don't want them belong to each other, because the logic is not like
>> > they
>> > belong to each other, User can simly add shortcut and easily find
>> > required
>> > test from his profile.
>> > So I can do this without a relation? Or I can't?
>>
>> What are the attributes of a Profile object?

> 1) Just Added Tests

>> Can a use have more than one profile?

> 2) No

>> Can a profile be associated with more that one user?

> 3)No

>> I presume a profile can have multiple tests

> 4) Yes

>> Can a test be in more than one profile?

> 5) Yes
> Basically it is like has many tests and belongs to many tests

I don't understand why you have a Profile object at all, is it not
just part of the User?
As you say, the relation between tests and profile (or user) is
has_and_belongs_to_many or has_many through. I prefer has_many
through as I find it easier to think about. Have a look at the Rails
Guide on ActiveRecord Relations if you don't understand how to do
this.

Colin
Reply all
Reply to author
Forward
0 new messages