1

I'd like to send global notifications to my users (1000+ users) and allow them to close the notification box once they have read the message.

Basically I may send one notification per week globally ie/ each user get the same message and they are not personal in nature.

What is the best way to achieve this?

Create 2 tables:

**tb_messages**
message_id
massage_title
message_content

**tb_read_messages**
user_id
message_id
is-read

That way i can just show each user the current notifications that are not read?

select * from tb_read_messages WHERE user_id = $user_id AND is-read = no

OR is there a more efficient way?

Thanks!!!

2
  • 4
    That's what we do for our 10k+ users and it seems to work out just fine. This will allow you to create global or user specific alerts easily enough. Commented Jan 9, 2011 at 16:37
  • Do you need to know which messages are already read by your users or you just need to track the unread only? Commented Jan 9, 2011 at 16:49

2 Answers 2

2

I think your two table solution (really 3 with a table of user info) is the way to go. You are essentially creating a many to many link between Users and Messages with tb_read_messages, (though I would name this "user_message" or user_message_status as it is a link between a user and message that records the current status).

The only other though I would through in is to consider groups of users so that you can easily target specific groups of users

Users}-User_Groups-{Group_message_status}-Messages

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

Comments

0

Your solution seems fine. What you can further consider is that your
tb_read_messages table may bubble up quite a lot. You may think of some maintenance for it. Perhaps you can do that by archiving the messages already read in a separate table or just dropping them if you do not need keeping such history. Further you may want to get rid of messages queued for inactive users (you may do that with a timestamp attached to the message).

This are just general ideas which may be improved in the context of your actual product.

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.