保存通知和帖子的最佳方法 [英] Best approach to save notification and posts

查看:106
本文介绍了保存通知和帖子的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am developing a notification and post system. I have done a database design where there are user ids for who is sending notification, to whom its being sent and notification text field.
Now my question is, should I save the notification with html format what I'll show in front end, like user name, user image etc or just save the raw data and make a join query with users table while fetching the notification.

What is the best structure?

And in facebook we can see post title like "ABC has shared BCD's post". And link on ABC and BCD. So do facebook save the full format in table or format it while fetching the data?

Can you please help me with the good approach please.





我尝试过:



我设计了如上所述的数据库。



What I have tried:

I designed the database as stated above.

推荐答案

你应该存储原始数据库数据,例如发件人和收件人的ID以及他们想要发送的邮件。它使得处理数据变得更加容易,并且意味着您可以在数据库中存储更少的冗余数据;例如,您没有存储from和to名称,只需在显示消息时检索它们。这也意味着如果用户更改了他们的名字,那么他们在查看消息时始终会显示正确的名称。
You should store the raw data such as the ids of the sender and recipient and also the message they want to send. It makes it easier to work with the data and will mean you store less redundant data in your database; you're not storing the "from" and "to" names for example, you just retrieve those when you show the message. It also means that if a user changes their name then when they view the message the correct name is always shown.


这篇关于保存通知和帖子的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆