I'm building a search function in php for a database with 1k to 4k articles. It's going to be built on a tag system. I've been reading some tutorials, blog posts, q&a etc about it.
Most important for me is performance, I want it to be fast and light. In my special case I'm only going to have a set of few fixed tags. Example: Color:blue, Size:large etc. So if user filters/search "Large Blue" only the articles with these tags should show. There's going to be "Ajaxed" queries, so a light and fast query is important.
I can think of three ways of doing this:
Option 1:
Articles table
- id
- name
- tags (with a data string of tags comma separated)
- etc
Option 2.
Articles table
- id
- name
- etc
Tags table
- id
- name
- article ids (with a data string of article ids comma separated)
Option 3.
Articles table
- id
- name
- etc
Relational Tag Arts table
- Fkey tags id
- Fkey article id
Tags table
- id
- name
- etc
Which one of these would be fastest / best performance. I know it's not good practice to use comma separated data strings in a table field. But for me, since I just have a few set of tags, option 1 or 2 looks simple and faster than option 3?
Any other suggestions is of course welcome! Thanks