Page 1 of 1

How do people usually manage this kind of data in MySQL?

Posted: Tue Oct 18, 2005 3:32 am
by silverme
For example, this forum. The forum has this division "Databases".

How do people usually store the names of moderators in this division? Because the number of moderators could vary. It could be only 1 moderator, 3 moderators, or more. So in the database, when admin adds a moderator, does the database actually use a separate table to store all information about moderators, or just reserves a few rooms for recording names of moderators in the table with forum division information (It is like the Databases division can have a maximum of 5 moderators)? Or some other methods?

Thank you

Posted: Tue Oct 18, 2005 4:50 am
by timvw
Well, during analysis you will discover that a forum can have multiple moderators and a moderator can work in multiple forums.
This is a n - m relationship. In a relational design this kind relationships are split into two 1 - n relationships.

So you start with [forum] n - m [moderator]
and end up with [forum] 1 - n [forum_moderator] n - 1 [moderator]

Now you can have _any_ number of forums, moderators, forummoderators...

table forum (forum_id, name, description, ...)
table moderator (moderator_id, name, password, ...)
table forum_moderator (forum_id, moderator_id)