ASP. net and SQL question

Posted by Nerdanalysis under ASP.NET on 12/17/2012 | Points: 10 | Views : 832 | Status : [Member] | Replies : 3
Hi,

I am working on a project where a user can select multiple categories of interest, while they will create their profile. How should i do that?
Should i make 3 tables eg. one for user_details(User id, username), a table with list of categories(categoryID and category name) and a bridge table(user id and category id)?

Or

Should i make 2 tables eg. one for user_details(User id, username and a table with list of categoryies(Userid, cat1, cat2, cat3, cat4........., cat25), here userid will be the candidate key, and all the selected categories will be true or false.

Please let me know which is better approach and Why?

Kind regards
Nerd




Responses

Posted by: Ankitsrist on: 12/18/2012 [Member] Starter | Points: 25

Up
0
Down
hello,
simply make two tables 1st user_details and 2nd categories....and in user_details table assign User id as a primary key and assign User id as foreign key for categories table...no need to make bridge table....have u learned abut RDBMS this is how u can achieve that

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/18/2012 [Member] Starter | Points: 25

Up
0
Down
2nd table now have 3 columns categories(categoryID and category name, User id).....
mark this if it helps u

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nerdanalysis on: 12/18/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Ankit thanks for reply.....I think this second table is called bridge/junction table that has categoryid, name and userid.....There are 25 categories and suppose there are 1,000,000 users than in the category table there should be 25,000,000 records, which will slow down the performance.

Anyway we need the category table to display the category names and take the reference to the bridge table.

Thanks

Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response