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?
SO considers questions and answers to be the same thing – a
Post. Here’s a stripped down MySQL equivalent table:Tags are stored in a typical type code table:
Associating a tag to a question/post is recorded in the database in a many-to-many table – in SO, it’s called
POSTTAGS:The
POSTTAGStable: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.