Structure for a php/sql forum built from scratch?

[COLOR=#000000][FONT=verdana]I have to build a forum from scratch with php as the server side, and was wondering how I should set up my tables.

[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]Once logged in, I need categories which contain topics which contain threads/messages.
So, Categories --> Topics --> Thread[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]
I was thinking of have one table for all the categories, one table for all the topics, and one table for all the messages.

Then in each category it would show the appropriate topics only by iterating the entire table and searching for a ‘categoryID’, and the same would go for being in a topic and that topic searching for a ‘topicID’ over every message.

Would this waste a lot of time and resources? Would it be better for the creation of each topic to also create a new table that holds all of its messages?
[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]
[/FONT][/COLOR]