[pre-able]
In my www.twipler.com project I want to allow people to link Twitter accounts. This will be achieved by having them login, selecting "link account" and then logging in again. This will effectively give me UserId-1 and UserId-2. Now I want to allow the user to login with either UserId-1 or UserId-2 credentials and then retreive the credentials for the other user. (Feel free to comment, but this is not the question)
[the setup]
C# 3.5, NHibernate, TweetSharp, SQL 2005.
[question]
How do I store an "bag" of unique integers in a database, such that querying one interger will return the other associated ones.
For example, I might create a table called UserLinks and have GroupId which I calculate before inserting a new link. It would look like this
UserLinks GroupId UserId 1 12312784 1 18329139 2 19319332 2 14529342 2 21031023
But this feels a bit ugly and un-NHibernate. (Update: note there can more than 2 accounts)
There's mention below of finding a new GroupId using Max(GroupId)+1, but I realise since the UserId's are unique I can use the first inserted UserId of the group as the GroupId.