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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:45:58+00:00 2026-05-11T12:45:58+00:00

EDIT : To people building tagging systems. Don’t read this. It is not what

  • 0

EDIT: To people building tagging systems. Don’t read this. It is not what you are looking for. I asked this when I wasn’t aware that RDBMS all have their own optimization methods, just use a simple many to many scheme.

I have a posting system that has millions of posts. Each post can have an infinite number of tags associated with it.

Users can create tags which have notes, date created, owner, etc. A tag is almost like a post itself, because people can post notes about the tag.

Each tag association has an owner and date, so we can see who added the tag and when.

My question is how can I implement this? It has to be fast searching posts by tag, or tags by post. Also, users can add tags to posts by typing the name into a field, kind of like the google search bar, it has to fill in the rest of the tag name for you.

I have 3 solutions at the moment, but not sure which is the best, or if there is a better way.

Note that I’m not showing the layout of notes since it will be trivial once I get a proper solution for tags.

Method 1. Linked list

tagId in post points to a linked list in tag_assoc, the application must traverse the list until flink=0

post:           id, content, ownerId, date, tagId, notesId tag_assoc:      id, tagId, ownerId, flink tag:            id, name, notesId 

Method 2. Denormalization

tags is simply a VARCHAR or TEXT field containing a tab delimited array of tagId:ownerId. It cannot be a fixed size.

post:           id, content, ownerId, date, tags, notesId tag:            id, name, notesId 

Method 3. Toxi

(from: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html, also same thing here: Recommended SQL database design for tags or tagging)

post:          id, content, ownerId, date, notesId tag_assoc:     ownerId, tagId, postId tag:           id, name, notesId 

Method 3 raises the question, how fast will it be to iterate through every single row in tag_assoc?

Methods 1 and 2 should be fast for returning tags by post, but for posts by tag, another lookup table must be made.

The last thing I have to worry about is optimizing searching tags by name, I have not worked that out yet.

I made an ASCII diagram here: http://pastebin.com/f1c4e0e53

  • 1 1 Answer
  • 3 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. 2026-05-11T12:45:58+00:00Added an answer on May 11, 2026 at 12:45 pm

    Bill I think I kind of threw you off, the notes are just in another table and there is a separate table with notes posted by different people. Posts have notes and tags, but tags also have notes, which is why tags are UNIQUE.

    Jonathan is right about linked lists, I wont use them at all. I decided to implement the tags in the simplest normalized way that meats my needs:

    DROP TABLE IF EXISTS `tags`; CREATE TABLE IF NOT EXISTS `tags` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `owner` int(10) unsigned NOT NULL,   `date` int(10) unsigned NOT NULL,   `name` varchar(255) NOT NULL,   PRIMARY KEY (`id`),   UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;  DROP TABLE IF EXISTS `posts`; CREATE TABLE IF NOT EXISTS `posts` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `owner` int(10) unsigned NOT NULL,   `date` int(10) unsigned NOT NULL,   `name` varchar(255) NOT NULL,   `content` TEXT NOT NULL,   PRIMARY KEY (`id`) ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;  DROP TABLE IF EXISTS `posts_notes`; CREATE TABLE IF NOT EXISTS `posts_notes` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `owner` int(10) unsigned NOT NULL,   `date` int(10) unsigned NOT NULL,   `postId` int(10) unsigned NOT NULL,   `note` TEXT NOT NULL,   PRIMARY KEY (`id`),   FOREIGN KEY (`postId`) REFERENCES posts(`id`) ON DELETE CASCADE ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;  DROP TABLE IF EXISTS `posts_tags`; CREATE TABLE IF NOT EXISTS `posts_tags` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `owner` int(10) unsigned NOT NULL,   `tagId` int(10) unsigned NOT NULL,   `postId` int(10) unsigned NOT NULL,   PRIMARY KEY (`id`),   FOREIGN KEY (`postId`) REFERENCES posts(`id`) ON DELETE CASCADE,   FOREIGN KEY (`tagId`) REFERENCES tags(`id`) ON DELETE CASCADE ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 

    I’m not sure how fast this will be in the future, but it should be fine for a while as only a couple people use the database.

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

Sidebar

Related Questions

edit Ok People! No need to bring this question to the abysses of SO.
I am building a commenting system where people can comment on uploaded files, messages
I am building a full featured web application. Naturally, you can save when you
I am working on the frontend of a project that gives me Java Expression
I'm currently working on a project that's based on Android. Without getting into many
I have recently started playing around with iOS development and have got most of
I'm struggling with something rather simple in flash at the moment. Imagine you have
i'd like to know how i can make my custom function in tinymce. assumed
I'm programming a network protocol over UDP, using C/C++ in Linux. The protocol must
#include <stdio.h> #include <iostream> using namespace std; int main(void) { bool premiereLignefaite = false;

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.