I've read several tutorials, documentations about mysql, db structures and also I'm using it via php for weeks. Now I get a problem, I don't know how to form/organize/create my db structure for posts and comments. I've already read some posts about this (here on stackoverflow), but I didn't find anything useful. I understand that I need to have 2 tables for posts and comments, and when I need to print them on the page with a foreign key (or ID) I "merge" them (only on the page, not with SQL). When a person is viewing the page, he is seeing the post and comments normally, but in the "background" everything is stored in 2 tables.
Am I needing to add a new column every time when somebody is adding a new comment or a reply?
If my question is true, that means if in a post are 100+ comments, that means I need to ALTER the TABLE every single time? That means if post "A" has 3 comments and post "B" has 150 comments, my table "comments" will have 100+ columns?
E.g:
Posts | column1 | column2 | ... | columnN
A | bla1 | bla2 | bla3 | - empty | - empty | ... | - empty - |
B | bla1 | bal2 | bla3 | bla4 | bla5 | bla6 | ... | bla100 |
POSTS(id,title,text);COMMENTS(id,postid,text);. Each post has a row inPOSTS, each comment has a row inCOMMENTS. You know which comments are for which posts by the use ofcomments.postidwhich matches theposts.idof the post. - Rudu