You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by lee yeushian <ye...@yahoo.com> on 2012/05/29 06:46:05 UTC

USER_ROLES.role_name is foreign key to ROLES.id

Hi,

I had a USER_ROLES table and a ROLES table in my database. (ROLES table is used to manage the list of available roles)
The column "role_name" in the USER_ROLES table is a foreign key to ROLES table ID column.
Is this possible to workable?
Without the ROLES table, it all worked because it was storing the actual rolename instead of the roles.id.

Thanks in advance.

Regards,
Nick Lee

Re: USER_ROLES.role_name is foreign key to ROLES.id

Posted by Jonathan Barker <jo...@gmail.com>.
Why not have your ROLES table use role_name as the primary key?  You
get to enforce referential integrity, role name uniqueness, have your
list of available roles, and have your old solution still work,
because your foreign key IS the actual role name.

On Tue, May 29, 2012 at 12:46 AM, lee yeushian <ye...@yahoo.com> wrote:
> Hi,
>
> I had a USER_ROLES table and a ROLES table in my database. (ROLES table is
> used to manage the list of available roles)
> The column "role_name" in the USER_ROLES table is a foreign key to ROLES
> table ID column.
> Is this possible to workable?
> Without the ROLES table, it all worked because it was storing the actual
> rolename instead of the roles.id.
>
> Thanks in advance.
>
> Regards,
> Nick Lee



-- 
Jonathan Barker
ITStrategic