D
Daisy
Let's say I've got a forum, where users can be moderators of each forum.
Tables look like this:
USER
--------
user_key
name
FORUM
---------
forum_key
name
USERFORUM
----------
userforum_key
user_fkey
forum_fkey
(I'm sure you can work out where the relationships are!)
My user, "Danny" is a moderator in "Forum1" and "Forum2".
I've just logged in as Danny, and my User.Authenticate() method should go to
the database, check the details, and return all the info to populat the User
object with as little effort as possible (ie. 1 query if possible).
Most of the user object is just string variables, but there's also gotta be
a list of forums I can moderate. I'm open to suggestions of how this should
actually be stored (like an int[] of the keys, should be fine).
My question, is this... How is the "best" way to pull back these forum_keys
that I'm allowed to moderate? If I join to the table, I also pull back my
user details once for every forum (twice, in this case). This seems a bit
messy.
Stored procedures don't seem to be capable of returning more than a flat
table. How would you achieve what I'm trying?
Many thanks,
Danny
Tables look like this:
USER
--------
user_key
name
FORUM
---------
forum_key
name
USERFORUM
----------
userforum_key
user_fkey
forum_fkey
(I'm sure you can work out where the relationships are!)
My user, "Danny" is a moderator in "Forum1" and "Forum2".
I've just logged in as Danny, and my User.Authenticate() method should go to
the database, check the details, and return all the info to populat the User
object with as little effort as possible (ie. 1 query if possible).
Most of the user object is just string variables, but there's also gotta be
a list of forums I can moderate. I'm open to suggestions of how this should
actually be stored (like an int[] of the keys, should be fine).
My question, is this... How is the "best" way to pull back these forum_keys
that I'm allowed to moderate? If I join to the table, I also pull back my
user details once for every forum (twice, in this case). This seems a bit
messy.
Stored procedures don't seem to be capable of returning more than a flat
table. How would you achieve what I'm trying?
Many thanks,
Danny