Search code examples
mysqldatabase-designschemadatabase-schemadb-schema

Users group table schema


I am creating a system where users can join and create groups. Within these groups, members can create topics and respond to topics already created, so I'd like to know your opinion on which of the following methods is best: Create two tables, groups_posts and group_topics:

--group_topics
id PK
group_id int FK
user_id int FK
title varchar(50)
content varchar(500)
status int

--group_posts
id PK
topic_id int FK
user_id int FK
content varchar(500)
status int

or create a unique table, group_tposts:

--group_tposts
id PK
group_id int FK
user_id int FK
is_topic boolean
title varchar(50)
content varchar(500)
status int

Solution

  • Based on your description, seems to me that a bit more may be needed. Maybe something something like:

    • One group can have many users.
    • One user can belong to many groups.
    • Within a group users create topics (topic = subject; theme; a category or general area of interest.)
    • Within a topic users create new posts or reply to previous posts.

    enter image description here

    Note: add the content field to the Post.