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

  • Home
  • SEARCH
  • 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 7500547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:13:23+00:00 2026-05-29T20:13:23+00:00

I want to make a Keywords table that stores words in a string (from

  • 0

I want to make a Keywords table that stores words in a string (from a phrase with spaces) and if the user enters a phrase it adds a reference to the keyword id in a phrases table.

I think the tables should look like this:

Keyword:

ID | Word
-----------
1, a
2, keyword
3, phrase

Domain:

ID | Name
-----------
1, findme.org

Phrase:

Phrase_ID | Keyword_ID | Domain_ID | Word_Weight
-----------
1, 1, 1, 0
1, 2, 1, 1
1, 3, 1, 2

Is there a way that I can do this in rails possibly with a has_many relationship so that I could get a phrase by passing @domain.phrases returning a list of all of the phrases with the same Domain_ID, and @keyword.phrases lists all of the phrases that contain a keyword with Keyword_ID

My goal is to avoid duplicate rows in any of the tables, is this convoluted? Could you suggest a better design that is the rails way of doing things?

  • 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-29T20:13:27+00:00Added an answer on May 29, 2026 at 8:13 pm

    What your describing is very similar to the concept of tags, and so you can use any of the tagging libraries already available, and/or study their structure for a solid solution.

    For example, here is the migration for the acts_as_taggable_on gem, which will give you an idea of how other people have done this, including the models (and relationships between models) in the code.

    These tools provide, with very little code, the ability to add @domain.tags to any record. Some of the libraries also let you define what you want to call the tags – so if you want to call them keywords, you can do that, and have calls like @domain.keywords or @domain.phrases, etc., like in your example.

    Also, if the ultimate goal of this is to add keywords in order to aid in searching, there are great search libraries and tools that enable full text search (where text, titles, etc. are automatically indexed for keywords) without needing to explicitly define keywords.

    Really depends on where you want to go, but those are a couple of directions for you.

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

Sidebar

Related Questions

I want to make a table in SqlServer that will add, on insert, a
I have a dictionary of keywords that I want to make available for autocomplete/suggestion
I want to make an etag that matches what Apache produces. How does apache
I want to make an entity that has an autogenerated primary key, but also
The table's schema is pretty simple. I have a child table that stores a
following on from my other post... I have a table that uses two fields
i have a problem. i have table. and i want to make td in
I have data that I want to pull from a mySQL database and I
I'm creating a table with two columns that I want to auto-increment. One column
I'm trying to create script, that will import keywords from images to database. Keywords

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.