Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7599273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:37:16+00:00 2026-05-30T22:37:16+00:00

I have the following tables users: uid, name_f, name_l… group_data: id, group_id, admin, invitedusers,

  • 0

I have the following tables

users: uid, name_f, name_l...

group_data: id, group_id, admin, invitedusers, subscribers...

When user, ‘uid:4’ for example creates a group and invites his friends ‘uid:7′ and uid:9’ I insert into the group_data table:

'admin:4, invitedusers:4,7,9, subscribers:4,7,9'. I

If for example uid:9 doesn’t want to receive notifications, I simply remove him/her from the comma-delimited list, subscribers to make it 'subscribers:4,7' I also do the same when an admin removes a user from the group except I alter the invitedusers column.

I understand that this setup is extremely flawed and that I have to create a new table for invitedusers and subscribers. I’m just looking for a way to create that table and also an sql query that selects all users in the new system.

Any help is wonderfully appreciated. Also, this answer somewhat touched on the subject but I don’t quite understand the structure reference and couldn’t implement it: SQL Array Search

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:37:17+00:00Added an answer on May 30, 2026 at 10:37 pm

    You should have one table with one row for each user that exists, like you already do. Call it ‘users’. This table will have only the information about the user, not which groups they are in.

    You should have another table with one row for each group, which you do. Call it ‘groups’. This table will have only the information about the group, not who is in it.

    You should have a third table with one row for each user for each group they’re in. Call it ‘user_groups’ or something. Each row in this table will link one user from the ‘users’ table to one group from the ‘groups’ table, and possibly give information about their subscription to that group.

    A sample setup may look like:

    CREATE TABLE users (
        userID INT,
        firstName VARCHAR,
        lastName VARCHAR,
        PRIMARY KEY (userID)
    );
    
    CREATE TABLE groups (
        groupID INT,
        groupName VARCHAR,
        adminUserID INT,    /* this is the userID of the one and only administrator of this group */
        PRIMARY KEY (groupID)
    );
    
    CREATE TABLE user_groups (
        userID INT,
        groupID INT,
        invited TINYINT,    /* 0 or 1 to indicate true or false */
        subscribed TINYINT  /* 0 or 1 to indicate true or false */
    );
    

    EDIT Answering question from comments:

    $groupID = 1;
    $userIDArray = explode(",", $row["invitedusers"]);    // assuming that $row is a row from the old group_data table
    foreach ($userIDArray as $userID)
        mysql_query("INSERT INTO user_groups (userID, groupID, invited) VALUES ('". mysql_real_escape_string($userID) ."', '". mysql_real_escape_string($groupID) ."', 1)");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two tables: USER FID UID VALUE 4 3 John 3
Let's say I have two SQL tables: QYZ: id, uid<user id, FK*>, somedatacolumn USERS:
I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
I have three tables: Project: ... relations: User: local: authorId foreign: id Users: class:
I have the following tables represented in my Entity Framework diagram (.edmx file) Users
I have the following tables: Users - Users of the site Matchups - Matchups
I have the following tables: USERS table id username email password status FRIENDS table
I Have the following tables Users -> UserId -> Name Roles -> RoleId ->
I have the following tables: users: user_id user_name message: message_id thread_id to_id from_id title
I have three tables: users, events, and user_events, then I do the following in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.