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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
silverme
Forum Newbie
Posts: 13
Joined: Tue Sep 27, 2005 4:24 pm

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

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
Post Reply