Answer the question
In order to leave comments, you need to log in
Implementation of site functionality. How to do it right?
Greetings to all.
I was now wondering how to "correctly" implement the functions of the site.
To make it clearer, I’ll give an example of their life, (Something I can’t formulate a thought)
Once, when I was just learning PHP, I wrote mini blogs and it was necessary to implement “notifications” that someone said they answered in a record.
I just created an actions table with the following fields:
id - record ID
user - to whom the notification
message - just HTML markup that I output later :D
An example of this "message":
<strong>UserName</strong> оставил вам сообщение в записи <a href="/post/show/PostId">PostName</a>
Answer the question
In order to leave comments, you need to log in
Keeping html seems to me to be definitely not the best idea.
I would formulate all possible types of notifications, whether they are supposed to be searched, and depending on how different they are, I already thought. There can be a sea of options:
1) if notifications are of the same type - fields in the database (conditionally event_type, date, user_id, post_id, etc.)
2) if notifications are partially of the same type - some of the fields in the common database (event_type, user_id, date), and part
2.1) in in the form of a json object in line
2.2) as a separate table for each event_type with additional fields
3) some denormalized options.
We once made another Instagram clone, there were a lot of notifications - we stored the events themselves in sql, and in redis we stored for each user id a list of notification id that he should see.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question