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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:58:50+00:00 2026-06-13T09:58:50+00:00

I have been able to make 2 ActiveRecord tables, Profile and Bot . I

  • 0

I have been able to make 2 ActiveRecord tables, Profile and Bot. I have been unable to figure out how to link them properly.

There are thousands of Profiles with columns username, gender. A handful of Bots with columns botname, level

When a bot visits a profile two pieces of info need to be recorded. visited and response should be updated for that specific bot. visited is a boolean that will indicate that one particular bot has visited that one particular profile. the response is a string, again like the visited this is a response for one particular bot that was sent by one particular profile. I am thinking I need a 3rd table that joins these two tables.

I need to keep a record of every profile that every bot visits and the response that happens when it visits.

How can I create this relationship and how can I set/update the columns?

Thanks

  • 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-06-13T09:58:51+00:00Added an answer on June 13, 2026 at 9:58 am

    I’m not completely certain of your requirements, so I will restate them:

    1. Table Profile: id, username, gender (note that I changed the table names to singular)
    2. Table Bot: id, botname, level
    3. The “bots” somehow “visit” profiles. You need to track when a bot has visited a profile.
    4. When a bot visits a profile, a “response” string is generated and that response string needs to be preserved. I’m assuming it needs to be preserved with the record of the visit.

    I think your instincts about a join table are good. I don’t think a boolean “visited” column works, however, because if you have a record of a visit, that’s an indication that the profile was visited. If the record doesn’t exist, then it wasn’t visited.

    Given this, I think your tables look like this:

    profile 
    ---------
    profile_id integer autoincrement
    username varchar(255)
    gender ...
    
    bot
    ---------
    bot_id integer autoincrement
    name varchar(255)
    level ...
    
    visit
    ---------
    visit_id integer autoincrement
    bot_id integer
    profile_id integer
    visit_time datetime
    response varchar(255)
    

    To maintain the integrity of your data, you’ll want to set up foreign key constraints between this visit table and your profile and bot tables.

    alter table visit
        add constraint visit_profile_profile_id_fk 
        foreign key (profile_id) 
        references profile (profile_id);
    
    alter table visit
        add constraint visit_bot_bot_id_fk 
        foreign key (bot_id) 
        references profile (bot_id);
    

    You’ll need to decide if it’s “legal” for a given bot to visit a particular profile more than once. If it’s not, you should put a unique constraint on the combination of profile_id and bot_id in the visit table, and catch the duplicate key errors when your DBMS throws them at you (or otherwise handle dupes.)

    I hope that helps.

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

Sidebar

Related Questions

I have been able to make my photos large for single photo posts on
I have not been able to make a html5 button with a span inside
I have been looking at the ruby-docs but have not been able to make
Allright, I have been able to make it work with DataGrid, but for some
I have been able to run my C# .net 3.5 app just fine on
I have been able to find lots of examples of adding a Dropdown list
I have been able to design my layout so that it has 2 columns
I have been able to set up OBDC in Filemaker, and added table ,
I have been trying different things and still have been able to get exactly
Hi I have been able to extract a VARCHAR to a date using string_to_date

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.