Database - How should a limited-time history table be designed?
ringa_lee
ringa_lee 2017-05-31 10:36:04
0
2
1078

The database is MongoDB.

Suppose there is a data table (data collection-collection) --- Users.

Every time a user (User) updates his or her data, a copy of historical data needs to be retained, but not too much. For example, only the latest 5 copies can be saved at most.

If you design a table UserHistory to store old data, you need to check whether there are more than 5 records each time you save new records. If so, delete the oldest one.

Is this reasonable?

Is there a more reasonable design?

ringa_lee
ringa_lee

ringa_lee

reply all(2)
大家讲道理

https://docs.mongodb.com/v3.0...
Can this document answer your questions?

phpcn_u1582

Traditionally use triggers + stored procedures.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template