# Master id or guid

**URL:** <https://www.ruby-forum.com/t/master-id-or-guid/176591>\
**Category:** Rails\
**Created:** [October 2, 2009, 7:22pm UTC](https://www.ruby-forum.com/t/master-id-or-guid/176591 "2009-10-02T19:22:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [October 2, 2009, 7:22pm UTC](https://www.ruby-forum.com/t/master-id-or-guid/176591/1 "2009-10-02T19:22:17Z")

</div>

Hi

I’ve just started looking into building a rails frontend to a database  
project I’ve been working on but I need some help with how to convert  
some parts of the database.

The database got a bunch of tables each describing a different type of  
entity and each of these entities can have several comments. I’ve  
solved this by giving all entities an identifier through a master  
identifier table (entityId1 --\> masterId, entityId2 --\> masterId) but  
I can’t think of any way to get this working in rails and also it’s  
kinda an ugly hack in my opinion.

Any thoughts on this? Thought of using some sort of guid but most  
people seem to think it’s not worth it?

// Andreas

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [October 2, 2009, 7:36pm UTC](https://www.ruby-forum.com/t/master-id-or-guid/176591/2 "2009-10-02T19:36:55Z")

</div>

2009/10/2 Andreas [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> identifier table (entityId1 → masterId, entityId2 → masterId) but  
> I can’t think of any way to get this working in rails and also it’s  
> kinda an ugly hack in my opinion.
> 
> Any thoughts on this? Thought of using some sort of guid but most  
> people seem to think it’s not worth it?

_If_ I understand I think you might want to look at polymorphic  
relationships.  
[http://wiki.rubyonrails.org/howtos/db-relationships/polymorphic](http://wiki.rubyonrails.org/howtos/db-relationships/polymorphic) might  
be a good start. This would allow your different model types all to  
have comments without repeating the code everywhere.

Colin

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [October 2, 2009, 9:22pm UTC](https://www.ruby-forum.com/t/master-id-or-guid/176591/3 "2009-10-02T21:22:54Z")

</div>

That seems to do it. Thanks for the help!

// Andreas
