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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:18:13+00:00 2026-05-17T15:18:13+00:00

I’m adding tags to several models (Posts, Articles, Photos, etc). I’m aware of rails

  • 0

I’m adding tags to several models (Posts, Articles, Photos, etc). I’m aware of rails tagging plugins but prefer not to use them, as they don’t quite meet my specific needs.

I know the typical way of implementing polymorphic tagging support is to use 2 tables Tags, Taggings and setup the appropriate has_many :through relationships.

But, as I think about it a bit more – and here is my question: Is there a need for a Tags table. Are there any disadvantages of using just a Taggings table and have my relationships like this:

Post, Article, Photo
has_many :taggings

Taggings (attributes)
taggable_type
taggable_id
tag_name

Then I would just need to manage inserting/deleting taggings myself. Basically, I’d like to just store the tag_name attribute directly in the Taggings table instead of a Tags table.

The advantages are that eliminate managing a table, no joins to get the tag names (although I’ll be doing a lot of SELECT DISTINCTs).

Could you let me know your thoughts on this design?

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-05-17T15:18:13+00:00Added an answer on May 17, 2026 at 3:18 pm

    Those SELECT DISTINCTs are going to be one disadvantage. You’re going to find it slow to build a list of tags, not just in the case of building an index to link (which you could work around by fragment caching, I suppose) but also for auto-complete.

    I’d say the more significant disadvantage is that if you’re using an in-application search solution (e.g. Xapian) you’ll either need to index the Taggings table, which is likely to create some odd results, or not index tags at all, which might defeat the point of tags, depending on how you’re using them.

    None of which is to say you absolutely shouldn’t do this, of course; skipping the extra join is going to make some things a lot faster. It’s smart of you to look at the cost and decide if it’s worth it.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.