0

I want know what solution is more efficient (or know another better solution of course). If I have a website where any user can leave a comment for each post, what will be the better solution?

Serialize an array with all comments for that post in a column of database (I don't know if it is possible that two users leaving a comment at the same time can lead to data loss)

Or maybe is better the following:

Creating a specific table called comments, where I have an unique id for each post and other unique id for each username

I read that some people don't like use the serialize function, but I don't know if it is a good idea or not their use

5
  • Create a table. It's better scalable and maintainable than using a serialized array. Commented Jan 27, 2016 at 17:06
  • Ok, thanks for your reply @CharlotteDunois Do you think that the efficiency of the database is maintained with two ids for each row? Or can I do another thing to improve the efficiency? Commented Jan 27, 2016 at 17:11
  • Specific table with unique ids is always the better way. Commented Jan 27, 2016 at 17:11
  • Tables are the better route. Serializing is best when there are large amounts of data for a single record and when you're not asking for the data constantly. Commented Jan 27, 2016 at 17:11
  • Okay, perfect. Thanks for your comments Commented Jan 27, 2016 at 17:18

1 Answer 1

1

Table. Comments table with relation to your Posts And no alternatives for it. Create, update, delete actions for specific comment and search at all becomes painful using serialization into single field.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.