小编the*_*mix的帖子

如何在Cassandra中存储嵌套数据

考虑以下"文档",这两个文档将如何存储在集合中.

// collection posts:
{
  id: 1,
  name: "kingsbounty",
  fields: {
    "title": {
      "title": "Game Title",
      "value": "Kings Bounty"
    }
  },
  {
    "body": {
      "title": "Game Description",
      "value": "Kings Bounty is a turn-based fantasy..."
    }
  }
}

// collection posts:
{
  id: 2,
  name: "outrun",
  fields: { 
    "vehicle": {
      "title": "Vehicle",
      "value": "Ferrari Testarossa"
    },
    "color": {
      "title": "Vehicle Color",
      "value": "Red"
    },
    "driver": {
      "title": "Driver",
      "value": "David Hasselhoff"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

注意字段是不同大小的地图.

因为cassandra不允许定义这种类型 fields <map <map, text>>

我想学习"cassandra"的方式去做,非正规化的方式.这种方式不是非规范化的,但可以用来存储和检索任意长度的嵌套数据. …

database denormalization cassandra

5
推荐指数
1
解决办法
2021
查看次数

标签 统计

cassandra ×1

database ×1

denormalization ×1