Colin Law wrote in post #999008:
> On 14 May 2011 13:04, comopasta Gr <li...@ruby-forum.com> wrote:
>> So my doubts are:
>> - Should I set the custom identifier as the primary key and remove the
>> default id?
>
> No
>
>> - Or should I keep the default Id but instead fill it with the custom
>> identifier?
>
> No
>
>> - Would it make any difference when thinking of performance?
>
> I doubt it.
>
>>
>> I'm currently adding some statistics record for each of those Tags. So
>> one tag "has_many" statistic records. And this statistics record has the
>> Tag identifier stored.
>
> Why store the tag identifier in the statistic?  You have the tag_id
> presumably.  If you need to show the tag itself it is
> statistic.tag.identifier or whatever it is called.
>
> Colin

Thanks Colin.

> Why store the tag identifier in the statistic?
Externally the tag is known by its identifier. They are tags that are
read with the mobile and when they come to the server they are found by
this identifier. When a stat is created the tag where it belongs is also
found by the identifier (creation of a stat is not triggered by a tag
being read).

Yes, when the stat is created I could first use the tag identifier I
get, find the internal tag ID and actually store that internal ID with
the stats instead of the identifier. Then the relationship would be
complete. But I guess I was trying to save that db call since if I would
use the identifier for both that call wouldn't be needed.

Cheers.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to