Click to See Complete Forum and Search --> : Newb question:Storing user profiles


jbu311
12-25-2006, 12:10 AM
Hey everyone,

If I had to keep track of users, where every user a user description and a list of interests, how would I go about do that?

I would guess the best/easiest thing to do would be to use PHP/mySQL and have an entry for each user in the database, and have a text field for description. But for the list of interests, how would I keep track of all the elements in the user's list - what if the user can have anywhere between 1-100000 elements in the list? I can't create a field that has an infinite amount of space. What would be the best thing to do?

Thanks for any help in advance.

jbu

ray326
12-25-2006, 11:24 PM
You put the interests into a separate table, keyed to the basic user info in the user table. Whenever you have a one-to-many relationship like that it indicates a separate table to hold the "many".

jbu311
12-25-2006, 11:41 PM
1 separate table per user?

chazzy
12-25-2006, 11:56 PM
you should have 1 table that houses all of the interest-user pairs. this table could have as few as 2 columns - userid and interestid. these should map to appropriate users and interests.

do not create new tables for each user - that will become a management nightmare.

ray326
12-26-2006, 06:19 PM
1 separate table per user?No, one table for users and one for user interests. The latter has one row per user per interest. There could be a third table for interest descriptions depending on the definition of "an interest."