Category Navigation
Today, I restructured my SQL database a bit to better handle the displaying of posts based on their categories. Initially, I had a column in the Post table called "category" that was collecting the category (or categories) that I entered in when making a new post. I realized that it would be better to keep each category on a particular post in a separate row in the table - this way I wouldn't need to split the category cell by comma or space in order to add multiple categories to each post.
There is now a new table in my database specifically for categories, with a column that relates that particular category instance to a specific post. It took me a bit of research to figure out how to do an inner join with a filter in order to first query from the 'categories' table based on a particular category, and then reference that category instance with a specific post, but I was able to solve it with a little help from a programming Discord I am in.
I ended up deciding to add a small sidebar on the /blog page of my website with a drop-down containing a unique list of all of the categories, that when clicked brings you to a page with posts tagged with that particular category, and I'm pretty happy with it so far.
0 Comments