Reputation: 6029
I apologize if this is not a suitable place for such question but I have exhausted Google trying to find out the correct design pattern for a particular table I have to design in my database. Let me paint the picture for you I have one table called Activities which has the following this is just a snap shop in total it has 102 entries
The user when signing up has the option to select as many of the activities he or she participates in, the issue I'm trying to crack is how to design such a table that stores this information in, I could go and create a table which has 102 columns which would look like the following again this is a snapshot
From what I know about SQL it's frowned upon having such large tables i.e X amount of columns I personally do not want to create a table which is 102 columns long due to the fact as time progresses more activities may be added which would result in this particular table growing even more and to a point where it would be hard to work with, I am only interested in storing the activities the user has selected in to the database.
So I'm seeking some SQL Guru's opinions on the matter, I have heard of the Meta model design pattern in SQL (not sure if that's the correct name for it). I tried Googling for an example but it turned out zero results which gave me the impression the pattern is not called that.
I'd appreciated all the feedback given.
Upvotes: 0
Views: 486
Reputation: 26
Go with relationship
3 tables
-users (user_id,....)
-activities(activity_id, activity_name,...)
-UserActivities(user_id, Activity_id)
Upvotes: 1