I'm in a project using Hibernate (version 2.1.8) to access a DB2 database. The DB has a table storing users with various attributes (name, supervisor etc...), users can belong to one of two possible roles (user or supervisor). The primary key consists of a user ID. The table gets its data from an external system which authenticates the user while logging in.
A request was made to add an attribute "signature" which is applicable to users only; supervisors won't have or need it.
My problem is that I can't decide how to implement this request:
a) add a new table with a foreign key UserID which points to the user table and an attribute signature.
b) just add the signature to the existing user table.
Does any of the above possibilities collide with Hibernate? I tend to go with option a)
a) you have to map a many-to-one element. To read a all the user information you (hibernate) would need to join these tables.
b) since all users are in the same table there would be a column "signature" which can not have a not null constraint.
With the information i've seen so far i would go with version b. Needs just one select to get all user informations.
Joined: Apr 12, 2006
Why do you think of a many-to-one-relationship? The signature will be a string, and one user will have one signature.
By the way, I tend to go with option a because the current user table is filled by the external login system only. By introducing a new table for this extra information we would separate table access: Login system modifies USER table, our application modifies ADDITIONAL_INFO table. I do see that the extra table is quite a big bang solution for storing just this additional attribute. I can't name it, but somehow I have the unspecific feeling that this is good. Feel free to call me a fool
Joined: Jun 19, 2001
Mike you are a fool (hey, i'm just doing what you tell me to do :-) )
sorry. one-to-one. But I see your point with the external system. Might be better, yes. At least until you can be absolutely sure that the other application does not get upset if there is suddenly a new column in the table.