gpt4 book ai didi

database - Azure Cosmos Document DB,可能有关系链接吗?

转载 作者:行者123 更新时间:2023-12-02 08:03:16 26 4
gpt4 key购买 nike

我有一个遵循以下粗略 json 结构的文档数据库:

{
id: 32,
Name: 'John',
Occupation:{
name: 'Programmer',
hours: 40
}
}

是否有办法拥有一个单独的文档集合或与职业相关的类似内容?如:

{
id: 32,
Name: 'John',
Occupation: 'jobs/JOB_PROGRAMMER_ID'
}

// jobs document collection
{
id: 'JOB_PROGRAMMER_ID',
name: 'Programmer',
hours: 40
}

我可以编写一个后端查询函数,它将自动解析这些关系,但想知道是否有内置的方法可以做到这一点。

最佳答案

可以使用 Cosmosdb 来实现。唯一的问题是,如果没有多个集合,您需要嵌入到一个集合中,如下所述。

Relational databases are not the only place where you can create relationships between entities. In a document database you can have information in one document that actually relates to data in other documents. Now, I am not advocating for even one minute that we build systems that would be better suited to a relational database in Azure Cosmos DB, or any other document database, but simple relationships are fine and can be very useful.

<强> Embedding documents

关于database - Azure Cosmos Document DB,可能有关系链接吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50539046/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com