php - insert reference in comment table that joins two sessions (blog and news)

807

I am finalizing a comments system and was with a doubt.

I have a table for blogs and one for news, and they accept comments.

My comments table receives the text and the id. I wonder if I need to (or should I) go through some sort of reference to know where the comment comes from.

table comment

id | id_content | text | ref
1  | 1          | test | blog
2  | 1          | test | news

thanks

337

Answer

Solution:

depending on the number of comments you expect to receive there are two ways of doing this ...

1 - parent_tbl, parent_id - in one big comment table

2 - two tables for comments with a parent_id - one for each primary table

either way you need to index properly, the second will always work faster, but it doesn't expand well if you say add "press_releases" now you have to duplicate code, tables, what not.

People are also looking for solutions to the problem: apache - Provide edit access to php files in server to users acrss sites

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.