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 6896701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:04:37+00:00 2026-05-27T07:04:37+00:00

I have a table called users , and one of the rows needs to

  • 0

I have a table called users, and one of the rows needs to hold all the actions the user did, and the actions are referenced as action_ids.

How do I have the row hold multiple action_ids?

For example, lets say the user did 5 actions, each with IDs 100001, 100002, 100003, 100004, 100005. How do I store that into the database so I can later say all the actions a user did?

The row might have to store hundreds or thousands of 6 digit values.

  • 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-27T07:04:38+00:00Added an answer on May 27, 2026 at 7:04 am

    I would recommend you create a UserAction table with a UserId and ActionId. This way you could reference the actions done without having to store multiple values in one row of your users table.

    You would store rows for each action a user takes. The table might look like this:

    SELECT ua.UserId, ua.ActionId
    FROM UserAction AS ua
    ORDER BY ua.UserId ASC, ua.ActionId ASC
    LIMIT 5
    

    Results:

    1, 100001
    1, 100002
    1, 100007
    2, 100002
    2, 100003
    

    Meaning that UserId = 1 performed actions 100001, 100002 and 100007 and UserId 2 performed 100002 and 100003

    Doing this also helps preserve normalization for your database, making future queries easier as well.

    You will be able to find how many actions have been performed by users easier (and other tasks) with this structure than parsing a column with text/string values: (I’m assuming you have a Name, or similar field)

    SELECT u.Name, COUNT(1) AS NumberOfActionsPerformed
    FROM users AS u
    INNER JOIN UserAction AS ua ON u.userId = ua.UserId
    GROUP BY u.userId, u.Name 
    ORDER BY NumberOfActionsPerformed DESC
    

    Also, if I were making the table, I would add UserActionId as an Auto-incremental Id column to use as my Primary Key

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called users and each user can belong to one group,
I have a table called Users ( class User < ActiveRecord::Base ) and a
I have a table with several million rows. Each row represents a user session
I have a database table called user where I have some columns. One of
I have a table called UserPermissions with a FK to the users table by
I have a data table. Each row of the table has a commandButton called
I have two tables, one called Users and one called Groups . I also
So, I have a database (With a table called users) that let's users connect
I have a table called Shoppings in my SQL db. This one has a
I have a very typical situation. We have a table called Users which has

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.