Database design for unread messages in mysql?

What would be the best way to check unread messages from the mysql table ...
I have two tables one for users and the other for messages ... In the users table I keep the last registration column and in the messages table a column with date added, but which would be better a way to check if the user has accessed the messages or not ....
I'm thinking of adding another update query to the select query for messages and adding another column (read) to the messages table and setting the read to yes or no ... any other suggestions? thank

+2


source to share


3 answers


Yes, the read column will be the best, logging in (time) does not mean the message has been read. Thus, the best metric is the reading for displaying messages to read.

Edit:



You might want to expand on the idea of ​​"status" to include things like read times, notifications, redirects, and replies.

+3


source


I agree that you should add a column to indicate that the post has been read in the table MESSAGES

. An opportunity to consider would be the data type - if you did it datetime, you would know what it was read and when.



+1


source


I agree with the observer, add a "read" column. I also recommend using tinyint for the "read" column data type (more widely compatible than boolean, but still very small).

0


source







All Articles