Master id or guid

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

2009/10/2 Andreas [email protected]:

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 might
be a good start. This would allow your different model types all to
have comments without repeating the code everywhere.

Colin

That seems to do it. Thanks for the help!

// Andreas