开发者

Wikipedia style article, how should I design my database?

I need to make article that cannot be edited, but it can be saved as a new version and only the newest version is shown to users. How should I implement this kind of开发者_开发技巧 database design?


The database can have a version number or timestamp on each version of the article, and you just serve up the most recent article (highest version number or most recent timestamp).

For best results, use a reverse proxy cache to avoid touching the database on every hit.


There are a couple of ways to handle this. I think the most straight forward way is to have a table, "article", with whatever data is set in stone when the article is created (id for example) and a second table with each edited version, "articleVersion". article would have a one to many relationship with articleVersion.

You could set a bit, "currentVersion", and toggle it off on old version and on for the new version. You could also just use a datetime, "dateCreated", to get the newest version since you never plan on editing them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜