举个例子,一个blog,支持评论。 是使用嵌套方式存储呢,还是引用方式?
使用嵌套方式查询快,但是假如我要更新一个用户的头像网址怎么办?
如果使用引用方式,查询次数可能会有很多。
请大家指导一下,谢谢~
嵌套:
{ "post": { "id": 0, "content": "content", "comments": [ { "author": "author1", "avator": "http://../a.jpg", "comment": "comment1" } ] }
引用:
{ "post": { "id": 0, "content": "content", }
{ "comment": { "post_id": "0", "author": "author1", "avator": "http://../a.jpg", "comment": "comment1" } }