假设我有organization_id
表,主键组成staff_id
为分区键,department
为排序键。另一方面,我有department_id
本地二级索引,{
...
KeySchema: [
{ AttributeName: "organization_id", KeyType: "HASH"},
{ AttributeName: "staff_id", KeyType: "RANGE" }
],
LocalSecondaryIndexes: [
{
IndexName: "department",
KeySchema: [
{ AttributeName: "organization_id", KeyType: "HASH"},
{ AttributeName: "department_id", KeyType: "RANGE" }
],
Projection: {
ProjectionType: "KEYS_ONLY"
}
}
],
AttributeDefinitions: [
{ AttributeName: "organization_id", AttributeType: "S" },
{ AttributeName: "staff_id", AttributeType: "S" },
{ AttributeName: "department_id", AttributeType: "S" }
]
...
}
为排序键。
staff_id
正如人们可能很容易理解的那样,有许多项目具有不同的department
共享相同的organization_id
索引键。我需要查询给定staff
的组织的部门列表。有没有办法从departments
表中检索此列表?我不喜欢维护另一个+--- org.springframework.kafka:spring-kafka: -> 1.1.6.RELEASE
| +--- org.springframework:spring-messaging:4.3.9.RELEASE -> 4.3.10.RELEASE
| | +--- org.springframework:spring-beans:4.3.10.RELEASE
| | | \--- org.springframework:spring-core:4.3.10.RELEASE
| | +--- org.springframework:spring-context:4.3.10.RELEASE
| | | +--- org.springframework:spring-aop:4.3.10.RELEASE
| | | | +--- org.springframework:spring-beans:4.3.10.RELEASE (*)
| | | | \--- org.springframework:spring-core:4.3.10.RELEASE
| | | +--- org.springframework:spring-beans:4.3.10.RELEASE (*)
| | | +--- org.springframework:spring-core:4.3.10.RELEASE
| | | \--- org.springframework:spring-expression:4.3.10.RELEASE
| | | \--- org.springframework:spring-core:4.3.10.RELEASE
| | \--- org.springframework:spring-core:4.3.10.RELEASE
| +--- org.springframework.retry:spring-retry:1.1.3.RELEASE -> 1.2.1.RELEASE
| | \--- org.springframework:spring-core:4.3.9.RELEASE -> 4.3.10.RELEASE
| \--- org.apache.kafka:kafka-clients:0.10.1.1
| +--- net.jpountz.lz4:lz4:1.3.0
| \--- org.xerial.snappy:snappy-java:1.1.2.6
+--- org.springframework.boot:spring-boot-starter: -> 1.5.6.RELEASE
| +--- org.springframework.boot:spring-boot:1.5.6.RELEASE
| | +--- org.springframework:spring-core:4.3.10.RELEASE
| | \--- org.springframework:spring-context:4.3.10.RELEASE (*)
| +--- org.springframework.boot:spring-boot-autoconfigure:1.5.6.RELEASE
| | \--- org.springframework.boot:spring-boot:1.5.6.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter-logging:1.5.6.RELEASE
| | +--- ch.qos.logback:logback-classic:1.1.11
| | | +--- ch.qos.logback:logback-core:1.1.11
| | | \--- org.slf4j:slf4j-api:1.7.22 -> 1.7.25
| | +--- org.slf4j:jcl-over-slf4j:1.7.25
| | | \--- org.slf4j:slf4j-api:1.7.25
| | +--- org.slf4j:jul-to-slf4j:1.7.25
| | | \--- org.slf4j:slf4j-api:1.7.25
| | \--- org.slf4j:log4j-over-slf4j:1.7.25
| | \--- org.slf4j:slf4j-api:1.7.25
| +--- org.springframework:spring-core:4.3.10.RELEASE
| \--- org.yaml:snakeyaml:1.17
+--- com.fasterxml.jackson.core:jackson-databind:2.8.7
| +--- com.fasterxml.jackson.core:jackson-annotations:2.8.0
| \--- com.fasterxml.jackson.core:jackson-core:2.8.7 -> 2.8.9
+--- com.kafka.test:txdb-connector:0.2.10
| +--- org.springframework.boot:spring-boot-starter:1.4.1.RELEASE -> 1.5.6.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter-jdbc:1.4.1.RELEASE -> 1.5.6.RELEASE
| | +--- org.springframework.boot:spring-boot-starter:1.5.6.RELEASE (*)
| | +--- org.apache.tomcat:tomcat-jdbc:8.5.16
| | | \--- org.apache.tomcat:tomcat-juli:8.5.16
| | \--- org.springframework:spring-jdbc:4.3.10.RELEASE
| | +--- org.springframework:spring-beans:4.3.10.RELEASE (*)
| | +--- org.springframework:spring-core:4.3.10.RELEASE
| | \--- org.springframework:spring-tx:4.3.10.RELEASE
| | +--- org.springframework:spring-beans:4.3.10.RELEASE (*)
| | \--- org.springframework:spring-core:4.3.10.RELEASE
| +--- com.oracle:ojdbc6:12.1.0.1
| \--- com.google.guava:guava:21.0
+--- org.springframework.cloud:spring-cloud-spring-service-connector:1.2.4.RELEASE
| +--- org.springframework.cloud:spring-cloud-core:1.2.4.RELEASE
| \--- org.springframework:spring-context:3.1.4.RELEASE -> 4.3.10.RELEASE (*)
+--- org.springframework.cloud:spring-cloud-config-client:1.3.2.RELEASE
| +--- org.springframework.boot:spring-boot-autoconfigure:1.5.4.RELEASE -> 1.5.6.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-commons:1.2.3.RELEASE
| | \--- org.springframework.security:spring-security-crypto:4.2.3.RELEASE
| +--- org.springframework.cloud:spring-cloud-context:1.2.3.RELEASE
| | \--- org.springframework.security:spring-security-crypto:4.2.3.RELEASE
| +--- org.springframework:spring-web:4.3.9.RELEASE -> 4.3.10.RELEASE
| | +--- org.springframework:spring-aop:4.3.10.RELEASE (*)
| | +--- org.springframework:spring-beans:4.3.10.RELEASE (*)
| | +--- org.springframework:spring-context:4.3.10.RELEASE (*)
| | \--- org.springframework:spring-core:4.3.10.RELEASE
| +--- com.fasterxml.jackson.core:jackson-annotations:2.8.0
| \--- com.fasterxml.jackson.core:jackson-databind:2.8.8 -> 2.8.7 (*)
\--- org.springframework:spring-aop:4.3.10.RELEASE (*)
表。我是DynamoDB的新手,所以如果您对整体表设计有任何意见/建议,我们都非常欢迎。
答案 0 :(得分:2)
截至目前,DynamoDB中没有明显的直接功能,但您可以通过以下方式实现此目的。
查询LSI并获取organizationId的所有记录,然后在应用程序级别找到不同的值。(这在NoSql DB中很常见)
正如你提到创建另一个表,现在我建议你创建另一个表,你可以直接检索所选的值
CloudSearch:可以集成到DynamoDB表中,然后您可以直接在Cloudsearch中搜索而不是在表中搜索,但是当您有多个搜索查询和数百万条记录时,这非常有用。
< / LI> 醇>由于