Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在做一个聊天项目,但我发现这个问题我无法解决。
假设我是一个名为“Randy”的用户,并且我访问过foo1 , foo2, bar4, Teenagers,... count to 30房间。现在我想跟踪最后 20 个房间。
foo1 , foo2, bar4, Teenagers,... count to 30
我在想我可以创建一个表来保存这种记录,并在一段时间后运行一个 cron 来只保留最后 2 个活动,或者我可以在用户表中创建一行,我将存储最后 20 条记录,格式如下房间1,房间2
我的问题是哪一个更适合存储这种记录?或者有没有其他方法可以更有效地解决这个问题?
有一个访问表,其中包含FK对user表 ( user_id) 、room表 ( room_id) 和的引用timestamp。
FK
user
user_id
room
room_id
timestamp
当然,一旦每行超过 30 行,您就可以清理数据user_id