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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:53:13+00:00 2026-05-16T10:53:13+00:00

OK so now I can understand that SO’s search system is primarily based around

  • 0

OK so now I can understand that SO’s search system is primarily based around tags, the tag system they use is a very good one at that but what I want to do is replicate it for my own projects.

Now I can understand how to use foreign keys and such, but I’m not exactly sure how it’s been developed here, do they use 3 tables or 2 etc.

How have they developed it, can you show me some MySql examples?

  • 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-16T10:53:13+00:00Added an answer on May 16, 2026 at 10:53 am

    SO considers questions and answers to be the same thing – a Post. Here’s a stripped down MySQL equivalent table:

    DROP TABLE IF EXISTS `example`.`post`;
    CREATE TABLE  `example`.`post` (
      `postid` int(10) unsigned NOT NULL auto_increment,
      PRIMARY KEY  (`postid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    Tags are stored in a typical type code table:

    DROP TABLE IF EXISTS `example`.`tags`;
    CREATE TABLE  `example`.`tags` (
      `tagid` int(10) unsigned NOT NULL auto_increment,
      `tagname` VARCHAR(45) NOT NULL,
      PRIMARY KEY  (`tagid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    Associating a tag to a question/post is recorded in the database in a many-to-many table – in SO, it’s called POSTTAGS:

    DROP TABLE IF EXISTS `example`.`posttags`;
    CREATE TABLE  `example`.`posttags` (
      `postid` int(10) unsigned NOT NULL auto_increment,
      `tagid` int(10) unsigned NOT NULL default '0',
      PRIMARY KEY  (`postid`,`tagid`),
      KEY `fk_tag` (`tagid`),
      CONSTRAINT `fk_post` FOREIGN KEY (`postid`) REFERENCES `post` (`postid`),
      CONSTRAINT `fk_tag` FOREIGN KEY (`tagid`) REFERENCES `tags` (`tagid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    The POSTTAGS table:

    • is only two columns, and those columns are the primary key – this makes sure there can’t be duplicates, and that either side (post or tag) can never be NULL.
    • The foreign key requires that the data stored in the table must already exist in the respective foreign table…

    If you ever want to look at the SO schema, check out the Stack Data Explorer – when you compose a query, the SO schema is available on the righthand side.

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

Sidebar

Related Questions

I understand that you can now create MVC-specific user controls, but will my existing
I understand that I can make the property nullable or use a bool called
I understand that within same folder, I can use include() function for external PHP
Right now I can use this URL to request a Google Static Maps image
Found more than 10 tutorials to cursors but I can't understand that. My question
I have refactored working code to use proper objects and now I can't get
There is component within the application that uses com.sun.java.swing.SwingUtilities2 Now I understand that this
I understand that a user can own a process and each process has an
I have a DataGrid . I have DataGridDragDropTarget from November Toolkit. I now can
Now I can add single value or tubles to the pipeline, my next question

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.