The first step in the schema design process is to identify the operations that your application runs most frequently. Knowing your application's most common queries helps you create effective indexes and minimize the number of calls the application makes to the database.模式设计过程的第一步是确定应用程序最频繁运行的操作。了解应用程序最常见的查询有助于您创建有效的索引,并最大限度地减少应用程序对数据库的调用次数。
About this Task关于此任务
When you consider your application's workload, consider the scenarios your application currently supports and scenarios it may support in the future. Design your schema to function in all stages of your application development.在考虑应用程序的工作负载时,请考虑应用程序当前支持的场景以及未来可能支持的场景。设计您的模式,使其在应用程序开发的所有阶段都能正常工作。
Steps步骤
Identify the data your application needs确定应用程序所需的数据
To identify the data that your application needs, consider the following factors:要确定应用程序所需的数据,请考虑以下因素:
Your application's users and the information they need.您的应用程序的用户及其所需的信息。Your business domain.您的业务领域。Application logs and frequently-run queries. To see database commands run on a MongoDB deployment, see Database Profiler.应用程序日志和频繁运行的查询。要查看在MongoDB部署上运行的数据库命令,请参阅数据库分析器。
Create a workload table with your application's queries使用应用程序的查询创建工作负载表
Fill out the following table with the queries that your application needs to run:在下表中填写您的应用程序需要运行的查询:
Example示例
The following example shows a workload table for a blog application:以下示例显示了博客应用程序的工作负载表:
| Write | 10 per day | |||
| Write | 1,000 per day (100 per article) | |||
| Read | 1,000,000 per day | |||
| Read | 10 per hour |
Next Steps后续步骤
After you identify your application's workload, the next step in the schema design process is to map related data in your schema. See Map Schema Relationships.在确定应用程序的工作负载后,模式设计过程的下一步是映射模式中的相关数据。请参见映射模式关系。