开发者

Document Database - Many-to-many

开发者 https://www.devze.com 2023-02-18 04:04 出处:网络
Lets say we mimic the behaviour of a many-to-many relationship between Users and UserGroups, and we\'re storing the ID\'s of which UserGroups a User is in, in the User document within开发者_如何学C an

Lets say we mimic the behaviour of a many-to-many relationship between Users and UserGroups, and we're storing the ID's of which UserGroups a User is in, in the User document within开发者_如何学C an array. Now when i delete a UserGroup then the ID of that UserGroup will still be in the Array in the User document - does it affect the perfomance at any point, that it's holding some old and useless values in the array?


It certainly wouldn't affect the performance in any way, since it's just data lying there.

If it would be included in an Map/Reduce index that depends on that the relationship is fulfilled, maybe that could cause an effect. But on the other hand, if that would be the case, you would get instant feedback on that since the index would be marked as faulty.

Out of curiosity, how do you store the related IDs? Do you store them as a complete key or just the key, if you know what I mean? I've seen Ayende use the complete key approach, but I don't know which approach is the best.


I've come to the conclusion that a Document-oriented database isnt made for relationships. I've instead decided to use a object-oriented database instead (db4o).

0

精彩评论

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

关注公众号