我在Mongo数据库集合中有数据,其中每个文档都有父文档的id。如果我想搜索所有有特定文档的文档(我将其称为P) (即P是它的父母、祖父母、曾祖父等),那么我有哪些有效的选择,这些选项的优缺点是什么?
我可以想到以下几点:
将整个祖先存储在每个文档中,以便搜索包含P. 的“谁的祖先”列表
优势:
定时间查找
- Weaknesses:
- If a parent is changed, the corresponding update is O(n), where n is the number of descendants of the doc
我是node.js的新手。
并使用Express框架和cassandra作为数据库。
我的问题是,在多个表关系(如join )中使用mysql是可能的。
例如,
在mysql中
select * from `table1`
left join `table2` on table1.id=table2.id