#### 1.需求

##### (1).数据字段
``````场次信息；

##### (2).业务查询有两种
``````根据电影场次，查询某一个渠道的价格；

#### 2.建模

##### (1).不好的

``````{
"scheduleId": "0001",
"movie": "你的名字",
"price": {
"gewala": 30,
"maoyan": 50,
"taopiao": 20
}
}``````

(a).根据电影场次，查询某一个渠道的价格

(b).根据渠道信息，查询对应的所有场次信息

``````createIndex({"price.gewala":1})
createIndex({"price.maoyan":1})
createIndex({"price.taopiao":1})``````

##### (2).一般般的设计
``````{
"scheduleId": "0001",
"movie": "你的名字",
"channel": "gewala",
"price": 30
}

{
"scheduleId": "0001",
"movie": "你的名字",
"channel": "maoyan",
"price": 50
}

{
"scheduleId": "0001",
"movie": "你的名字",
"channel": "taopiao",
"price": 20
}``````

(a).根据电影场次，查询某一个渠道的价格

(b).根据渠道信息，查询对应的所有场次信息

##### (3).合理的设计
``````{
"scheduleId": "0001",
"movie": "你的名字",
"provider": [
{
"channel": "gewala",
"price": 30
},
{
"channel": "maoyan",
"price": 50
},
{
"channel": "taopiao",
"price": 20
}
]
}``````

(a).根据电影场次，查询某一个渠道的价格

(b).根据渠道信息，查询对应的所有场次信息

``````db.movie.find({"scheduleId":"0001","movie":"你的名字", "provider.channel":"taopiao"}).explain()

......
"winningPlan": {
"stage": "FETCH",
"inputStage": {
"stage": "IXSCAN",
"keyPattern": {
"scheduleId": 1,
"movie": 1,
"provider.channel": 1
},
"indexName": "scheduleId_1_movie_1_provider.channel_1",
"isMultiKey": true,
......``````
``````db.movie.find({"provider.channel":"taopiao"}).explain()

......
"winningPlan": {
"stage": "FETCH",
"inputStage": {
"stage": "IXSCAN",
"keyPattern": {
"provider.channel": 1
},
"indexName": "provider.channel_1",
"isMultiKey": true,
......
``````