S
S
Soft_touch_plastic2020-07-28 08:20:17
Database design
Soft_touch_plastic, 2020-07-28 08:20:17

What is the best way to build your own forum?

You need to write forum code. Every post on the forum has comments, comments have answers to comments. I want to store all messages in the database. There will be three tables, users users, post forum posts, comments comments. Each post will have an author field, date of writing and a unique number. The comments table will have a parent field, a unique number of the post to which the comment is written, and a field with a unique comment number so that answers can be written to it. When a person loads a page with a post, the post is loaded, then comments are searched for by its unique number and loaded, followed by their comments, etc.
Is this approach correct for a small narrowly focused forum?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-07-28
@Soft_touch_plastic

The first question that needs to be decided before the stage of writing the code is whether the forum will look like a tree or a linear one.
While it looks like you are describing a tree. But we must understand that they are almost never found in nature. Known only for Reddit.
And in any case, the way you are going to upload is very inefficient. There can be thousands of replies in one thread (post) and since you're going to upload (and their comments, etc. behind them), it will be very inefficient.
In general, I recommend making it linear when there is a post and comments to it.
To make it clear to which remark the answer is written, you can make a citation.
Well, the last.
If you want to learn how to program, then of course write.
But if your goal is to get a forum on the site, then of course you need to take it ready.

D
Dr. Bacon, 2020-07-28
@bacon

Another approach is to store as a "document" in MongoDB or similar.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question