How to implement a one-time (per user) message in a web application?

When you want to warn the user about something once (at one time he notes about new features, upcoming events, special offers, etc.), what is the best way to do this?

I mainly deal with the presentation of data, but if there are more problems, please consider providing them. This is my first approach to this particular problem.

So my thoughts are still ...

You can have users, messages and a table of noticed / confirmed messages. When the user confirms the messages, we have a new record in the seen table with the user ID and a pair of message identifiers.

However, the table seen will grow rapidly with the number of users and messages. At some point it will become cumbersome (any understanding when it will be for one mysql db on one server?).

Would it be better to just create 1 table seen per message and maybe end up with 20-30 such additional tables to get started? No problem. This is simply due to the additional nuisance of having to create a new table every time a new message appears (of course, this would be automated in the code - a bit more coding).

This is for a project in which there are 2-3K current users, but hopes to grow to 10K over the next year, and, of course, we also look beyond this ...

Edit: , . , , . , . , . , - .

, , , . . , , . , .

, - , ? , ? CMS: , Joomla Wordpress. , . , " ". , , ?

, : . , , .

, , - - , .

: , , , , timestamp. !

+3
5

aproach:

CREATE TABLE IF NOT EXISTS `system_user_messages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `section` enum('home','account','all') NOT NULL DEFAULT 'home',
  `message` varchar(250) NOT NULL,
  `message_type` varchar(25) NOT NULL,
  `show` tinyint(4) NOT NULL DEFAULT '1',
  `allow_dismiss` tinyint(4) NOT NULL DEFAULT '1',
  `created_on` datetime NOT NULL,
  `dismissed_on` datetime DEFAULT NULL,
  `show_order` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx-user_id` (`user_id`),
  KEY `idx-section` (`section`),
  KEY `message_type` (`message_type`)
);

allow_dismiss, . , CC , , , CC. , .

sql, , ... , , , , , .

+2

, , . X , , . . :

messages
--------
type            PRIMARY KEY
text            TEXT

unseenMessages
--------------
id              PRIMARY KEY
messageType     FOREIGN KEY
user            FOREIGN KEY
expirationDate  DATE

unseenMessages , . , , - . , , . "".

, , . * . -.

* , .

, , . , . " ". . . , , .

eval(): , . , , eval() . .

+8

. , Twitter MySQL SQL Server Oracle 100 .

  • cookie , ,

  • - , ( HTML ?), /.

    - , , . .

    , , . , , .

, , "User Messages" User/Account . User Message (, , ..)

, , . , . - .

+5

, , / . , .

.

. - ( , mysql db ?).

, , , , . , ( it!), .

, . (100 000 000 +) .

(1 ) , , /.

.

: .:)

+1

? - ", ", , , ? (, , ?) - , . , . , , ? ( ), , , cookie, , , . .

0
source

Source: https://habr.com/ru/post/1711707/


All Articles