> Dan Allen wrote:
>
> >This is a simple one, pardon the request for advice.
> >
> >In the specs for JDBCRealm it talks about a username column being in
> >the users table and in the user_role table. Does this mean that the
> >username column has to be the primary key in the users table and not
> >a user_id?? I thought it was bad design to make a text field a
> >primary key since it means that it would have to be updated in two
> >places if the user changed usernames, or are we sticking with the
> >requirment that users can't change usernames or that it is an
> >uncommon task?
> >
This whole thing is really a TOMCAT-USER issue, but there's lots of Tomcat
users here.
JDBCRealm does *not* require that the username be the primary key -- you
can still use an autogenerated sequence number (or whatever) for that
purpose. You'll want to ensure that the username column is indexed,
however, for faster performance.
If you're using a USER_ID column as the primary key for your users and
users_roles tables, the easiest thing to do is create a view that includes
the columns you need for Tomcat's purpose. Consider the scenario where
you've got fully normalized tables like this (datatypes modified as
needed for your database):
Table USERS:
USER_ID Primary key, auto-generated sequence number
USER_NAME String
Table ROLES:
ROLE_ID Primary key, auto-generated sequence number
ROLE_NAME String
Table USERS_ROLES:
USER_ID
ROLE_ID
Then you can create a simulation of what Tomcat needs with something like
this (assuming you've got a database that supports views):
create view users_roles_view as
select u.user_name, r.role_name
from users u, roles r, users_roles ur
where (ur.user_id = u.user_id) and
(ur.role_id = r.role_id);
Now, your administrative apps can continue to use USER_ID and ROLE_ID as
the primary key (in the usual way), allowing changes in the actual user
name and role name values, but Tomcat is still happy with the
USERS_ROLES_VIEW for matching users and roles by name.
> >Dan
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]