我有一个想要转换为 NoSQL 的 SQL 数据库(目前我正在使用 RavenDB)
这是我的表:
痕迹:
ID (PK, bigint, not null)
DeploymentID (FK, int, not null)
AppCode (int, not null)
部署:
DeploymentID (PK, int, not null)
DeploymentVersion (varchar(10), not null)
DeploymentName (nvarchar(max), not null)
应用:
AppID (PK, int, not null)
AppName (nvarchar(max), not null)
目前我的表中有这些行:
痕迹:
ID: 1 , DeploymentID: 1, AppCode: 1
ID: 2 , DeploymentID: 1, AppCode: 2
ID: 3 , DeploymentID: 1, AppCode: 3
ID: 3 , DeploymentID: 2, AppCode: 1
部署:
DeploymentID: 1 , DeploymentVersion: 1.0, DeploymentName: "Test1"
DeploymentID: 2 , DeploymentVersion: 1.0, DeploymentName: "Test2"
应用:
AppID: 1 , AppName: "Test1"
AppID: 2 , AppName: "Test2"
AppID: 3 , AppName: "Test3"
我的问题是:我应该如何构建我的 NoSQL 文档模型?
它应该看起来像:
trace/1
{
"Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test1" } ],
"Application": "Test1"
}
trace/2
{
"Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test1" } ],
"Application": "Test2"
}
trace/3
{
"Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test1" } ],
"Application": "Test3"
}
trace/4
{
"Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test2" } ],
"Application": "Test1"
}
如果部署 1 发生变化怎么办?我应该浏览每个文档并更改数据吗?
什么时候应该在 NoSQL 中使用引用?