JohnRock wrote:
I have two tables that I want to map correctly. A user table, and a user_session table. The User_session table gets populated with one row per user when they log in, and then that row is deleted when they log off.
I was planning on linking the two tables by username (which is unique but not a primary key in either table) but I am confused if this is a real OneToOne relationship. All I originally wanted to do was somehow declare that the user_session.username column was a foreign key of user.username. I am all confused at this point. What is the correct way I should be mapping this?
Thanks
table User
Long id
String username
etc, etc,
table User_Session
long id
String username
String ServerID
Date updated
etc,etc,
Declare username unique in each table, then you will be guaranteed a one-to-one mapping and the set will only have one member.
Dave