codeigniterlogistics

Logistics of Notifications/Messaging in web app


I'm finishing up my first Codeigniter app and I have a question.

Right now I have a message for new users saying something like "Hey there, welcome to the app..."

A row in the db marks when the user has clicked "Don't show me this again".

I would like to have a table called "user-notifications" that will send a notification to the user about special deals or updated info about the app.

How do I keep track of which users have marked "Don't show me this again" if I have many messages?


Solution

  • I would say a simple m-n relation will do the trick

    User                  UserNotification                           Notifications
    --------              -------------------                        -----------------
    id                    user_id                                    id
    foo                   notification_id                            message
    bar                   read                                
    

    Note the read field in the join table. I would use it as a boolean (or whatever type your DBMS has). This way, you know if the user has "clicked the message away" or not. You could also add a date so you could query for messages not older than X.