groups database

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
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

groups database

Post by pleigh »

hi, i have created so far 3 tables for a groups site (like yahoo grouops) namely userprofile, groupsprofile and groupsmessage...i was thinking how and where i can put additional fields...i'm confused, here's the catch...in a single account, a user might have multiple groups to join, now, i cant figure out how i can make the logic in the database...should i add additional field in the userprofile table??or should i create another table for this...i don't really know much about mysql and logic structure for larger project...i hope u can help me...thanks in advance.. :)
painperdu
Forum Newbie
Posts: 12
Joined: Fri Mar 04, 2005 4:44 am

Post by painperdu »

If you'd like to study up on this problem and solution then look up "Database normalization" over the net.

In short, it looks like you'll need at least 4 tables :

1. User_db -A table to hold unique information about the user.
2. Groups_db -A table to hold unique information about the groups.
3. GroupMembers_db -A table to connect users to groups.
4. Messages_db -A table to relate Messages to Users and Groups.

User_db would then have a unique primary key to indentify each unique row (each user).

Groups_db would have a unique primary key for each row (each group).

GroupMembers_db would would have a unique primary key for each row as well as foreign keys relating back to Groups_db and User_db and connects which users belong to which groups.

Message_db would have a unique primary key for each row (each message) as well as a foreign key relating back to GroupMembers_db.

Get the idea?
Post Reply