How do you track record relations in NoSQL?

后端 未结 5 2033
鱼传尺愫
鱼传尺愫 2020-12-04 05:28

I am trying to figure out the equivalent of foreign keys and indexes in NoSQL KVP or Document databases. Since there are no pivotal tables (to add keys marking a relation be

5条回答
  •  眼角桃花
    2020-12-04 06:17

    1. user:userid:comments is a reasonable approach - think of it as the equivalent of a column index in SQL, with the added requirement that you cannot query on unindexed columns.

    2. This is where you need to think about your requirements. A list with 30 million items is not unreasonable because it is slow, but because it is impractical to ever do anything with it. If your real requirement is to display some recent comments you are better off keeping a very short list that gets updated whenever a comment is added - remember that NoSQL has no normalization requirement. Race conditions are an issue with lists in a basic key value store but generally either your platform supports lists properly, you can do something with locks, or you don't actually care about failed updates.

    3. Same as for user comments - create an index keyword:posts

    4. More of the same - probably a list of clubs as a property of student and an index on that field to get all members of a club

提交回复
热议问题