作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;text-align: left;> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">昨天,Anthropic(发布了Claude 3.5的公司)公布了其智能体系统的最佳实践,堪称目前最强,非常值得一读!这份来自行业顶尖AI公司的洞见,相信会给你带来非常多的启发。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">LLM智能体落地实战:避开99%的坑,只需这3个简单法则</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">你有没有觉得,现在AI智能体(Agent)的概念火得一塌糊涂,但真正用起来却感觉无从下手?过去一年,我们和各行各业的几十个团队一起研究大型语言模型智能体的落地,发现一个特点:<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">真正成功的案例,用的不是什么复杂框架或高深库,而是简单、可组合的模式!</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">今天,我就把我们从客户那里学到的,以及自己踩坑总结的经验分享给你,教你如何打造真正高效的智能体。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">什么是智能体?</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">“智能体”的定义五花八门。有的客户认为,智能体是完全自主的系统,可以长时间独立运行,利用各种工具完成复杂任务。有的则认为,智能体是按照预定义流程执行的系统。在Anthropic,我们把这些都归为<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">智能体系统</strong>,但我们更注重区分<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">工作流</strong>和<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">智能体</strong>这两种架构:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">工作流</strong>:LLM和工具通过预定义的代码路径进行编排。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">智能体</strong>:LLM动态地指导自己的流程和工具使用,自主决定如何完成任务。 </section></li> </ul> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">接下来,我们深入探讨这两种智能体系统。在附录1(“智能体的实践”)中,我们还会分享客户在两个领域使用这些系统取得的成功案例。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时用,何时不用智能体?</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">用LLM开发应用,<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">越简单越好</strong>!只有在必要时才增加复杂度。这意味着,你可能根本不需要智能体系统。智能体系统通常以延迟和成本为代价,换取更好的任务表现。所以,你需要权衡利弊。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">如果确实需要更复杂的方法,那么:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">工作流</strong>:适合处理定义明确的任务,提供可预测性和一致性。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">智能体</strong>:更适合需要灵活性和模型驱动决策的场景。 </section></li> </ul> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">但别忘了,很多时候,仅仅通过检索和上下文示例优化单次LLM调用就足够了。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">框架,是蜜糖还是砒霜?</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">现在有很多框架可以简化智能体系统的实现,比如:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> LangChain的LangGraph; </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 亚马逊Bedrock的AI Agent框架; </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 拖拽式GUI LLM工作流构建器Rivet; </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 另一个GUI工具Vellum,用于构建和测试复杂的工作流。 </section></li> </ul> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这些框架确实能让你快速上手,简化了调用LLM、定义和解析工具、链接调用等底层任务。但它们也可能引入额外的抽象层,让你难以理解底层提示和响应,给调试带来麻烦。更重要的是,它们可能会诱使你增加不必要的复杂性。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">我的建议是:</strong>先直接使用LLM API!很多模式只需几行代码就能实现。如果你非要用框架,请务必理解底层代码。对底层机制的错误假设,是客户常犯的错误。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">想看一些示例实现?请参考我们的cookbook。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">从积木到智能体:核心模式大揭秘</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">接下来,我们来探索在生产环境中常见的智能体系统模式。从最基础的增强型LLM开始,逐步增加复杂度,最终到达自主智能体。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">基石:增强型LLM</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">智能体系统的基本构件是增强型LLM,它具备检索、工具和记忆等能力。我们现在的模型可以主动使用这些能力,生成搜索查询、选择合适的工具、决定保留哪些信息。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">我们建议你关注两个关键点:</p> <ol data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">定制化:</strong>根据你的具体用例定制这些能力。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">易用性:</strong>为LLM提供简单、文档完善的接口。 </section></li> </ol> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">实现这些增强的方法有很多,其中一种是通过我们最近发布的模型上下文协议,它允许开发者通过简单的客户端实现与不断增长的第三方工具生态系统集成。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img data-imgfileid="100007263" data-ratio="0.4166666666666667" src="/upload/6fa39e4599a4c4287ffb168ba79c8106.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;object-fit: fill;box-shadow: rgb(133, 161, 201) 0px 0px 5px 0px;"> </figure> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在本文的后续部分,我们将假设每次LLM调用都可以访问这些增强功能。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">工作流:提示链</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">提示链将任务分解为一系列步骤,每个LLM调用处理上一步的输出。你可以在任何中间步骤添加编程检查(如下图中的“gate”),以确保流程正常进行。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时使用:</strong>当任务可以轻松地分解为固定的子任务时,提示链是理想选择。它的主要目标是通过简化每次LLM调用的任务,以延迟换取更高的准确性。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img data-imgfileid="100007266" data-ratio="0.4166666666666667" src="/upload/c96b837dc4c4b73c68d508b94614f930.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;object-fit: fill;box-shadow: rgb(133, 161, 201) 0px 0px 5px 0px;"> </figure> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">示例:</strong></p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 生成营销文案,然后将其翻译成其他语言。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 编写文档大纲,检查大纲是否符合特定标准,然后根据大纲编写文档。 </section></li> </ul> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">工作流:路由</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">路由对输入进行分类,并将其导向专门的后续任务。这种工作流可以实现关注点分离,并构建更专业的提示。如果没有路由,针对一种输入的优化可能会损害其他输入的性能。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img data-imgfileid="100007265" data-ratio="0.4166666666666667" src="/upload/84fba7bb4b933a2b1a70ce9c67d706ee.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;object-fit: fill;box-shadow: rgb(133, 161, 201) 0px 0px 5px 0px;"> </figure> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时使用:</strong>当复杂任务包含可以更好单独处理的不同类别,并且可以通过LLM或更传统的分类模型/算法准确处理分类时,路由效果很好。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">示例:</strong></p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 将不同类型的客户服务查询(一般问题、退款请求、技术支持)导向不同的下游流程、提示和工具。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 将简单/常见的问题导向较小的模型(如Claude 3.5 Haiku),将困难/不常见的问题导向功能更强大的模型(如Claude 3.5 Sonnet),以优化成本和速度。 </section></li> </ul> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">工作流:并行化</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">LLM有时可以同时处理一项任务,并通过编程方式聚合其输出。并行化工作流有两种主要形式:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">分段:</strong>将任务分解为并行运行的独立子任务。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">投票:</strong>多次运行同一任务以获得不同的输出。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <img data-imgfileid="100007264" data-ratio="0.4166666666666667" src="/upload/fde71dfa2a5b39a81b4a714add89e599.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;"> </section></li> </ul> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时使用:</strong>当可以并行化子任务以提高速度,或者需要多个角度或尝试以获得更高的置信度结果时,并行化是有效的。对于包含多个考虑因素的复杂任务,通常当每个考虑因素由单独的LLM调用处理时,LLM的性能会更好,从而可以专注于每个特定方面。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">示例:</strong></p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">分段:</strong> </section></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 实现安全防护,其中一个模型实例处理用户查询,而另一个模型实例筛选不当内容或请求。这往往比让同一个LLM调用同时处理安全防护和核心响应效果更好。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 自动化评估以评估LLM性能,其中每个LLM调用评估模型在给定提示下性能的不同方面。 </section></li> </ul> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">投票:</strong> </section></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 审查一段代码是否存在漏洞,其中多个不同的提示审查代码,并在发现问题时标记代码。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 评估一段内容是否不当,其中多个提示评估不同的方面或需要不同的投票阈值,以平衡误报和漏报。 </section></li> </ul> </ul> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">工作流:协调器-工作者</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在协调器-工作者工作流中,中央LLM动态地分解任务,将其委派给工作者LLM,并综合其结果。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img data-imgfileid="100007267" data-ratio="0.4166666666666667" src="/upload/20cfbb5354add6be849340a56696a6d5.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;object-fit: fill;box-shadow: rgb(133, 161, 201) 0px 0px 5px 0px;"> </figure> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时使用:</strong>这种工作流非常适合无法预测所需子任务的复杂任务(例如,在编码中,需要更改的文件数量以及每个文件中更改的性质可能取决于任务)。虽然在拓扑结构上相似,但与并行化的主要区别在于其灵活性——子任务不是预定义的,而是由协调器根据特定输入确定的。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">示例:</strong></p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 每次都对多个文件进行复杂更改的编码产品。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 涉及从多个来源收集和分析信息以获取可能相关信息的搜索任务。 </section></li> </ul> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">工作流:评估器-优化器</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在评估器-优化器工作流中,一个LLM调用生成响应,而另一个LLM调用在循环中提供评估和反馈。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img data-imgfileid="100007269" data-ratio="0.4166666666666667" src="/upload/8bf1899f76db92057aabdfa70fcbb396.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;object-fit: fill;box-shadow: rgb(133, 161, 201) 0px 0px 5px 0px;"> </figure> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时使用:</strong>当有明确的评估标准,并且迭代改进可以提供可衡量的价值时,此工作流特别有效。两个适用性指标是:首先,当人类表达反馈时,LLM的响应可以得到显著改进;其次,LLM可以提供此类反馈。这类似于人类作家在撰写润色文档时经历的迭代写作过程。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">示例:</strong></p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 文学翻译,其中翻译LLM可能最初无法捕捉到细微之处,但评估器LLM可以提供有用的批评。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 需要多轮搜索和分析以收集全面信息的复杂搜索任务,其中评估器决定是否需要进一步搜索。 </section></li> </ul> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(14, 136, 235);line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;">智能体</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">随着LLM在理解复杂输入、进行推理和规划、可靠地使用工具以及从错误中恢复等关键能力方面的成熟,智能体正在生产中涌现。智能体的工作从人类用户的命令或互动讨论开始。一旦任务明确,智能体就会独立规划和操作,并可能返回给人类以获取更多信息或判断。在执行过程中,智能体必须在每个步骤中从环境中获得“真实信息”(例如工具调用结果或代码执行),以评估其进度。智能体可以在检查点或遇到障碍时暂停以获得人类反馈。任务通常在完成时终止,但也通常包括停止条件(例如最大迭代次数)以保持控制。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">智能体可以处理复杂的任务,但它们的实现通常很简单。它们通常只是在循环中基于环境反馈使用工具的LLM。因此,清晰且周全地设计工具集及其文档至关重要。我们在附录2(“提示工程你的工具”)中扩展了工具开发的最佳实践。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img data-imgfileid="100007268" data-ratio="0.4166666666666667" src="/upload/f4cdb6947311b2657f181d1bf9031bb3.png" data-type="other" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;object-fit: fill;box-shadow: rgb(133, 161, 201) 0px 0px 5px 0px;"> </figure> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">何时使用:</strong>智能体可用于无法预测所需步骤数量的开放式问题,并且无法硬编码固定路径。LLM可能会运行多次,你必须对其决策有一定程度的信任。智能体的自主性使其非常适合在受信任的环境中扩展任务。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">智能体的自主性意味着更高的成本以及复合错误的潜在风险。我们建议在沙盒环境中进行广泛的测试,并采取适当的安全措施。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">示例:</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">以下示例来自我们自己的实现:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 解决SWE-bench任务的编码智能体,其中涉及基于任务描述对多个文件进行编辑; </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 我们的“计算机使用”参考实现,其中Claude使用计算机完成任务。 </section></li> </ul> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">组合和定制这些模式</strong></p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这些构建模块不是规定性的。它们是开发人员可以塑造和组合以适应不同用例的常见模式。与任何LLM功能一样,成功的关键在于衡量性能并迭代实现。再次强调:只有当它能显著改善结果时,你才应该考虑增加复杂性。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在LLM领域取得成功,不在于构建最复杂的系统,而在于构建<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">适合你需求的系统</strong>。从简单的提示开始,通过全面的评估对其进行优化,并且仅在更简单的解决方案不足时才添加多步骤智能体系统。</p> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在实施智能体时,我们尝试遵循三个核心原则:</p> <ol data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 保持智能体设计的<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">简单性</strong>。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 通过明确显示智能体的规划步骤来优先考虑<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">透明度</strong>。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 15px;line-height: 1.8em;letter-spacing: 0em;"> 通过全面的工具<strong style="color: rgb(14, 136, 235);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">文档和测试</strong>精心设计你的智能体-计算机接口 (ACI)。 </section></li> </ol> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">框架可以帮助你快速入门,但当你转向生产时,请不要犹豫减少抽象层并使用基本组件进行构建。通过遵循这些原则,你可以创建不仅强大而且可靠、可维护并受到用户信任的智能体。</p> </section> <p><br></p> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<article> <p><span style="font-weight: bold;font-size: 28px;"><span leaf="">1. Prometheus介绍</span></span></p> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">1.1 什么是</span></span><span style="font-weight: bold;font-size: 20px;"><span leaf="">Prometheus</span></span></p> <p><span leaf="">Prometheus受启发于Google的Brogmon监控系统(相似的Kubernetes是从Google的Brog系统演变而来),从2012年开始由前Google工程师在Soundcloud以开源软件的形式进行研发,并且于2015年早期对外发布早期版本。2016年5月继Kubernetes之后成为第二个正式加入CNCF基金会的项目,同年6月正式发布1.0版本。2017年底发布了基于全新存储层的2.0版本,能更好地与容器平台、云平台配合。</span></p> <p><span leaf="">官网:</span><span style="color: rgb(0, 56, 132);"><span leaf="">https://prometheus.io/</span></span></p> </article> <section style="text-align: center;" nodeleaf=""> <img src="/upload/d52b9e099e38eae3f3a19ae01f7f785e.png" class="rich_pages wxw-img" data-ratio="0.3095512082853855" data-s="300,640" data-type="png" data-w="869" type="block" data-imgfileid="100001197"> </section> <article> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">监控的目标</span></span></p> <p><span leaf="">监控系统需要能够有效地支持白盒监控和黑盒监控。通过白盒能够了解其内部的实际运行状态,通过对监控指标的观察能够预判可能出现的问题,从而对潜在的不确定因素进行优化。而黑盒监控,常见的如HTTP探针,TCP探针等,可以在系统或者服务在发生故障时能够快速通知相关的人员进行处理。通过建立完善的监控体系,从而达到以下目的:</span></p> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;><span style="font-weight: bold;"><span leaf="">长期趋势分析<span textstyle="" style="font-weight: normal;">:通过对监控样本数据的持续收集和统计,对监控指标进行长期趋势分析。例如,通过对磁盘空间增长率的判断,我们可以提前预测在未来什么时间节点上需要对资源进行扩容。</span></span></span></li> </ul> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;><span style="font-weight: bold;"><span leaf="">对照分析<span textstyle="" style="font-weight: normal;">:两个版本的系统运行资源使用情况的差异如何?在不同容量情况下系统的并发和负载变化如何?通过监控能够方便的对系统进行跟踪和比较。</span></span></span></li> </ul> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;><span style="font-weight: bold;"><span leaf="">告警<span textstyle="" style="font-weight: normal;">:当系统出现或者即将出现故障时,监控系统需要迅速反应并通知管理员,从而能够对问题进行快速的处理或者提前预防问题的发生,避免出现对业务的影响。</span></span></span></li> </ul> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;><span style="font-weight: bold;"><span leaf="">故障分析与定位<span textstyle="" style="font-weight: normal;">:当问题发生后,需要对问题进行调查和处理。通过对不同监控监控以及历史数据的分析,能够找到并解决根源问题。</span></span></span></li> </ul> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;><span style="font-weight: bold;"><span leaf="">数据可视化<span textstyle="" style="font-weight: normal;">:通过可视化仪表盘能够直接获取系统的运行状态、资源使用情况、以及服务运行状态等直观的信息。</span></span></span> <section> <span leaf=""><br></span> </section></li> </ul> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">Prometheus的优势</span></span></p> <p><span leaf="">Prometheus是一个开源的完整监控解决方案,其对传统监控系统的测试和告警模型进行了彻底的颠覆,形成了基于中央化的规则计算、统一分析和告警的新模型。 相比于传统监控系统Prometheus具有以下优点:</span></p> <ul style="list-style-type: disc;" class="list-paddingleft-1"> <li style="font-size:14px;"> <section> <span leaf=""><span textstyle="" style="font-size: 14px;">内置时序数据库:Prometheus自带了一种高性能的时间序列数据库用于存储监控数据。这个数据库针对高吞吐量的写入和查询进行了优化。</span></span> </section></li> <li style="font-size:14px;"> <section> <span leaf=""><span textstyle="" style="font-size: 14px;">强大的数据模型:Prometheus使用多维数据模型来存储时间序列数据,如下所示每一条时间序列由指标名称(Metrics Name)以及一组标签(Labels)唯一标识,每条时间序列按照时间的先后顺序存储一系列的样本值。</span></span> </section></li> </ul> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="java"><code><span leaf=""><span class="code-snippet__plaintext"> <metric name>{ <label name>=<label value>, ...} =>[value1</label></label> </metric></span><span class="code-snippet__meta">@timestamp1</span><span class="code-snippet__plaintext">,value2</span><span class="code-snippet__meta">@timestamp2</span><span class="code-snippet__plaintext">...]</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">http_request_status{code=</span><span class="code-snippet__string">'200'</span><span class="code-snippet__plaintext">,content_path=</span><span class="code-snippet__string">'/api/path'</span><span class="code-snippet__plaintext">, environment=</span><span class="code-snippet__string">'produment'</span><span class="code-snippet__plaintext">} => [value1</span><span class="code-snippet__meta">@timestamp1</span><span class="code-snippet__plaintext">,value2</span><span class="code-snippet__meta">@timestamp2</span><span class="code-snippet__plaintext">...]</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">http_request_status{code=</span><span class="code-snippet__string">'200'</span><span class="code-snippet__plaintext">,content_path=</span><span class="code-snippet__string">'/api/path2'</span><span class="code-snippet__plaintext">, environment=</span><span class="code-snippet__string">'produment'</span><span class="code-snippet__plaintext">} => [value1</span><span class="code-snippet__meta">@timestamp1</span><span class="code-snippet__plaintext">,value2</span><span class="code-snippet__meta">@timestamp2</span><span class="code-snippet__plaintext">...]</span></span></code></pre> </section> <article data-content="[{" type:block,id:rydj-1701348727972,name:list-item,data:{version:1,listid:gvli-1701348727978,listlevel:1,listtype:unordered},nodes:[{type:text,id:z2rn-1701348727971,leaves:[{text:promql查询语言:promql是prometheus的查询语言,支持丰富的操作和聚合函数,使用户能够进行高级查询、数据分析和警报设置。,marks:[]}]}],state:{}},{type:block,id:aqm7-1701348727974,name:list-item,data:{version:1,listid:gvli-1701348727978,listlevel:1,listtype:unordered},nodes:[{type:text,id:usb0-1701348727973,leaves:[{text:可扩展、易集成: prometheus可以轻松集成新的数据源和插件,以适应不同的监控需求。它还支持水平扩展,以处理大规模的监控数据。prometheus社区提供了大量第三方实现的监控数据采集支持:jmx, cloudwatch, ec2, mysql, postgressql, haskell, bash, snmp, consul, haproxy, mesos, bind, couchdb, django, memcached, rabbitmq, redis, rethinkdb, rsyslog等等。,marks:[]}]}],state:{index:2}},{type:block,id:2oz4-1701348727976,name:list-item,data:{version:1,listid:gvli-1701348727978,listlevel:1,listtype:unordered},nodes:[{type:text,id:ltnu-1701348727975,leaves:[{text:可视化支持: prometheus除了自带的ui可以对收集的指标可视化查询,还可以,基于grafana可以创建更加精美的监控图标。,marks:[]}]}],state:{}}]> <ul style="list-style-type: disc;" class="list-paddingleft-1"> <li style="font-size:14px;"> <section> <span leaf=""><span textstyle="" style="font-size: 14px;">PromQL查询语言:PromQL是Prometheus的查询语言,支持丰富的操作和聚合函数,使用户能够进行高级查询、数据分析和警报设置。</span></span> </section></li> <li style="font-size:14px;"> <section> <span leaf=""><span textstyle="" style="font-size: 14px;">可扩展、易集成: Prometheus可以轻松集成新的数据源和插件,以适应不同的监控需求。它还支持水平扩展,以处理大规模的监控数据。Prometheus社区提供了大量第三方实现的监控数据采集支持:JMX, MySQL, PostgresSQL, Redis等等。</span></span> </section></li> <li style="font-size:14px;"> <section> <span leaf=""><span textstyle="" style="font-size: 14px;">可视化支持: Prometheus除了自带的UI可以对收集的指标可视化查询,还可以,基于Grafana可以创建更加精美的监控图标。</span></span> </section></li> </ul> </article> <section> <span leaf=""><br></span> </section> <article> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">1.2 </span></span><span style="font-weight: bold;color: rgb(51, 51, 51);font-size: 20px;"><span leaf="">Prometheus 组成与架构</span></span><span style="color: rgb(255, 255, 255);font-weight: bold;font-size: 20px;"><span leaf="">展</span></span></p> <p><span leaf="">下图展示Prometheus的基本架构:</span></p> <section nodeleaf=""> <img src="/upload/acad3f2622e322f9f3ea868e4b6ef254.png" class="rich_pages wxw-img" data-ratio="0.6652173913043479" data-type="png" data-w="690" style="width: 594px;height: 407px;" data-imgfileid="100001199"> </section> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">Prometheus Server</span></span></p> <p><span style="color: rgb(243, 50, 50);"><span leaf="">Prometheus Server是Prometheus组件中的核心部分,负责实现对监控数据的获取,存储以及查询。</span></span><span leaf=""> Prometheus Server可以通过静态配置管理监控目标,也可以配合使用Service Discovery的方式动态管理监控目标,并从这些监控目标中获取数据。其次Prometheus Server需要对采集到的监控数据进行存储,Prometheus Server本身就是一个时序数据库,将采集到的监控数据按照时间序列的方式存储在本地磁盘当中。最后Prometheus Server对外提供了自定义的PromQL语言,实现对数据的查询以及分析。</span></p> <p><span leaf="">Prometheus Server内置的Express Browser UI,通过这个UI可以直接通过PromQL实现数据的查询以及可视化。</span></p> <p><span leaf="">Prometheus Server的联邦集群能力可以使其从其他的Prometheus Server实例中获取数据,因此在大规模监控的情况下,可以通过联邦集群以及功能分区的方式对Prometheus Server进行扩展。</span></p> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">Exporters</span></span></p> <p><span style="color: rgb(243, 50, 50);"><span leaf="">Exporter将监控数据采集的端点通过HTTP服务的形式暴露给Prometheus Server,Prometheus Server通过访问该Exporter提供的Endpoint端点,即可获取到需要采集的监控数据。</span></span></p> <p><span leaf="">一般来说可以将Exporter分为2类:</span></p> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;> <section> <span leaf="" style="color: rgb(243, 50, 50);">直接采集<span textstyle="" style="color: rgb(0, 0, 0);">:这一类Exporter直接内置了对Prometheus监控的支持,比如cAdvisor,Kubernetes,Etcd,Gokit等,都直接内置了用于向Prometheus暴露监控数据的端点。</span></span> </section></li> </ul> <ul style="margin:0px;" class="list-paddingleft-1"> <li style="white-space:pre-wrap;line-height:1.75;font-size:14px;text-align:left;list-style-position:inside;word-break:break-word;color:rgb(0, 0, 0);font-weight:normal;font-style:normal;text-decoration:none;background-color:rgba(0, 0, 0, 0);font-family:" microsoft yahei, stxihei;list-style-type:disc;><span style="color: rgb(243, 50, 50);"><span leaf="">间接采集<span textstyle="" style="color: rgb(0, 0, 0);">:间接采集,原有监控目标并不直接支持Prometheus,因此我们需要通过Prometheus提供的Client Library编写该监控目标的监控采集程序。例如: Mysql Exporter,JMX Exporter,Consul Exporter等。</span></span></span></li> </ul> </article> <section> <span leaf=""><br></span> </section> <article> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">AlertManager</span></span></p> <p><span style="color: rgb(243, 50, 50);"><span leaf="">在Prometheus Server中支持基于PromQL创建告警规则,如果满足PromQL定义的规则,则会产生一条告警,而告警的后续处理流程则由AlertManager进行管理。</span></span><span leaf="">在AlertManager中我们可以与邮件,Slack等等内置的通知方式进行集成,也可以通过Webhook自定义告警处理方式。AlertManager即Prometheus体系中的告警处理中心。</span></p> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">PushGateway</span></span></p> <p><span leaf="">由于Prometheus数据采集基于Pull模型进行设计,因此在网络环境的配置上必须要让Prometheus Server能够直接与Exporter进行通信。 当这种网络需求无法直接满足时,就可以利用PushGateway来进行中转。可以通过PushGateway将内部网络的监控数据主动Push到Gateway当中。而Prometheus Server则可以采用同样Pull的方式从PushGateway中获取到监控数据。</span></p> <p><span style="font-weight: bold;font-size: 28px;"><span leaf=""><br></span></span></p> <p><span style="font-weight: bold;font-size: 28px;"><span leaf="">2.Prometheus快速开始</span></span></p> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">2.1 安装Prometheus Server</span></span></p> <p><span leaf="">Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖。用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prometheus Server。</span></p> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">从二进制包安装</span></span></p> <p><span leaf="">对于非Docker用户,可以从</span><span style="color: rgb(0, 56, 132);"><span leaf="">https://prometheus.io/download/</span></span><span leaf="">找到最新版本的Prometheus Sevrer软件包:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="cpp"><code><span leaf=""><span class="code-snippet__meta">#windows</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">https:</span><span class="code-snippet__comment">//github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.windows-amd64.zip</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">#linux</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">wget https://github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.linux-amd64.tar.gz</span></span></code></pre> </section> <article data-content="[{" type:block,id:5fud-1701349824755,name:paragraph,data:{},nodes:[{type:text,id:jody-1701349824756,leaves:[{text:解压后当前目录会包含默认的prometheus配置文件promethes.yml:,marks:[]}]}],state:{}}]> <p><span leaf="">解压后当前目录会包含默认的Prometheus配置文件promethes.yml:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__plaintext"># my </span><span class="code-snippet__keyword">global</span><span class="code-snippet__plaintext"> config</span></span></code><code><span leaf=""><span class="code-snippet__keyword">global</span><span class="code-snippet__plaintext">:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> scrape_interval: </span><span class="code-snippet__number">15</span><span class="code-snippet__plaintext">s # </span><span class="code-snippet__keyword">Set</span><span class="code-snippet__plaintext"> the scrape </span><span class="code-snippet__type">interval</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">to</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">every</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__number">15</span><span class="code-snippet__plaintext"> seconds. </span><span class="code-snippet__keyword">Default</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">is</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">every</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__number">1</span><span class="code-snippet__plaintext"> minute.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> evaluation_interval: </span><span class="code-snippet__number">15</span><span class="code-snippet__plaintext">s # Evaluate rules </span><span class="code-snippet__keyword">every</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__number">15</span><span class="code-snippet__plaintext"> seconds. The </span><span class="code-snippet__keyword">default</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">is</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">every</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__number">1</span><span class="code-snippet__plaintext"> minute.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # scrape_timeout </span><span class="code-snippet__keyword">is</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">set</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">to</span><span class="code-snippet__plaintext"> the </span><span class="code-snippet__keyword">global</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">default</span><span class="code-snippet__plaintext"> (</span><span class="code-snippet__number">10</span><span class="code-snippet__plaintext">s).</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># Alertmanager configuration</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">alerting:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> alertmanagers:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__operator">-</span><span class="code-snippet__plaintext"> static_configs:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__operator">-</span><span class="code-snippet__plaintext"> targets:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # </span><span class="code-snippet__operator">-</span><span class="code-snippet__plaintext"> alertmanager:</span><span class="code-snippet__number">9093</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># Load rules once </span><span class="code-snippet__keyword">and</span><span class="code-snippet__plaintext"> periodically evaluate them according </span><span class="code-snippet__keyword">to</span><span class="code-snippet__plaintext"> the </span><span class="code-snippet__keyword">global</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__string">'evaluation_interval'</span><span class="code-snippet__plaintext">.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">rule_files:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # </span><span class="code-snippet__operator">-</span><span class="code-snippet__plaintext"> "first_rules.yml"</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # </span><span class="code-snippet__operator">-</span><span class="code-snippet__plaintext"> "second_rules.yml"</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># A scrape configuration containing exactly </span><span class="code-snippet__keyword">one</span><span class="code-snippet__plaintext"> endpoint </span><span class="code-snippet__keyword">to</span><span class="code-snippet__plaintext"> scrape:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># Here it</span><span class="code-snippet__string">'s Prometheus itself.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">scrape_configs:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # The job name is added as a label `job= <job_name>` to any timeseries scraped from this config. </job_name></span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - job_name: 'prometheus</span><span class="code-snippet__string">'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # metrics_path defaults to '</span><span class="code-snippet__operator">/</span><span class="code-snippet__plaintext">metrics</span><span class="code-snippet__string">'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # scheme defaults to 'http</span><span class="code-snippet__string">'.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> static_configs:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - targets: ['localhost:</span><span class="code-snippet__number">9090</span><span class="code-snippet__string">']</span></span></code></pre> </section> <article data-content="[{" type:block,id:brci-1701350208937,name:paragraph,data:{},nodes:[{type:text,id:sjib-1701350208938,leaves:[{text:启动prometheus服务,其会默认加载当前路径下的prometheus.yaml文件:,marks:[]}]}],state:{}}]> <p><span leaf="">启动prometheus服务,其会默认加载当前路径下的prometheus.yaml文件:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__plaintext">./prometheus</span></span></code></pre> </section> <article data-content="[{" type:block,id:6pfl-1701350279639,name:paragraph,data:{version:1},nodes:[{type:text,id:jejh-1701350279638,leaves:[{text:正常的情况下,你可以看到以下输出内容:,marks:[]}]}],state:{}}]> <p><span leaf="">正常的情况下,你可以看到以下输出内容:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__plaintext">level=info ts=2018-10-23T14:55:14.499484Z </span><span class="code-snippet__built_in">caller</span><span class="code-snippet__plaintext">=main.go:554 msg=</span><span class="code-snippet__string">"Starting TSDB ..."</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">level=info ts=2018-10-23T14:55:14.499531Z </span><span class="code-snippet__built_in">caller</span><span class="code-snippet__plaintext">=web.go:397 component=web msg=</span><span class="code-snippet__string">"Start listening for connections"</span><span class="code-snippet__plaintext"> address=0.0.0.0:9090</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">level=info ts=2018-10-23T14:55:14.507999Z </span><span class="code-snippet__built_in">caller</span><span class="code-snippet__plaintext">=main.go:564 msg=</span><span class="code-snippet__string">"TSDB started"</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">level=info ts=2018-10-23T14:55:14.508068Z </span><span class="code-snippet__built_in">caller</span><span class="code-snippet__plaintext">=main.go:624 msg=</span><span class="code-snippet__string">"Loading configuration file"</span><span class="code-snippet__plaintext"> filename=prometheus.yml</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">level=info ts=2018-10-23T14:55:14.509509Z </span><span class="code-snippet__built_in">caller</span><span class="code-snippet__plaintext">=main.go:650 msg=</span><span class="code-snippet__string">"Completed loading of configuration file"</span><span class="code-snippet__plaintext"> filename=prometheus.yml</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">level=info ts=2018-10-23T14:55:14.509537Z </span><span class="code-snippet__built_in">caller</span><span class="code-snippet__plaintext">=main.go:523 msg=</span><span class="code-snippet__string">"Server is ready to receive web requests."</span></span></code></pre> </section> <article data-content="[{" type:block,id:6qoc-1701351287376,name:heading,data:{level:h3},nodes:[{type:text,id:zgdc-1701351287375,leaves:[{text:使用docker安装,marks:[]}]}],state:{}},{type:block,id:vbjt-1701351288665,name:paragraph,data:{version:1},nodes:[{type:text,id:tzxn-1701351288664,leaves:[{text:对于docker用户,直接使用prometheus的镜像即可启动prometheus server:,marks:[]}]}],state:{}}]> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">使用docker安装</span></span></p> <p><span leaf="">对于Docker用户,直接使用Prometheus的镜像即可启动Prometheus Server:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__plaintext">docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus</span></span></code></pre> </section> <article data-content="[{" type:block,id:hznp-1701351750982,name:paragraph,data:{},nodes:[{type:text,id:02j7-1701351750981,leaves:[{text:启动完成后,可以通过,marks:[]}]},{type:inline,id:d9v7-1701351319772,name:link,data:{href:http: localhost:9090},nodes:[{type:text,id:4m48-1701351319775,leaves:[{text:http: localhost:9090,marks:[]}]}]},{type:text,id:mxlq-1701351319776,leaves:[{text:访问prometheus的ui界面:,marks:[]}]}],state:{}},{type:block,id:xpgy-1701351336579,name:image,data:{version:1,url:https: note.youdao.com yws res 78834 webresource85c7984ce92344f48d7c79a1526e0807,width:2880,height:734,fromidentity:},nodes:[],state:{rendersource:https: webresource85c7984ce92344f48d7c79a1526e0807,initialsize:{width:2880,height:734},loading:false}},{type:block,id:kaea-1701351336582,name:paragraph,data:{},nodes:[{type:text,id:pjwg-1701351336581,leaves:[{text:也可以使用docker compose安装,marks:[]}]}],state:{}}]> <p><span leaf="">启动完成后,可以通过</span><span style="color: rgb(0, 56, 132);"><span leaf="">http://localhost:9090</span></span><span leaf="">访问Prometheus的UI界面:</span></p> <section nodeleaf=""> <img src="/upload/fbc4eafcf436a5e5d7f9eb3156fa3a72.png" class="rich_pages wxw-img" data-ratio="0.25462962962962965" data-type="png" data-w="1080" style="width: 2880px;height: 734px;" data-imgfileid="100001200"> </section> <p><span leaf="">也可以使用docker compose安装</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="ruby"><code><span leaf=""><span class="code-snippet__symbol">version:</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__string">"3"</span></span></code><code><span leaf=""><span class="code-snippet__symbol">services:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__symbol">prometheus:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__symbol">image:</span><span class="code-snippet__plaintext"> prom/</span><span class="code-snippet__symbol">prometheus:</span><span class="code-snippet__plaintext">v2.</span><span class="code-snippet__number">4.3</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__symbol">container_name:</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__string">'prometheus'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__symbol">volumes:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - ./prometheus/</span><span class="code-snippet__symbol">:/etc/prometheus/</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__comment">#映射prometheus的配置文件</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - /etc/localtime:/etc/localtime:ro #同步容器与宿主机的时间,这个非常重要,如果时间不一致,会导致prometheus抓不到数据</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> ports:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - '9090:9090'</span></span></code></pre> </section> <article> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">2.2 使用Node Exporter采集主机数据</span></span></p> <p><span style="font-weight: bold;color: rgb(59, 69, 78);background-color: rgba(0, 0, 0, 0);font-family: Arial;font-size: inherit;"><span leaf="">安装Node Exporter</span></span></p> <p><span leaf="">在Prometheus的架构设计中,Prometheus Server并不直接服务监控特定的目标,其主要任务负责数据的收集,存储并且对外提供数据查询支持。因此为了能够能够监控到某些东西,如主机的CPU使用率,我们需要使用到Exporter。Prometheus周期性的从Exporter暴露的HTTP服务地址(通常是/metrics)拉取监控样本数据。</span></p> <p><span leaf="">这里为了能够采集到主机的运行指标如CPU, 内存,磁盘等信息。我们可以使用</span><span style="color: rgb(0, 56, 132);"><span leaf="">Node Exporter</span></span><span leaf="">。</span></p> <p><span leaf="">Node Exporter同样采用Golang编写,并且不存在任何的第三方依赖,只需要下载,解压即可运行。可以从</span><span style="color: rgb(0, 56, 132);"><span leaf="">https://prometheus.io/download/</span></span><span leaf="">获取最新的node exporter版本的二进制包。</span></p> <p><span leaf="">也可以使用docker安装</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__plaintext">docker run -d -p 9100:9100 prom/node-exporter</span></span></code></pre> </section> <article> <p><span leaf="">访问</span><span style="color: rgb(0, 56, 132);"><span leaf="">http://localhost:9100/</span></span><span leaf="">可以看到以下页面:</span></p> <section nodeleaf=""> <img src="/upload/1f31481a2cb15d367fc6e30903d9f90c.png" class="rich_pages wxw-img" data-ratio="0.30965391621129323" data-type="png" data-w="549" style="width: 549px;height: 170px;" data-imgfileid="100001201"> </section> <p><span leaf="">Node Exporter页面</span></p> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">初始Node Exporter监控指标</span></span></p> <p><span leaf="">访问</span><span style="color: rgb(0, 56, 132);"><span leaf="">http://localhost:9100/metrics</span></span><span leaf="">,可以看到当前node exporter获取到的当前主机的所有监控数据,如下所示</span></p> <section nodeleaf=""> <img src="/upload/5759aa438d688c6cd261b73d872f7410.png" class="rich_pages wxw-img" data-ratio="0.6537931034482759" data-type="png" data-w="725" style="width: 725px;height: 474px;" data-imgfileid="100001202"> </section> <p><span leaf="">每一个监控指标之前都会有一段类似于如下形式的信息:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="swift"><code><span leaf=""><span class="code-snippet__plaintext"># </span><span class="code-snippet__type">HELP</span><span class="code-snippet__plaintext"> node_cpu </span><span class="code-snippet__type">Seconds</span><span class="code-snippet__plaintext"> the cpus spent </span><span class="code-snippet__keyword">in</span><span class="code-snippet__plaintext"> </span><span class="code-snippet__keyword">each</span><span class="code-snippet__plaintext"> mode.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># </span><span class="code-snippet__type">TYPE</span><span class="code-snippet__plaintext"> node_cpu counter</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">node_cpu{cpu</span><span class="code-snippet__operator">=</span><span class="code-snippet__string">"cpu0"</span><span class="code-snippet__plaintext">,mode</span><span class="code-snippet__operator">=</span><span class="code-snippet__string">"idle"</span><span class="code-snippet__plaintext">} </span><span class="code-snippet__number">362812.7890625</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># </span><span class="code-snippet__type">HELP</span><span class="code-snippet__plaintext"> node_load1 1m load average.</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"># </span><span class="code-snippet__type">TYPE</span><span class="code-snippet__plaintext"> node_load1 gauge</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">node_load1 </span><span class="code-snippet__number">3.0703125</span></span></code></pre> </section> <article> <p><span leaf="">其中HELP用于解释当前指标的含义,TYPE则说明当前指标的数据类型。在上面的例子中node_cpu的注释表明当前指标是cpu0上idle进程占用CPU的总时间,CPU占用时间是一个只增不减的度量指标,从类型中也可以看出node_cpu的数据类型是计数器(counter),与该指标的实际含义一致。又例如node_load1该指标反映了当前主机在最近一分钟以内的负载情况,系统的负载情况会随系统资源的使用而变化,因此node_load1反映的是当前状态,数据可能增加也可能减少,从注释中可以看出当前指标类型为仪表盘(gauge),与指标反映的实际含义一致。</span></p> <p><span leaf="">除了这些以外,在当前页面中根据物理主机系统的不同,你还可能看到如下监控指标:</span></p> <ul style="list-style-type: disc;" class="list-paddingleft-1"> <li> <section> <span leaf="">node_boot_time:系统启动时间</span> </section></li> <li> <section> <span leaf="">node_cpu:系统CPU使用量</span> </section></li> <li> <section> <span leaf="">nodedisk*:磁盘IO</span> </section></li> <li> <section> <span leaf="">nodefilesystem*:文件系统用量</span> </section></li> <li> <section> <span leaf="">node_load1:系统负载</span> </section></li> <li> <section> <span leaf="">nodememeory*:内存使用量</span> </section></li> <li> <section> <span leaf="">nodenetwork*:网络带宽</span> </section></li> <li> <section> <span leaf="">node_time:当前系统时间</span> </section></li> <li> <section> <span leaf="">go_*:node exporter中go相关指标</span> </section></li> <li> <section> <span leaf="">process_*:node exporter自身进程相关运行指标</span> </section></li> </ul> </article> <section> <span leaf=""><br></span> </section> <article data-content="[{" type:block,id:3qln-1701352562528,name:heading,data:{level:h3},nodes:[{type:text,id:urt0-1701352562527,leaves:[{text:从node exporter收集监控数据,marks:[]}]}],state:{}},{type:block,id:nxr1-1701352563112,name:paragraph,data:{version:1},nodes:[{type:text,id:vay1-1701352563111,leaves:[{text:为了能够让prometheus server能够从当前node exporter获取到监控数据,这里需要修改prometheus配置文件。编辑prometheus.yml并在scrape_configs节点下添加以下内容:,marks:[]}]}],state:{}}]> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">从Node Exporter收集监控数据</span></span></p> <p><span leaf="">为了能够让Prometheus Server能够从当前node exporter获取到监控数据,这里需要修改Prometheus配置文件。编辑prometheus.yml并在scrape_configs节点下添加以下内容:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="css"><code><span leaf=""><span class="code-snippet__plaintext">scrape_configs:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - job_name: </span><span class="code-snippet__string">'prometheus'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> static_configs:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - targets: [</span><span class="code-snippet__string">'localhost:9090'</span><span class="code-snippet__plaintext">]</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> # 采集node exporter监控数据</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - job_name: </span><span class="code-snippet__string">'node'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> static_configs:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - targets: [</span><span class="code-snippet__string">'localhost:9100'</span><span class="code-snippet__plaintext">]</span></span></code></pre> </section> <article> <p><span style="font-weight: bold;"><span leaf="">重新启动Prometheus Server</span></span></p> <p><span leaf="">访问</span><span style="color: rgb(0, 56, 132);"><span leaf="">http://localhost:9090</span></span><span leaf="">,进入到Prometheus Server。如果输入“up”并且点击执行按钮以后,可以看到如下结果:</span></p> <section nodeleaf=""> <img src="/upload/15d110fd811930fc606b654398a0344a.png" class="rich_pages wxw-img" data-ratio="0.4900105152471083" data-type="png" data-w="951" style="width: 951px;height: 466px;" data-imgfileid="100001203"> </section> <p><span leaf="">如果Prometheus能够正常从node exporter获取数据,则会看到以下结果:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="javascript"><code><span leaf=""><span class="code-snippet__plaintext">up{instance=</span><span class="code-snippet__string">"localhost:9090"</span><span class="code-snippet__plaintext">,job=</span><span class="code-snippet__string">"prometheus"</span><span class="code-snippet__plaintext">} </span><span class="code-snippet__number">1</span></span></code><code><span leaf=""><span class="code-snippet__plaintext">up{instance=</span><span class="code-snippet__string">"localhost:9100"</span><span class="code-snippet__plaintext">,job=</span><span class="code-snippet__string">"node"</span><span class="code-snippet__plaintext">} </span><span class="code-snippet__number">1</span></span></code></pre> </section> <article> <p><span leaf="">其中“1”表示正常,反之“0”则为异常。</span></p> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">2.3 使用PromQL查询监控数据</span></span></p> <p><span leaf="">Prometheus UI是Prometheus内置的一个可视化管理界面,通过Prometheus UI用户能够轻松的了解Prometheus当前的配置,监控任务运行状态等。 通过</span><span style="background-color: rgb(245, 247, 249);"><span leaf="">Graph</span></span><span leaf="">面板,用户还能直接使用</span><span style="background-color: rgb(245, 247, 249);"><span leaf="">PromQL</span></span><span leaf="">实时查询监控数据:</span></p> <section nodeleaf=""> <img src="/upload/4297290e31ea6a143df5a39c64e77516.png" class="rich_pages wxw-img" data-ratio="0.4004237288135593" data-type="png" data-w="944" style="width: 944px;height: 378px;" data-imgfileid="100001204"> </section> <p><span leaf="">切换到</span><span style="background-color: rgb(245, 247, 249);"><span leaf="">Graph</span></span><span leaf="">面板,用户可以使用PromQL表达式查询特定监控指标的监控数据。如下所示,查询主机负载变化情况,可以使用关键字</span><span style="background-color: rgb(245, 247, 249);"><span leaf="">node_load1</span></span><span leaf="">可以查询出Prometheus采集到的主机负载的样本数据,这些样本数据按照时间先后顺序展示,形成了主机负载随时间变化的趋势图表:</span></p> <section nodeleaf=""> <img src="/upload/9b387249811bcd27fc4123344cddc010.png" class="rich_pages wxw-img" data-ratio="0.6085889570552148" data-type="png" data-w="815" style="width: 815px;height: 496px;" data-imgfileid="100001205"> </section> <p><span leaf="">PromQL是Prometheus自定义的一套强大的数据查询语言,除了使用监控指标作为查询关键字以外,还内置了大量的函数,帮助用户进一步对时序数据进行处理。例如使用</span><span style="background-color: rgb(245, 247, 249);"><span leaf="">rate()</span></span><span leaf="">函数,可以计算在单位时间内样本数据的变化情况即增长率,因此通过该函数我们可以近似的通过CPU使用时间计算CPU的利用率:</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="css"><code><span leaf=""><span class="code-snippet__plaintext">rate(node_cpu</span><span class="code-snippet__selector-attr">[2m]</span><span class="code-snippet__plaintext">)</span></span></code></pre> </section> <section style="text-align: center;" nodeleaf=""> <img src="/upload/4f9f0f2f436078013c4e7a55b30347c9.png" class="rich_pages wxw-img" data-ratio="0.696360153256705" data-s="300,640" data-type="png" data-w="1044" type="block" data-imgfileid="100001206"> </section> <article data-content="[{" type:block,id:tlug-1701352889126,name:paragraph,data:{version:1},nodes:[{type:text,id:bkfp-1701352889125,leaves:[{text:这时如果要忽略是哪一个cpu的,只需要使用without表达式,将标签cpu去除后聚合数据即可:,marks:[]}]}],state:{}},{type:block,id:tsoe-1701352916447,name:code,data:{wrap:false,tokensperline:[],language:,theme:default},nodes:[{type:block,id:igeo-1701352916446,name:code-line,data:{},nodes:[{type:text,id:rsmt-1701352916445,leaves:[{text:avg without(cpu) (rate(node_cpu[2m])),marks:[]}]}]}],state:{}}]> <p><span leaf="">这时如果要忽略是哪一个CPU的,只需要使用without表达式,将标签CPU去除后聚合数据即可:</span></p> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="css"><code><span leaf=""><span class="code-snippet__plaintext">avg without(cpu) (rate(node_cpu</span><span class="code-snippet__selector-attr">[2m]</span><span class="code-snippet__plaintext">))</span></span></code></pre> </section> <section style="text-align: center;" nodeleaf=""> <img src="/upload/bbcfdf01937857e326eec6f3a949b423.png" class="rich_pages wxw-img" data-ratio="0.5139289145052833" data-s="300,640" data-type="png" data-w="1041" type="block" data-imgfileid="100001207"> </section> <article data-content="[{" type:block,id:jrxa-1701352889133,name:paragraph,data:{version:1},nodes:[{type:text,id:nqzd-1701352889132,leaves:[{text:那如果需要计算系统cpu的总体使用率,通过排除系统闲置的cpu使用率即可获得:,marks:[]}]}],state:{}},{type:block,id:1aek-1701352912190,name:code,data:{wrap:false,tokensperline:[],language:,theme:default},nodes:[{type:block,id:lkfe-1701352912189,name:code-line,data:{},nodes:[{type:text,id:dkac-1701352912188,leaves:[{text:1 - avg without(cpu) (rate(node_cpu{mode="\"idle\"}[2m]))","marks":[]}]}]}],"state":{}}]""> <p><span leaf="">那如果需要计算系统CPU的总体使用率,通过排除系统闲置的CPU使用率即可获得:</span></p> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="java"><code><span leaf=""><span class="code-snippet__number">1</span><span class="code-snippet__plaintext"> - avg </span><span class="code-snippet__title">without</span><span class="code-snippet__params">(cpu)</span><span class="code-snippet__plaintext"> (rate(node_cpu{mode=</span><span class="code-snippet__string">"idle"</span><span class="code-snippet__plaintext">}[2m]))</span></span></code></pre> </section> <section style="text-align: center;" nodeleaf=""> <img src="/upload/61927cdefeceee6a3c47fa98c9d1a46e.png" class="rich_pages wxw-img" data-ratio="0.47439613526570046" data-s="300,640" data-type="png" data-w="1035" type="block" data-imgfileid="100001208"> </section> <article data-content="[{" type:block,id:reoz-1701352889140,name:paragraph,data:{version:1},nodes:[{type:text,id:bdbp-1701352889139,leaves:[{text:通过promql我们可以非常方便的对数据进行查询,过滤,以及聚合,计算等操作。通过这些丰富的表达书语句,监控指标不再是一个单独存在的个体,而是一个个能够表达出正式业务含义的语言。,marks:[]}]}],state:{}},{type:block,id:cl7c-1701352969556,name:heading,data:{level:h2},nodes:[{type:text,id:4gcw-1701352969555,leaves:[{text:2.4 任务和实例,marks:[]}]}],state:{}},{type:block,id:7jha-1701387631780,name:paragraph,data:{version:1},nodes:[{type:text,id:zjxb-1701387631779,leaves:[{text:通过在prometheus.yml配置文件中,添加如下配置。我们让prometheus可以从node exporter暴露的服务中获取监控指标数据。,marks:[]}]}],state:{}}]> <p><span leaf="">通过PromQL我们可以非常方便地对数据进行查询,过滤,以及聚合,计算等操作。通过这些丰富的表达书语句,监控指标不再是一个单独存在的个体,而是一个个能够表达出正式业务含义的语言。</span></p> <p><span style="font-weight: bold;font-size: 20px;"><span leaf=""><br></span></span></p> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">2.4 任务和实例</span></span></p> <p><span leaf="">通过在prometheus.yml配置文件中,添加如下配置。我们让Prometheus可以从node exporter暴露的服务中获取监控指标数据。</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="javascript"><code><span leaf=""><span class="code-snippet__attr">scrape_configs</span><span class="code-snippet__plaintext">:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - </span><span class="code-snippet__attr">job_name</span><span class="code-snippet__plaintext">: </span><span class="code-snippet__string">'prometheus'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__attr">static_configs</span><span class="code-snippet__plaintext">:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - </span><span class="code-snippet__attr">targets</span><span class="code-snippet__plaintext">: [</span><span class="code-snippet__string">'localhost:9090'</span><span class="code-snippet__plaintext">]</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - </span><span class="code-snippet__attr">job_name</span><span class="code-snippet__plaintext">: </span><span class="code-snippet__string">'node'</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> </span><span class="code-snippet__attr">static_configs</span><span class="code-snippet__plaintext">:</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> - </span><span class="code-snippet__attr">targets</span><span class="code-snippet__plaintext">: [</span><span class="code-snippet__string">'localhost:9100'</span><span class="code-snippet__plaintext">]</span></span></code></pre> </section> <p><span leaf=""><br></span></p> </article> <article data-content="[{" type:block,id:bqqx-1701387631797,name:paragraph,data:{version:1},nodes:[{type:text,id:tfzv-1701387631796,leaves:[{text:当我们需要采集不同的监控指标(例如:主机、mysql、nginx)时,我们只需要运行相应的监控采集程序,并且让prometheus server知道这些exporter实例的访问地址。在prometheus中,每一个暴露监控样本数据的http服务称为一个实例。例如在当前主机上运行的node exporter可以被称为一个实例(instance)。,marks:[]}]}],state:{}},{type:block,id:bmqk-1701387631799,name:paragraph,data:{version:1},nodes:[{type:text,id:ypnp-1701387631798,leaves:[{text:而一组用于相同采集目的的实例,或者同一个采集进程的多个副本则通过一个一个任务(job)进行管理。,marks:[]}]}],state:{}}]> <p><span leaf="">当我们需要采集不同的监控指标(例如:主机、MySQL、Nginx)时,我们只需要运行相应的监控采集程序,并且让Prometheus Server知道这些Exporter实例的访问地址。在Prometheus中,每一个暴露监控样本数据的HTTP服务称为一个实例。例如在当前主机上运行的node exporter可以被称为一个实例(Instance)。</span></p> <p><span leaf="">而一组用于相同采集目的的实例,或者同一个采集进程的多个副本则通过一个一个任务(Job)进行管理。</span></p> </article> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang=""><code><span leaf=""><span class="code-snippet__plaintext">* job: node</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> * instance 2: 1.2.3.4:9100</span></span></code><code><span leaf=""><span class="code-snippet__plaintext"> * instance 4: 5.6.7.8:9100</span></span></code></pre> </section> <p><span leaf=""><br></span></p> </article> <article> <p><span leaf="">当前在每一个Job中主要使用了静态配置(static_configs)的方式定义监控目标。除了静态配置每一个Job的采集Instance地址以外,Prometheus还支持与DNS、Consul、E2C、Kubernetes等进行集成实现自动发现Instance实例,并从这些Instance上获取监控数据。</span></p> <p><span leaf="">除了通过使用“up”表达式查询当前所有Instance的状态以外,还可以通过Prometheus UI中的Targets页面查看当前所有的监控采集任务,以及各个任务下所有实例的状态:</span></p> <section nodeleaf=""> <img src="/upload/e35abe063d71bf519981925a50005278.png" class="rich_pages wxw-img" data-ratio="0.1361111111111111" data-type="png" data-w="1080" style="width: 1919px;height: 262px;" data-imgfileid="100001210"> </section> <p><span leaf="">我们也可以访问</span><span style="color: rgb(0, 56, 132);"><span leaf="">http://192.168.33.10:9090/targets</span></span><span leaf="">直接从Prometheus的UI中查看当前所有的任务以及每个任务对应的实例信息。</span></p> <section nodeleaf=""> <img src="/upload/eec6cb144e16d8e84b2053183f8ccde3.png" class="rich_pages wxw-img" data-ratio="0.3882017126546147" data-type="png" data-w="1051" style="width: 1051px;height: 408px;" data-imgfileid="100001209"> </section> <p><span style="font-weight: bold;font-size: 20px;"><span leaf="">2.5 监控数据可视化</span></span></p> <p><span leaf="">Prometheus UI提供了快速验证PromQL以及临时可视化支持的能力,而在大多数场景下引入监控系统通常还需要构建可以长期使用的监控数据可视化面板(Dashboard)。这时用户可以考虑使用第三方的可视化工具如Grafana,Grafana是一个开源的可视化平台,并且提供了对Prometheus的完整支持。</span></p> <p><span style="font-weight: bold;font-size: inherit;"><span leaf="">安装</span></span><span style="font-weight: bold;color: rgb(18, 18, 18);background-color: rgb(255, 255, 255);font-size: inherit;"><span leaf="">Grafana</span></span></p> <p><span style="color: rgb(0, 56, 132);"><span leaf="">https://grafana.com/grafana/download?pg=graf&plcmt=deploy-box-1</span></span></p> <section class="code-snippet__fix code-snippet__js"> <ul class="code-snippet__line-index code-snippet__js"> </ul> <pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__plaintext">docker run -d -p 3000:3000 grafana/grafana</span></span></code></pre> </section> <p><span leaf=""><br></span></p> <p><span leaf="">访问</span><span style="color: rgb(57, 197, 127);"><span leaf="">http://localhost:3000</span></span><span leaf="">就可以进入到Grafana的界面中,默认情况下使用账户admin/admin进行登录。在Grafana首页中显示默认的使用向导,包括:安装、添加数据源、创建Dashboard、邀请成员、以及安装应用和插件等主要流程:</span></p> <section nodeleaf=""> <img src="/upload/af92213a5bcc680926637140cb3eea71.png" class="rich_pages wxw-img" data-ratio="0.26944444444444443" data-type="png" data-w="1080" style="width: 1878px;height: 506px;" data-imgfileid="100001211"> </section> <p><span leaf="">这里将添加Prometheus作为默认的数据源,如下图所示,指定数据源类型为Prometheus并且设置Prometheus的访问地址即可,在配置正确的情况下点击“Add”按钮,会提示连接成功的信息:</span></p> <section nodeleaf=""> <img src="/upload/15967b060988a2286d9d3080e14b8b91.png" class="rich_pages wxw-img" data-ratio="0.71964461994077" data-type="png" data-w="1013" style="width: 1013px;height: 729px;" data-imgfileid="100001212"> </section> <p><span leaf="">在完成数据源的添加之后就可以在Grafana中创建我们可视化Dashboard了。Grafana提供了对PromQL的完整支持,如下所示,通过Grafana添加Dashboard并且为该Dashboard添加一个类型为“Graph”的面板。 并在该面板的“Metrics”选项下通过PromQL查询需要可视化的数据:</span></p> <section nodeleaf=""> <img src="/upload/1c19629598e2d068994a9fada4c9a029.png" class="rich_pages wxw-img" data-ratio="0.5416666666666666" data-type="png" data-w="1080" style="width: 1473px;height: 798px;" data-imgfileid="100001213"> </section> <p><span leaf="">点击界面中的保存选项,就创建了我们的第一个可视化Dashboard了。 当然作为开源软件,Grafana社区鼓励用户分享Dashboard通过</span><span style="color: rgb(57, 197, 127);"><span leaf="">https://grafana.com/dashboards</span></span><span leaf="">网站,可以找到大量可直接使用的Dashboard:</span></p> <section nodeleaf=""> <img src="/upload/faf7f616de3220f6a0ee3b4599211f2a.png" class="rich_pages wxw-img" data-ratio="0.5851851851851851" data-type="png" data-w="1080" style="width: 1233px;height: 721px;" data-imgfileid="100001215"> </section> <p><span leaf="">Grafana中所有的Dashboard通过JSON进行共享,下载并且导入这些JSON文件,就可以直接使用这些已经定义好的Dashboard:</span></p> <section nodeleaf=""> <img src="/upload/178929e0b5081a26778ec48216a8310e.png" class="rich_pages wxw-img" data-ratio="0.5064814814814815" data-type="png" data-w="1080" style="width: 1250px;height: 633px;" data-imgfileid="100001214"> </section> </article> <section> <span leaf=""><br></span> </section> <section class="mp_profile_iframe_wrp" nodeleaf=""> <mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="Fox爱分享" data-alias="dcl_yc" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/aSJ8tDK6zEtIJWnEiahMNNA6DNjiafUUzmichdKkWCFc9ibqGnymD5kYxiaH8ZpohgAXzTn2gLVHqDe4uqKwCYNakvw/0?wx_fmt=png" data-signature="分享微服务、中间件、消息队列、搜索引擎、分布式存储和高并发架构等方面的知识" data-id="MzU1ODk1NTQ0Mg==" data-is_biz_ban="0" data-service_type="1"></mp-common-profile> </section> <section> <span leaf=""><br></span> </section> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;text-align: left; data-mpa-powered-by="yiban.io"> <section class="mp_profile_iframe_wrp"> <mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-id="Mzg2NTc1NDM1MA==" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/qM9Jiat4uNGQibvG1jm9jUfdx6wOrhqp541OnRXwu2uLe2fGIZhZMtagg4SeBoAMe2W73dzHMkHAXMYOg3Q43Tfw/0?wx_fmt=png" data-nickname="编程技术汇" data-alias="" data-signature="汇总最实用的,最有趣的,最新鲜的热门技术。" data-from="0" data-is_biz_ban="0" data-service_type="1"></mp-common-profile> </section> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_jpg pmzoeonjxwc5p16tqysanspnkbrxfxxfqzjf2xcbjibnwrswd6iciajlnr8lhjoqg8nhwqaido8ow6kizvibyvc0yq 640?wx_fmt="other&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 75px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none none solid;border-width: 1px 1px 2px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(46, 121, 80);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">引言</span><span style="display: none;"></span></h1> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">大家好,我是苏三,最近在做系统设计的时候,发现要画不少时序图,以前我用的最顺手的工具是draw.io,后来也尝试了语雀自带的画图工具,感觉画画简单的图还行,但是复杂一点的,就比较吃力了。<img class="rich_pages wxw-img" data-imgfileid="100012106" data-ratio="0.6231481481481481" src="/upload/ff87ceb3bf3373e7ba337ad3765e0f47.png" data-type="png" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;">哎,这条线怎么又歪了?布局怎么又乱了?这个条怎么又对不齐了?……手忙脚乱才画好一张图,这时候我就想,有没有其它更专业的画图工具呢?大部分同事都在用Visio,辉哥给我推荐了PlantUML,说非常好用!这时候旁边来了一句—— “他就是装比!”</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012105" data-ratio="0.6866666666666666" src="/upload/1c076c802a01ffdf3089355bc706ccb4.png" data-type="gif" data-w="150" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 装比带我一个 </figcaption> </figure> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;"><span style="color: rgb(63, 63, 63);font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;letter-spacing: 0.32px;text-align: left;text-wrap: wrap;> 还有这样的事?</span><span style="color: rgb(63, 63, 63);font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;letter-spacing: 0.32px;text-align: left;text-wrap: wrap;>那我不能让他一个人都装了。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">最开始看下官方文档,发现PlantUML类似MarkDown,似乎需要一点学习成本,简单用了一下,曲线还是挺平缓的,上手相当快!推荐大家也用一下试试。</p> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_jpg pmzoeonjxwc5p16tqysanspnkbrxfxxfqzjf2xcbjibnwrswd6iciajlnr8lhjoqg8nhwqaido8ow6kizvibyvc0yq 640?wx_fmt="other&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 75px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none none solid;border-width: 1px 1px 2px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(46, 121, 80);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">一、什么是PlantUML?</span><span style="display: none;"></span></h1> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;border-top: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(53, 179, 120);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(251, 249, 253);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <span style="display: none;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;"></span> <p style="text-indent: 0em;padding-top: 16px;padding-bottom: 8px;color: rgb(63, 63, 63);font-size: 16px;line-height: 1.8em;letter-spacing: 0.02em;"><strong style="color: rgb(74, 74, 74);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">PlantUML</strong>是一个多功能组件,可快速、直接地创建图表。用户可以使用简单直观的语言起草各种图表。</p> </blockquote> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">PlantUML是一个开源工具,它允许我们用简单的文本描述来创建UML图,包括序列图、用例图、类图、对象图、活动图、组件图、部署图、状态图,以及我们今天要讲的时序图。<img class="rich_pages wxw-img" data-imgfileid="100012104" data-ratio="0.4715909090909091" src="/upload/309b78c467ee86c76f8c221c9c90d7d7.png" data-type="png" data-w="1056" style="display: block;margin-right: auto;margin-left: auto;">除了UML图之外,PlantUML 还支持一系列其他图表,例如JSON数据、YAML数据、EBNF图表、架构图等等。PlantUML的一大优势,是图表完全用文本代码描述,这就意味着它可以作为文档嵌入到源代码中,也非常方便版本控制和多人协作,不管是迭代设计、文档编写、系统建模,PlantUML都能胜任。</p> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_jpg pmzoeonjxwc5p16tqysanspnkbrxfxxfqzjf2xcbjibnwrswd6iciajlnr8lhjoqg8nhwqaido8ow6kizvibyvc0yq 640?wx_fmt="other&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 75px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none none solid;border-width: 1px 1px 2px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(46, 121, 80);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">二、快速入门</span><span style="display: none;"></span></h1> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">PlantUML插件</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">为了便捷地使用PlantUML,许多流行的IDE和代码编辑器提供了集成PlantUML的插件,如Visual Studio Code、IntelliJ IDEA、Eclipse等。插件提供了实时预览、语法高亮和图表导出等功能,能帮助我们更快捷,更高效地画图,整体上IDEA的插件用起来体验最好,但是IDEA大家懂的,太占内存了,VS Code相对而言,用起来就会轻量很多。</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> <p style="line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">IntelliJ IDEA:比如 "PlantUML integration" 可以让我们直接在 IDE 中查看和编辑 PlantUML 图表</p> <figure style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012107" data-ratio="0.737037037037037" src="/upload/f67cb608f92c4530eaf5d8c179c4cb7b.png" data-type="png" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> PlantUML integration </figcaption> </figure> </section></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 插件使用效果 </section></li> </ul> </ul> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012108" data-ratio="0.46111111111111114" src="/upload/3d9f16dac8931a7db574014f7633f677.png" data-type="png" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> image.png </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> VS Code:https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml </section></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 插件市场: </section></li> </ul> </ul> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012112" data-ratio="0.6981481481481482" src="/upload/3f000d36c8b05d5e9f4591c8a8561329.png" data-type="png" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> image.png </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 插件使用效果: </section></li> </ul> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012113" data-ratio="0.5537037037037037" src="/upload/2dac24f33630e93aa83ff4ac2e0121de.png" data-type="png" data-w="1080" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> image.png </figcaption> </figure> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">Hello World!</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">我们先来看个最简单的例子,通过<code style="color: rgb(40, 202, 113);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>-></code> 、<code style="color: rgb(40, 202, 113);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>--></code>和<code style="color: rgb(40, 202, 113);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;> :</code>就可以在参与者之间传递消息,不用明确声明参与者。</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>老张 -> 老王 : 老王,你好啊<br>老王--> 老张: 老张,你好啊<br><br>老张 -> 老王: 最近有空一起喝茶<br>老张 <-- 老王: OK<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012109" data-ratio="1.2377777777777779" src="/upload/7031b84b4b941faf897916f4384d5b98.png" data-type="png" data-w="450" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> hello </figcaption> </figure> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_jpg pmzoeonjxwc5p16tqysanspnkbrxfxxfqzjf2xcbjibnwrswd6iciajlnr8lhjoqg8nhwqaido8ow6kizvibyvc0yq 640?wx_fmt="other&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 75px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none none solid;border-width: 1px 1px 2px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(46, 121, 80);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">三、PlantUML时序图语法</span><span style="display: none;"></span></h1> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">接下来,我们看看PlantUML时序图的一些具体语法。</p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">声明参与者</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">我们使用关键字participant 来声明参与者,就可以对该参与者进行更多的控制。声明的顺序就是默认的<strong style="color: rgb(74, 74, 74);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">显示顺序</strong>。我们也可以用这些关键字来声明参与者,给参与者设置不同的形状。</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> actor(角色) </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> boundary(边界) </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> control(控制) </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> entity(实体) </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> database(数据库) </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> collections(集合) </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> queue(队列) </section></li> </ul> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">我们还可以通过 <code style="color: rgb(40, 202, 113);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>as</code>关键字重命名参与者。</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>participant Participant as Foo<br>actor Actor as Foo1<br>boundary Boundary as Foo2<br>control Control as Foo3<br>entity Entity as Foo4<br>database Database as Foo5<br>collections Collections as Foo6<br>queue Queue as Foo7<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012110" data-ratio="0.3225419664268585" src="/upload/297e0600ba7b1b74df24823626fc935d.png" data-type="png" data-w="834" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 参与者 </figcaption> </figure> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">默认的颜色比较单调,也可以通过<code style="color: rgb(40, 202, 113);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>#</code>来设置参与者的颜色:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>actor Bob #blue<br><span style="color: #98c379;line-height: 26px;">' The only difference between actor<br>'</span>and participant is the drawing<br>participant Alice #SkyBlue<br>participant <span style="color: #98c379;line-height: 26px;">"I have a really\nlong name"</span> as L #<span style="color: #d19a66;line-height: 26px;">00f</span>f00<br><br>Alice->Bob: Authentication Request<br>Bob->Alice: Authentication Response<br>Bob->L: Log transaction<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012111" data-ratio="0.8607038123167156" src="/upload/cb3fe7d790dda89c1766c13868b3659d.png" data-type="png" data-w="682" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 上颜色的参与者 </figcaption> </figure> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">消息传递</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">在不同参与者之间,通过箭头+:来表示消息传递。</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 同步消息: </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">A -> B: 同步消息文本<br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012115" data-ratio="0.9397163120567376" src="/upload/f25483af4ba1f4673aa1771832b96c0f.png" data-type="png" data-w="282" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 同步消息 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 异步消息:由发送者A指向接收者B,表示A发送后不需要等待B立即处理。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">A ->> B: 异步消息文本<br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012118" data-ratio="0.9408284023668639" src="/upload/a3b74cf0c49f24f66935f368cddf1bc3.png" data-type="png" data-w="338" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 异步消息 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 返回消息:通常从接收者返回到发送者,标识一个回应。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">A <-- B: 返回消息文本<br><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012114" data-ratio="0.9408284023668639" src="/upload/fdacd8718cd74973b92c5d215b6eb540.png" data-type="png" data-w="338" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 返回消息 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> <p style="line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">自调用:一个参与者直接发送消息给自己,表示自我处理或运算。</p> <pre style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;color: rgb(171, 178, 191);width: auto;margin-left: 2px;margin-right: 2px;padding: 15px 4px 2px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);word-break: break-all;background: rgb(40, 44, 52);display: -webkit-box;font-family: " operator mono, consolas, monaco, menlo, monospace;border-radius: 0px;font-size: 12px;>A ->A: 自调用<br></code></pre> <figure style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012117" data-ratio="2.0406976744186047" src="/upload/b139dc43cef7646d7004c800b1a840ef.png" data-type="png" data-w="172" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 自调用 </figcaption> </figure> </section></li> </ul> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">生命线(Lifeline)与激活条(Activation Bar)</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">在时序图中,生命线表示对象在一段时间内的活动状态,也就是从参与者往下延伸的那条虚线。激活条用来表示参与者或对象在处理某个任务期间的活动状态,是生命线的一部分,矩形条形式出现。</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 生命线的激活与撤销:可以用下面这些关键字来控制生命线的激活与撤销 </section></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> activate: 显示参与者的活动状态开始 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> deactivate: 指示参与者的活动状态结束。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> destroy: 用于表示参与者的生命线终结,通常表示对象生命周期的结束。 </section></li> </ul> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>participant User<br>User -> A: DoWork<br>activate A<br>A -> B: << createRequest >><br>activate B<br>B -> C: DoWork<br>activate C<br>C --> B: WorkDone<br>destroy C<br>B --> A: RequestCreated<br>deactivate B<br>A -> User: Done<br>deactivate A<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012116" data-ratio="0.8515463917525773" src="/upload/c74387e681d903d2ff2526c17fae0bf2.png" data-type="png" data-w="485" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 生命线的激活与撤销 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 生命线的嵌套与颜色:我们还可以使用嵌套激活条来表示内部调用,并可以给生命线添加颜色。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>participant User<br>User -> A: DoWork<br>activate A #FFBBBB<br>A -> A: Internal call<br>activate A #DarkSalmon<br>A -> B: << createRequest >><br>activate B<br>B --> A: RequestCreated<br>deactivate B<br>deactivate A<br>A -> User: Done<br>deactivate A<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012122" data-ratio="1.088992974238876" src="/upload/604e66046aba4639d92f0cc693dd97db.png" data-type="png" data-w="427" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 生命线的嵌套与颜色 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 自动激活:在发送消息时自动显示激活条。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">A->B++: 激活B并发送消息<br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012120" data-ratio="0.8079268292682927" src="/upload/9e795f7d95d6d47f5785343fe21e8395.png" data-type="png" data-w="328" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 自动激活 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 自动去激活:在接收回应时自动隐藏激活条。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">A->B++: 激活B并发送消息<br>A <--B--: B去激活并回应消息<br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012124" data-ratio="0.9095890410958904" src="/upload/9f4defcf1a483d61662ea4eb3c146357.png" data-type="png" data-w="365" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 自动去激活 </figcaption> </figure> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">分组和替代</span><span style="display: none;"></span></h2> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 分组:用于逻辑上分组一系列交互。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">group 分组名<br>A -> B: 消息<br>...<br>end group<br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012121" data-ratio="1.7433628318584071" src="/upload/e7100f2cfd0d21132a6aa6d7b66cec7e.png" data-type="png" data-w="226" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 分组 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 替代(Alt/Else):表示基于条件的替代执行流程。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;">alt 条件<span style="color: #d19a66;line-height: 26px;">1</span><br>A -> B: 满足条件<span style="color: #d19a66;line-height: 26px;">1</span>的消息<br><span style="color: #c678dd;line-height: 26px;">else</span> 条件<span style="color: #d19a66;line-height: 26px;">2</span><br>A -> B: 满足条件<span style="color: #d19a66;line-height: 26px;">2</span>的消息<br>end<br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012123" data-ratio="1.1624203821656052" src="/upload/5fca183fc5a2d4f0e86c24b6c9434b45.png" data-type="png" data-w="314" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 替代 </figcaption> </figure> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">注释</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">注释用于添加说明性文本。</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 可以用note left of,note right of或note over来控制注释相对节点的位置,还可以通过修改背景色来高亮显示注释。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>participant Alice<br>participant Bob<br>note left of Alice #aqua<br>This is displayed<br>left of Alice.<br>end note<br><br>note right of Alice: This is displayed right of Alice.<br><br>note over Alice: This is displayed over Alice.<br><br>note over Alice, Bob #FFAAAA: This is displayed\n over Bob and Alice.<br><br>note over Bob, Alice<br>This is yet another<br>example of<br>a <span style="color: #c678dd;line-height: 26px;">long</span> note.<br>end note<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012128" data-ratio="1.055441478439425" src="/upload/85fa9596bc9fe5d3ade903f06596066a.png" data-type="png" data-w="487" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 注释 </figcaption> </figure> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_png pmzoeonjxwc5p16tqysanspnkbrxfxxfh0iaicjh4eraszazhu0qdcliaibiaib5o7rqxib2tnmlej1x74xjyyonrdk9a 640?wx_fmt="png&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 63px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">颜色</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">Choosing colors在 PlantUML 中,我们可以对时序图的各个元素自定义颜色,比如参与者(actors)、对象(objects)、激活条(activation bars)等,来让我们的时序图更加美观。在声明元素时,可以直接指定颜色,格式为#颜色代码。颜色代码可以是不同的形式:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 直接指定颜色:颜色代码可以是一个十六进制颜色值,也可以是预定义的颜色名称。 </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>actor 用户 #Green<br>participant 参与者 #B4A7E5<br><br>用户-[#red]>参与者:消息<br>activate 参与者 #Blue<br><br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012125" data-ratio="1.9739130434782608" src="/upload/44f17b8e66ed9c747c0815e9dc0c7e64.png" data-type="png" data-w="230" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 直接指定颜色 </figcaption> </figure> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 使用 <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>skinparam</code> 设置颜色:除了直接为特定元素指定颜色外,还可以使用 <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>skinparam</code> 全局设置时序图中的颜色。用这种方式更改元素的默认颜色比较方便: </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>skinparam ActorBorderColor #DarkOrange<br>skinparam ParticipantBackgroundColor #SkyBlue<br><br>actor 用户<br>participant 参与者<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012127" data-ratio="1.6869565217391305" src="/upload/05d2d28b9266bdc76217160a91f84a2b.png" data-type="png" data-w="230" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 使用 <code>skinparam</code> 设置颜色 </figcaption> </figure> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">当使用 <code style="color: rgb(40, 202, 113);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>skinparam</code> 时,我们可以设置许多不同属性的颜色,如边框颜色(BorderColor)、背景颜色(BackgroundColor)、字体颜色(FontColor)和激活条颜色(SequenceGroupBodyBackgroundColor)。更多语法可以直接查看官方文档:顺序图的语法和功能,目前这些内容,已经足够我们常见的时序图需求了。</p> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_jpg pmzoeonjxwc5p16tqysanspnkbrxfxxfqzjf2xcbjibnwrswd6iciajlnr8lhjoqg8nhwqaido8ow6kizvibyvc0yq 640?wx_fmt="other&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 75px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none none solid;border-width: 1px 1px 2px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(46, 121, 80);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">四、完整实例</span><span style="display: none;"></span></h1> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">我们接下来看一个稍微完整一点的例子,在这个例子中,我们的需求,是要在原本的登录的基础上,引入Google登录。</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg iahdqiccc5vbskyvchl3yzerhnm8cv0eribia6kxszvzrfthxrcn46sxzylwhefibb5fp8bicgummdghws2e8cur8qzy02zdldnaria 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@startuml</span><br>skinparam ParticipantBackgroundColor #DeepSkyBlue<br><br>actor 用户 as c #DeepSkyBlue<br>participant <span style="color: #98c379;line-height: 26px;">"客户端"</span> as client<br>participant <span style="color: #98c379;line-height: 26px;">"服务网关"</span> as ga<br>participant <span style="color: #98c379;line-height: 26px;">"用户服务"</span> as user<br>database <span style="color: #98c379;line-height: 26px;">"数据库"</span> as DB #DeepSkyBlue<br>participant <span style="color: #98c379;line-height: 26px;">"Google服务"</span> as google #LightCoral<br><br>activate c #DeepSkyBlue<br>activate client #DeepSkyBlue<br><br>c->client:用户登录<br><br>group#LightCoral #LightCoral Google登录客户端流程<br> client -> google : 请求Google OAuth登录<br> activate google #DeepSkyBlue<br> google-->client:登录url<br> client->google:跳转登录页<br> google -> google : 用户登录<br> google --> client : Google登录Token<br> deactivate google<br>end<br><br>|||<br><br>client -> ga : 登录请求<br>note right#LightCoral:新增登录方式,三方登录请求实体<br>activate ga #DeepSkyBlue<br>ga ->user:请求转发<br>activate user #DeepSkyBlue<br><br><br>alt#DeepSkyBlue 常规登录<br> user -> DB : 查询用户信息<br> activate DB #DeepSkyBlue<br> DB -> user : 用户信息<br> deactivate DB<br> user->user:登录密码校验<br><br>|||<br><span style="color: #c678dd;line-height: 26px;">else</span> Google登录<br> group#LightCoral #LightCoral Google登录服务端流程<br> user->google:验证token<br> activate google #DeepSkyBlue<br> google-->user:用户信息<br> deactivate google<br> user->user:存储或更新用户信息<br> end group<br>end<br><br><br>user-->ga:登录结果<br>deactivate user<br>ga -> client : 响应<br>deactivate ga<br>alt#DeepSkyBlue 成功<br> client -> c : 登录成功<br><span style="color: #c678dd;line-height: 26px;">else</span> 失败<br> client -> c : 登录失败<br>end<br>deactivate client<br>|||<br><span style="color: #61aeee;line-height: 26px;">@enduml</span><br><br><br></code></pre> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100012129" data-ratio="1.7737512242899118" src="/upload/d35a0f3d54b426c0500f40eb0cf93576.png" data-type="png" data-w="1021" style="display: block;margin-right: auto;margin-left: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;margin-top: 5px;"> 登录时序图 </figcaption> </figure> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;background-attachment: scroll;background-clip: border-box;background-image: url(" https: mmbiz.qpic.cn mmbiz_jpg pmzoeonjxwc5p16tqysanspnkbrxfxxfqzjf2xcbjibnwrswd6iciajlnr8lhjoqg8nhwqaido8ow6kizvibyvc0yq 640?wx_fmt="other&from=appmsg");background-origin:" padding-box;background-position: 50% 50%;background-repeat: no-repeat;background-size: 75px;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;-webkit-box-reflect: unset;><span style="display: none;"></span><span style="font-size: 18px;color: rgb(72, 179, 120);line-height: 2.4em;letter-spacing: 0em;margin-top: 38px;margin-bottom: 10px;border-style: none none solid;border-width: 1px 1px 2px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(46, 121, 80);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: 38px;justify-content: unset;overflow: unset;text-align: center;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">五、总结</span><span style="display: none;"></span></h1> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">PlantUML使用起来整体上还是非常舒服的,对我而言,这几个特点让我爱不释手:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 提供了类似MarkDown的所见即所得的使用体验,免去调整图形之扰 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> PlantUML本质是文本,可以进行版本控制,多人协同 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;"> 语雀支持文本画图的功能,可以嵌入PlantUML文本,支持在语雀文档里直接修改 </section></li> </ul> <p data-tool="mdnice编辑器" style="color: rgb(63, 63, 63);line-height: 1.8em;letter-spacing: 0.02em;text-indent: 0em;padding-top: 16px;padding-bottom: 8px;">PlantUML还有很强大的扩展性和灵活性,我们可以通过 官方文档: 继续探索更多高级语法和技巧,来绘制更加复杂和丰富的图表。</p> </section>
作者:微信小助手
<p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100001698" data-ratio="0.4824074074074074" src="/upload/fdfd35bad242aba56054e46675508095.png" data-type="gif" data-w="1080" style=""></p> <section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;text-align: left;> <p data-tool="mdnice编辑器" style="font-size: 15px;line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">源代码</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg 6xfhg7ldobw4uipyhotly9hu7ddcypicicy3iahmtvibv9ricdcelainrav1nwajwbb7x9smjqh5ibicfjz4nyramgziaqw0ielc54 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">html</span>><br><span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">html</span> <span style="color: #d19a66;line-height: 26px;">lang</span>=<span style="color: #98c379;line-height: 26px;">"en"</span>></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">head</span>></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">meta</span> <span style="color: #d19a66;line-height: 26px;">charset</span>=<span style="color: #98c379;line-height: 26px;">"UTF-8"</span> /></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">title</span>></span>就决定是你了,皮卡丘!<span style="line-height: 26px;"><!--/<span style="color: #e06c75;line-height: 26px;"-->title</span>><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">link</span><br> <span style="color: #d19a66;line-height: 26px;">rel</span>=<span style="color: #98c379;line-height: 26px;">"stylesheet"</span><br> <span style="color: #d19a66;line-height: 26px;">href</span>=<span style="color: #98c379;line-height: 26px;">"https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"</span><br> /></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">link</span><br> <span style="color: #d19a66;line-height: 26px;">rel</span>=<span style="color: #98c379;line-height: 26px;">"stylesheet"</span><br> <span style="color: #d19a66;line-height: 26px;">href</span>=<span style="color: #98c379;line-height: 26px;">"https://fonts.googleapis.com/css?family=Heebo:100,300,400,500,700,800,900"</span><br> /></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">style</span>></span><span style="line-height: 26px;"><br> <span style="color: #d19a66;line-height: 26px;">.arrow</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">0</span>;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">50%</span>;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">36px</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">36px</span>;<span style="color: #98c379;line-height: 26px;">-webkit-animation</span>:boing <span style="color: #d19a66;line-height: 26px;">0.8s</span> ease infinite;<span style="color: #98c379;line-height: 26px;">animation</span>:boing <span style="color: #d19a66;line-height: 26px;">0.8s</span> ease infinite;<span style="color: #98c379;line-height: 26px;">transform-origin</span>:right center;<span style="color: #98c379;line-height: 26px;">pointer-events</span>:none;}<span style="color: #d19a66;line-height: 26px;">.arrow</span> <span style="color: #e06c75;line-height: 26px;">svg</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">36px</span>;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">0</span>;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">0</span>;<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">drop-shadow</span>(<span style="color: #d19a66;line-height: 26px;">0px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> rgba(<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0.4</span>));<span style="color: #98c379;line-height: 26px;">-webkit-animation</span>:smoosh <span style="color: #d19a66;line-height: 26px;">0.7s</span> ease infinite;<span style="color: #98c379;line-height: 26px;">animation</span>:smoosh <span style="color: #d19a66;line-height: 26px;">0.7s</span> ease infinite;}<span style="color: #d19a66;line-height: 26px;">.pokes</span>{<span style="color: #98c379;line-height: 26px;">display</span>:flex;<span style="color: #98c379;line-height: 26px;">flex</span>:wrap;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">100%</span>;<span style="color: #98c379;line-height: 26px;">justify-content</span>:center;<span style="color: #98c379;line-height: 26px;">margin-bottom</span>:<span style="color: #d19a66;line-height: 26px;">30px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span>{<span style="color: #98c379;line-height: 26px;">text-align</span>:center;<span style="color: #98c379;line-height: 26px;">position</span>:relative;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">180px</span>;<span style="color: #98c379;line-height: 26px;">min-width</span>:<span style="color: #d19a66;line-height: 26px;">150px</span>;<span style="color: #98c379;line-height: 26px;">margin</span>:<span style="color: #d19a66;line-height: 26px;">20px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> *{<span style="color: #98c379;line-height: 26px;">vertical-align</span>:middle;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #e06c75;line-height: 26px;">label</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">10px</span>;<span style="color: #98c379;line-height: 26px;">right</span>:<span style="color: #d19a66;line-height: 26px;">10px</span>;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">10px</span>;<span style="color: #98c379;line-height: 26px;">bottom</span>:<span style="color: #d19a66;line-height: 26px;">10px</span>;<span style="color: #98c379;line-height: 26px;">z-index</span>:<span style="color: #d19a66;line-height: 26px;">1</span>;<span style="color: #98c379;line-height: 26px;">cursor</span>:pointer;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.radio</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">opacity</span>:<span style="color: #d19a66;line-height: 26px;">0</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.lvl</span>{<span style="color: #98c379;line-height: 26px;">color</span>:<span style="color: #d19a66;line-height: 26px;">#00b8ff</span>;<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">14px</span>;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">12px</span>;<span style="color: #98c379;line-height: 26px;">font-weight</span>:<span style="color: #d19a66;line-height: 26px;">400</span>;<span style="color: #98c379;line-height: 26px;">font-size</span>:<span style="color: #d19a66;line-height: 26px;">18px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.sex</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">right</span>:<span style="color: #d19a66;line-height: 26px;">14px</span>;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">11px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.sex</span> <span style="color: #d19a66;line-height: 26px;">.icon</span>{<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">18px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.sex</span> <span style="color: #d19a66;line-height: 26px;">.icon</span><span style="color: #d19a66;line-height: 26px;">.female</span>{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">rotate</span>(-<span style="color: #d19a66;line-height: 26px;">45deg</span>);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.sprite</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">35%</span>;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">50%</span>;<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translate</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>,-<span style="color: #d19a66;line-height: 26px;">50%</span>);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">65%</span>;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">0</span>;<span style="color: #98c379;line-height: 26px;">right</span>:<span style="color: #d19a66;line-height: 26px;">0</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.name</span>{<span style="color: #98c379;line-height: 26px;">font-size</span>:<span style="color: #d19a66;line-height: 26px;">20px</span>;<span style="color: #98c379;line-height: 26px;">font-weight</span>:<span style="color: #d19a66;line-height: 26px;">400</span>;<span style="color: #98c379;line-height: 26px;">color</span>:<span style="color: #d19a66;line-height: 26px;">#222</span>;<span style="color: #98c379;line-height: 26px;">margin</span>:<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">0</span>;<span style="color: #98c379;line-height: 26px;">display</span>:inline-block;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.hp</span>{<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">60%</span>;<span style="color: #98c379;line-height: 26px;">margin</span>:auto;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.hp</span> <span style="color: #d19a66;line-height: 26px;">.text</span>{<span style="color: #98c379;line-height: 26px;">color</span>:<span style="color: #d19a66;line-height: 26px;">#666</span>;<span style="color: #98c379;line-height: 26px;">display</span>:inline-block;<span style="color: #98c379;line-height: 26px;">padding-top</span>:<span style="color: #d19a66;line-height: 26px;">4px</span>;<span style="color: #98c379;line-height: 26px;">font-size</span>:<span style="color: #d19a66;line-height: 26px;">14px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.hp</span> <span style="color: #d19a66;line-height: 26px;">.bar</span>{<span style="color: #98c379;line-height: 26px;">border-radius</span>:<span style="color: #d19a66;line-height: 26px;">50px</span>;<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #d19a66;line-height: 26px;">#073fa7</span>;<span style="color: #98c379;line-height: 26px;">border</span>:<span style="color: #d19a66;line-height: 26px;">3.5px</span> solid <span style="color: #d19a66;line-height: 26px;">#00a3e2</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">11px</span>;<span style="color: #98c379;line-height: 26px;">overflow</span>:hidden;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.hp</span> <span style="color: #d19a66;line-height: 26px;">.bar</span> <span style="color: #d19a66;line-height: 26px;">.health</span>{<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">50%</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">100%</span>;<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #e6c07b;line-height: 26px;">linear-gradient</span>(to right,lime,#<span style="color: #d19a66;line-height: 26px;">8</span>bf500);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.hp</span> <span style="color: #d19a66;line-height: 26px;">.bar</span> <span style="color: #d19a66;line-height: 26px;">.health</span><span style="color: #d19a66;line-height: 26px;">.low</span>{<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #e6c07b;line-height: 26px;">linear-gradient</span>(to right,#ffcc00,#f1f500);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.details</span> <span style="color: #d19a66;line-height: 26px;">.hp</span> <span style="color: #d19a66;line-height: 26px;">.bar</span> <span style="color: #d19a66;line-height: 26px;">.health</span><span style="color: #d19a66;line-height: 26px;">.critical</span>{<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #e6c07b;line-height: 26px;">linear-gradient</span>(to right,#d20000,#f51700);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.pokeball</span>{<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">fill</span>:white;<span style="color: #98c379;line-height: 26px;">opacity</span>:<span style="color: #d19a66;line-height: 26px;">0.5</span>;<span style="color: #98c379;line-height: 26px;">transition</span>:all <span style="color: #d19a66;line-height: 26px;">0.5s</span> ease;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">76%</span>;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">12%</span>;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">47%</span>;<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.cell</span>{<span style="color: #98c379;line-height: 26px;">transition</span>:all <span style="color: #d19a66;line-height: 26px;">0.2s</span> ease;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.cell</span> <span style="color: #d19a66;line-height: 26px;">.bg</span>{<span style="color: #98c379;line-height: 26px;">stroke</span>:<span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">0.5</span>);<span style="color: #98c379;line-height: 26px;">fill</span>:<span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">0.5</span>);<span style="color: #98c379;line-height: 26px;">transition</span>:all <span style="color: #d19a66;line-height: 26px;">1.15s</span> ease;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span> <span style="color: #d19a66;line-height: 26px;">.cell</span> <span style="color: #d19a66;line-height: 26px;">.stroke</span>{<span style="color: #98c379;line-height: 26px;">stroke</span>:white;<span style="color: #98c379;line-height: 26px;">stroke-width</span>:<span style="color: #d19a66;line-height: 26px;">4px</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span><span style="color: #d19a66;line-height: 26px;">:after</span>{<span style="color: #98c379;line-height: 26px;">content</span>:<span style="color: #98c379;line-height: 26px;">''</span>;<span style="color: #98c379;line-height: 26px;">display</span>:block;<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">7px</span>;<span style="color: #98c379;line-height: 26px;">right</span>:<span style="color: #d19a66;line-height: 26px;">7px</span>;<span style="color: #98c379;line-height: 26px;">bottom</span>:<span style="color: #d19a66;line-height: 26px;">2px</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">180px</span>;<span style="color: #98c379;line-height: 26px;">border-radius</span>:<span style="color: #d19a66;line-height: 26px;">100%</span> <span style="color: #d19a66;line-height: 26px;">100%</span> <span style="color: #d19a66;line-height: 26px;">70%</span> <span style="color: #d19a66;line-height: 26px;">70%</span>/<span style="color: #d19a66;line-height: 26px;">70%</span> <span style="color: #d19a66;line-height: 26px;">70%</span> <span style="color: #d19a66;line-height: 26px;">20%</span> <span style="color: #d19a66;line-height: 26px;">20%</span>;<span style="color: #98c379;line-height: 26px;">background</span>:transparent;<span style="color: #98c379;line-height: 26px;">box-shadow</span>:<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">20px</span> <span style="color: #d19a66;line-height: 26px;">30px</span> <span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0.1</span>);<span style="color: #98c379;line-height: 26px;">transition</span>:all <span style="color: #d19a66;line-height: 26px;">0.2s</span> ease;<span style="color: #98c379;line-height: 26px;">z-index</span>:-<span style="color: #d19a66;line-height: 26px;">2</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span><span style="color: #d19a66;line-height: 26px;">.selected</span><span style="color: #d19a66;line-height: 26px;">:after</span>{<span style="color: #98c379;line-height: 26px;">box-shadow</span>:<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">20px</span> <span style="color: #d19a66;line-height: 26px;">30px</span> <span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0.5</span>);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span><span style="color: #d19a66;line-height: 26px;">.selected</span> <span style="color: #d19a66;line-height: 26px;">.cell</span>{<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">drop-shadow</span>(<span style="color: #d19a66;line-height: 26px;">0px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> white);<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">scale</span>(<span style="color: #d19a66;line-height: 26px;">1.02</span>);}<span style="color: #d19a66;line-height: 26px;">.pokemon</span><span style="color: #d19a66;line-height: 26px;">.selected</span> <span style="color: #d19a66;line-height: 26px;">.cell</span> <span style="color: #d19a66;line-height: 26px;">.bg</span>{<span style="color: #98c379;line-height: 26px;">fill</span>:<span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">255</span>,<span style="color: #d19a66;line-height: 26px;">246</span>,<span style="color: #d19a66;line-height: 26px;">146</span>,<span style="color: #d19a66;line-height: 26px;">0.9</span>);<span style="color: #98c379;line-height: 26px;">fill</span>:<span style="color: #e6c07b;line-height: 26px;">url</span>(#bg-gradient-selected) <span style="color: #61aeee;line-height: 26px;">!important</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span><span style="color: #d19a66;line-height: 26px;">.selected</span> <span style="color: #d19a66;line-height: 26px;">.pokeball</span>{<span style="color: #98c379;line-height: 26px;">opacity</span>:<span style="color: #d19a66;line-height: 26px;">0.8</span>;}<span style="color: #d19a66;line-height: 26px;">.pokemon</span><span style="color: #d19a66;line-height: 26px;">.selected</span> <span style="color: #d19a66;line-height: 26px;">.sprite</span>{<span style="color: #98c379;line-height: 26px;">-webkit-animation</span>:bounce <span style="color: #d19a66;line-height: 26px;">0.8s</span> ease infinite;<span style="color: #98c379;line-height: 26px;">animation</span>:bounce <span style="color: #d19a66;line-height: 26px;">0.8s</span> ease infinite;}<span style="color: #d19a66;line-height: 26px;">.button</span>{<span style="color: #98c379;line-height: 26px;">position</span>:relative;<span style="color: #98c379;line-height: 26px;">background</span>:white;<span style="color: #98c379;line-height: 26px;">border</span>:<span style="color: #d19a66;line-height: 26px;">2px</span> solid <span style="color: #d19a66;line-height: 26px;">#ffc55b</span>;<span style="color: #98c379;line-height: 26px;">border-radius</span>:<span style="color: #d19a66;line-height: 26px;">10px</span>;<span style="color: #98c379;line-height: 26px;">min-height</span>:<span style="color: #d19a66;line-height: 26px;">30px</span>;<span style="color: #98c379;line-height: 26px;">vertical-align</span>:middle;<span style="color: #98c379;line-height: 26px;">padding</span>:<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">20px</span>;<span style="color: #98c379;line-height: 26px;">outline</span>:none <span style="color: #61aeee;line-height: 26px;">!important</span>;<span style="color: #98c379;line-height: 26px;">cursor</span>:pointer;<span style="color: #98c379;line-height: 26px;">font-size</span>:<span style="color: #d19a66;line-height: 26px;">18px</span>;}<span style="color: #d19a66;line-height: 26px;">.button</span><span style="color: #d19a66;line-height: 26px;">:after</span>{<span style="color: #98c379;line-height: 26px;">content</span>:<span style="color: #98c379;line-height: 26px;">''</span>;<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">left</span>:-<span style="color: #d19a66;line-height: 26px;">5px</span>;<span style="color: #98c379;line-height: 26px;">right</span>:-<span style="color: #d19a66;line-height: 26px;">5px</span>;<span style="color: #98c379;line-height: 26px;">top</span>:-<span style="color: #d19a66;line-height: 26px;">5px</span>;<span style="color: #98c379;line-height: 26px;">bottom</span>:-<span style="color: #d19a66;line-height: 26px;">5px</span>;<span style="color: #98c379;line-height: 26px;">background</span>:white;<span style="color: #98c379;line-height: 26px;">border-radius</span>:<span style="color: #d19a66;line-height: 26px;">13px</span>;<span style="color: #98c379;line-height: 26px;">z-index</span>:-<span style="color: #d19a66;line-height: 26px;">1</span>;<span style="color: #98c379;line-height: 26px;">box-shadow</span>:<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> -<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0.2</span>);}<span style="color: #d19a66;line-height: 26px;">.button</span><span style="color: #d19a66;line-height: 26px;">:hover</span>{<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #e6c07b;line-height: 26px;">linear-gradient</span>(to bottom,#ffd78e,#ffc55b);<span style="color: #98c379;line-height: 26px;">border-color</span>:white;}<span style="color: #d19a66;line-height: 26px;">.button</span><span style="color: #d19a66;line-height: 26px;">:hover</span><span style="color: #d19a66;line-height: 26px;">:after</span>{<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #e6c07b;line-height: 26px;">linear-gradient</span>(to bottom,#ffd78e,#ffc55b);<span style="color: #98c379;line-height: 26px;">box-shadow</span>:<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> white,<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#ffe9c1</span>,<span style="color: #d19a66;line-height: 26px;">0</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> -<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #e6c07b;line-height: 26px;">rgba</span>(<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0</span>,<span style="color: #d19a66;line-height: 26px;">0.2</span>);}<span style="color: #d19a66;line-height: 26px;">.candy</span>{<span style="color: #98c379;line-height: 26px;">display</span>:block;<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">52%</span>;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">55%</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">12px</span>;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">12px</span>;<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">scale</span>(<span style="color: #d19a66;line-height: 26px;">1</span>);<span style="color: #98c379;line-height: 26px;">margin</span>:<span style="color: #d19a66;line-height: 26px;">12px</span>;}<span style="color: #d19a66;line-height: 26px;">.candy</span><span style="color: #d19a66;line-height: 26px;">.mighty</span>{<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">hue-rotate</span>(<span style="color: #d19a66;line-height: 26px;">300deg</span>) <span style="color: #e6c07b;line-height: 26px;">saturate</span>(<span style="color: #d19a66;line-height: 26px;">2.2</span>);}<span style="color: #d19a66;line-height: 26px;">.candy</span><span style="color: #d19a66;line-height: 26px;">.smart</span>{<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">hue-rotate</span>(<span style="color: #d19a66;line-height: 26px;">200deg</span>) <span style="color: #e6c07b;line-height: 26px;">saturate</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">brightness</span>(<span style="color: #d19a66;line-height: 26px;">0.65</span>) <span style="color: #e6c07b;line-height: 26px;">contrast</span>(<span style="color: #d19a66;line-height: 26px;">3</span>);}<span style="color: #d19a66;line-height: 26px;">.candy</span><span style="color: #d19a66;line-height: 26px;">.tough</span>{<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">hue-rotate</span>(<span style="color: #d19a66;line-height: 26px;">170deg</span>) <span style="color: #e6c07b;line-height: 26px;">saturate</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">brightness</span>(<span style="color: #d19a66;line-height: 26px;">0.65</span>) <span style="color: #e6c07b;line-height: 26px;">contrast</span>(<span style="color: #d19a66;line-height: 26px;">3.1</span>);}<span style="color: #d19a66;line-height: 26px;">.candy</span><span style="color: #d19a66;line-height: 26px;">.courage</span>{<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">hue-rotate</span>(<span style="color: #d19a66;line-height: 26px;">40deg</span>) <span style="color: #e6c07b;line-height: 26px;">saturate</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">brightness</span>(<span style="color: #d19a66;line-height: 26px;">0.8</span>) <span style="color: #e6c07b;line-height: 26px;">contrast</span>(<span style="color: #d19a66;line-height: 26px;">2</span>);}<span style="color: #d19a66;line-height: 26px;">.candy</span><span style="color: #d19a66;line-height: 26px;">.quick</span>{<span style="color: #98c379;line-height: 26px;">filter</span>:<span style="color: #e6c07b;line-height: 26px;">hue-rotate</span>(<span style="color: #d19a66;line-height: 26px;">140deg</span>) <span style="color: #e6c07b;line-height: 26px;">saturate</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">brightness</span>(<span style="color: #d19a66;line-height: 26px;">0.8</span>) <span style="color: #e6c07b;line-height: 26px;">contrast</span>(<span style="color: #d19a66;line-height: 26px;">1.8</span>);}<span style="color: #d19a66;line-height: 26px;">.candy</span><span style="color: #d19a66;line-height: 26px;">:after</span>{<span style="color: #98c379;line-height: 26px;">content</span>:<span style="color: #98c379;line-height: 26px;">''</span>;<span style="color: #98c379;line-height: 26px;">display</span>:block;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">1px</span>;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">1px</span>;<span style="color: #98c379;line-height: 26px;">box-shadow</span>:<span style="color: #d19a66;line-height: 26px;">0px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">0px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">0px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#fff6e6</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#fff6e6</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#fff6e6</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#fff6e6</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#fff6e6</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#fff6e6</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#dea410</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#eec529</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#eec529</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#eec529</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#eec529</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#eec529</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#f6de41</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffe65a</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#fff69c</span>;}<span style="color: #d19a66;line-height: 26px;">.heart</span>{<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">18px</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">18px</span>;<span style="color: #98c379;line-height: 26px;">display</span>:block;<span style="color: #98c379;line-height: 26px;">position</span>:absolute;<span style="color: #98c379;line-height: 26px;">top</span>:<span style="color: #d19a66;line-height: 26px;">54%</span>;<span style="color: #98c379;line-height: 26px;">left</span>:<span style="color: #d19a66;line-height: 26px;">39%</span>;<span style="color: #98c379;line-height: 26px;">-webkit-animation</span>:float <span style="color: #d19a66;line-height: 26px;">1s</span> ease infinite;<span style="color: #98c379;line-height: 26px;">animation</span>:float <span style="color: #d19a66;line-height: 26px;">1s</span> ease infinite;}<span style="color: #d19a66;line-height: 26px;">.heart</span><span style="color: #d19a66;line-height: 26px;">:after</span>{<span style="color: #98c379;line-height: 26px;">content</span>:<span style="color: #98c379;line-height: 26px;">''</span>;<span style="color: #98c379;line-height: 26px;">width</span>:<span style="color: #d19a66;line-height: 26px;">1px</span>;<span style="color: #98c379;line-height: 26px;">height</span>:<span style="color: #d19a66;line-height: 26px;">1px</span>;<span style="color: #98c379;line-height: 26px;">display</span>:block;<span style="color: #98c379;line-height: 26px;">box-shadow</span>:<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#000000</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffffff</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#feccf1</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#feccf1</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#feccf1</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#feccf1</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#feccf1</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffd2f2</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ff87c2</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#ff87c2</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ff87c2</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ff87c2</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#ff87c2</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ff87c2</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">#eb86ae</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">4px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">3px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">13px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">14px</span> <span style="color: #d19a66;line-height: 26px;">12px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">11px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">6px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">1px</span> <span style="color: #d19a66;line-height: 26px;">5px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">2px</span> <span style="color: #d19a66;line-height: 26px;">#ffc6f8</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">15px</span> <span style="color: #d19a66;line-height: 26px;">#a53367</span>,<span style="color: #d19a66;line-height: 26px;">7px</span> <span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">10px</span> <span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">#f2d2f9</span>,<span style="color: #d19a66;line-height: 26px;">8px</span> <span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>,<span style="color: #d19a66;line-height: 26px;">9px</span> <span style="color: #d19a66;line-height: 26px;">16px</span> <span style="color: #d19a66;line-height: 26px;">#ffa5da</span>;}<span style="color: #c678dd;line-height: 26px;">@-webkit-keyframes</span> boing{0%,100%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">90%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1</span>);}50%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">60%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">0.95</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1.1</span>);}}<span style="color: #c678dd;line-height: 26px;">@keyframes</span> boing{0%,100%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">90%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1</span>);}50%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">60%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">0.95</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1.1</span>);}}<span style="color: #c678dd;line-height: 26px;">@-webkit-keyframes</span> bounce{0%,100%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1</span>);}50%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">60%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">0.95</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1.03</span>);}}<span style="color: #c678dd;line-height: 26px;">@keyframes</span> bounce{0%,100%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">1</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1</span>);}50%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">60%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">scaleX</span>(<span style="color: #d19a66;line-height: 26px;">0.95</span>) <span style="color: #e6c07b;line-height: 26px;">scaleY</span>(<span style="color: #d19a66;line-height: 26px;">1.03</span>);}}<span style="color: #c678dd;line-height: 26px;">@-webkit-keyframes</span> float{0%,100%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>);}50%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">57%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>);}}<span style="color: #c678dd;line-height: 26px;">@keyframes</span> float{0%,100%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>);}50%{<span style="color: #98c379;line-height: 26px;">transform</span>:<span style="color: #e6c07b;line-height: 26px;">translateY</span>(-<span style="color: #d19a66;line-height: 26px;">57%</span>) <span style="color: #e6c07b;line-height: 26px;">translateX</span>(-<span style="color: #d19a66;line-height: 26px;">50%</span>);}}<span style="color: #e06c75;line-height: 26px;">body</span>,<span style="color: #e06c75;line-height: 26px;">html</span>{<span style="color: #98c379;line-height: 26px;">min-height</span>:<span style="color: #d19a66;line-height: 26px;">100%</span>;<span style="color: #98c379;line-height: 26px;">text-align</span>:center;}<span style="color: #e06c75;line-height: 26px;">h1</span>{<span style="color: #98c379;line-height: 26px;">display</span>:inline-block;<span style="color: #98c379;line-height: 26px;">font-size</span>:<span style="color: #d19a66;line-height: 26px;">60px</span>;<span style="color: #98c379;line-height: 26px;">margin</span>:<span style="color: #d19a66;line-height: 26px;">10px</span>;<span style="color: #98c379;line-height: 26px;">color</span>:<span style="color: #d19a66;line-height: 26px;">#805cff</span>;<span style="color: #98c379;line-height: 26px;">font-weight</span>:<span style="color: #d19a66;line-height: 26px;">900</span>;}<span style="color: #d19a66;line-height: 26px;">.logo</span>{<span style="color: #98c379;line-height: 26px;">max-width</span>:<span style="color: #d19a66;line-height: 26px;">400px</span>;<span style="color: #98c379;line-height: 26px;">margin</span>:<span style="color: #d19a66;line-height: 26px;">100px</span> <span style="color: #d19a66;line-height: 26px;">40px</span>;}<span style="color: #e06c75;line-height: 26px;">body</span>{<span style="color: #98c379;line-height: 26px;">color</span>:black;<span style="color: #98c379;line-height: 26px;">background</span>:red;<span style="color: #98c379;line-height: 26px;">background</span>:<span style="color: #e6c07b;line-height: 26px;">linear-gradient</span>(<span style="color: #d19a66;line-height: 26px;">45deg</span>,#d2ffde,#ceefff,#ded1ff);<span style="color: #98c379;line-height: 26px;">background-size</span>:cover;<span style="color: #98c379;line-height: 26px;">background-repeat</span>:no-repeat;<span style="color: #98c379;line-height: 26px;">padding</span>:<span style="color: #d19a66;line-height: 26px;">20px</span>;<span style="color: #98c379;line-height: 26px;">font-family</span>:<span style="color: #98c379;line-height: 26px;">'Heebo'</span>,sans-serif;}</span><span style="line-height: 26px;"><!--/<span style="color: #e06c75;line-height: 26px;"-->style</span>><br> <span style="line-height: 26px;"><!--/<span style="color: #e06c75;line-height: 26px;"-->head</span>><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">body</span>></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">main</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">"app"</span>></span><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">List</span>></span><span style="line-height: 26px;"><!--/<span style="color: #e06c75;line-height: 26px;"-->List</span>><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">img</span><br> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">"logo"</span><br> <span style="color: #d19a66;line-height: 26px;">src</span>=<span style="color: #98c379;line-height: 26px;">"https://fecoder-pic-1302080640.cos.ap-nanjing.myqcloud.com/International_Poke%CC%81mon_logo.svg.png"</span><br> /></span><br> <span style="line-height: 26px;"><!--/<span style="color: #e06c75;line-height: 26px;"-->main</span>><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">script</span> <span style="color: #d19a66;line-height: 26px;">src</span>=<span style="color: #98c379;line-height: 26px;">"https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"</span>></span><span style="line-height: 26px;"><!--/<span style="color: #e06c75;line-height: 26px;"-->script</span>><br> <span style="line-height: 26px;"><<span style="color: #e06c75;line-height: 26px;">script</span>></span><span style="line-height: 26px;"><br> <span style="color: #e6c07b;line-height: 26px;">window</span>.pokemon = [<br> <span style="color: #98c379;line-height: 26px;">'Bulbasaur'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Ivysaur'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Venusaur'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Charmander'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Charmeleon'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Charizard'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Squirtle'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Wartortle'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Blastoise'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Caterpie'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Metapod'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Butterfree'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Weedle'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Kakuna'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Beedrill'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Pidgey'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Pidgeotto'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Pidgeot'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Rattata'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Raticate'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Spearow'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Fearow'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Ekans'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Arbok'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Pikachu'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Raichu'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Sandshrew'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Sandslash'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Nidoran♀'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Nidorina'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Nidoqueen'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Nidoran♂'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Nidorino'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Nidoking'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Clefairy'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Clefable'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Vulpix'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Ninetales'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Jigglypuff'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Wigglytuff'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Zubat'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Golbat'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Oddish'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Gloom'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Vileplume'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Paras'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Parasect'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Venonat'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Venomoth'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Diglett'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dugtrio'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Meowth'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Persian'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Psyduck'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Golduck'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Mankey'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Primeape'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Growlithe'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Arcanine'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Poliwag'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Poliwhirl'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Poliwrath'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Abra'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Kadabra'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Alakazam'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Machop'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Machoke'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Machamp'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Bellsprout'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Weepinbell'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Victreebel'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Tentacool'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Tentacruel'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Geodude'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Graveler'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Golem'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Ponyta'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Rapidash'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Slowpoke'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Slowbro'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Magnemite'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Magneton'</span>,<br> <span style="color: #98c379;line-height: 26px;">"Farfetch'd"</span>,<br> <span style="color: #98c379;line-height: 26px;">'Doduo'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dodrio'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Seel'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dewgong'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Grimer'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Muk'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Shellder'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Cloyster'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Gastly'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Haunter'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Gengar'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Onix'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Drowzee'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Hypno'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Krabby'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Kingler'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Voltorb'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Electrode'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Exeggcute'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Exeggutor'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Cubone'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Marowak'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Hitmonlee'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Hitmonchan'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Lickitung'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Koffing'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Weezing'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Rhyhorn'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Rhydon'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Chansey'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Tangela'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Kangaskhan'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Horsea'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Seadra'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Goldeen'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Seaking'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Staryu'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Starmie'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Mr Mime'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Scyther'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Jynx'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Electabuzz'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Magmar'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Pinsir'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Tauros'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Magikarp'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Gyarados'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Lapras'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Ditto'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Eevee'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Vaporeon'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Jolteon'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Flareon'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Porygon'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Omanyte'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Omastar'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Kabuto'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Kabutops'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Aerodactyl'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Snorlax'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Articuno'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Zapdos'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Moltres'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dratini'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dragonair'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dragonite'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Mewtwo'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Mew'</span>,<br> ];<br> <span style="color: #e6c07b;line-height: 26px;">window</span>.alolan = [<br> <span style="color: #98c379;line-height: 26px;">'Rattata'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Raticate'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Raichu'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Sandshrew'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Sandslash'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Vulpix'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Ninetales'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Diglett'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Dugtrio'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Meowth'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Persian'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Geodude'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Graveler'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Golem'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Grimer'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Muk'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Exeggutor'</span>,<br> <span style="color: #98c379;line-height: 26px;">'Marowak'</span>,<br> ];<br> <span style="color: #e6c07b;line-height: 26px;">window</span>.candies = [<br> <span style="color: #98c379;line-height: 26px;">''</span>,<br> <span style="color: #98c379;line-height: 26px;">'health'</span>,<br> <span style="color: #98c379;line-height: 26px;">'mighty'</span>,<br> <span style="color: #98c379;line-height: 26px;">'tough'</span>,<br> <span style="color: #98c379;line-height: 26px;">'smart'</span>,<br> <span style="color: #98c379;line-height: 26px;">'courage'</span>,<br> <span style="color: #98c379;line-height: 26px;">'quick'</span>,<br> ];<br><br> <span style="color: #e6c07b;line-height: 26px;">window</span>.team = [<br> {<br> <span style="color: #d19a66;line-height: 26px;">name</span>: <span style="color: #98c379;line-height: 26px;">'Pikachu'</span>,<br> <span style="color: #d19a66;line-height: 26px;">nick</span>: <span style="color: #98c379;line-height: 26px;">'Sparky'</span>,<br> <span style="color: #d19a66;line-height: 26px;">sex</span>: <span style="color: #98c379;line-height: 26px;">'female'</span>,<br> <span style="color: #d19a66;line-height: 26px;">lvl</span>: <span style="color: #d19a66;line-height: 26px;">24</span>,<br> },<br> {<br> <span style="color: #d19a66;line-height: 26px;">name</span>: <span style="color: #98c379;line-height: 26px;">'Eevee'</span>,<br> <span style="color: #d19a66;line-height: 26px;">sex</span>: <span style="color: #98c379;line-height: 26px;">'female'</span>,<br> <span style="color: #d19a66;line-height: 26px;">lvl</span>: <span style="color: #d19a66;line-height: 26px;">23</span>,<br> },<br> {<br> <span style="color: #d19a66;line-height: 26px;">name</span>: <span style="color: #98c379;line-height: 26px;">'Vulpix'</span>,<br> <span style="color: #d19a66;line-height: 26px;">sex</span>: <span style="color: #98c379;line-height: 26px;">'male'</span>,<br> <span style="color: #d19a66;line-height: 26px;">lvl</span>: <span style="color: #d19a66;line-height: 26px;">13</span>,<br> <span style="color: #d19a66;line-height: 26px;">alolan</span>: <span style="color: #56b6c2;line-height: 26px;">true</span>,<br> <span style="color: #d19a66;line-height: 26px;">health</span>: <span style="color: #d19a66;line-height: 26px;">15</span>,<br> <span style="color: #d19a66;line-height: 26px;">candy</span>: <span style="color: #98c379;line-height: 26px;">'quick'</span>,<br> },<br> {<br> <span style="color: #d19a66;line-height: 26px;">name</span>: <span style="color: #98c379;line-height: 26px;">'Haunter'</span>,<br> <span style="color: #d19a66;line-height: 26px;">sex</span>: <span style="color: #98c379;line-height: 26px;">'female'</span>,<br> <span style="color: #d19a66;line-height: 26px;">lvl</span>: <span style="color: #d19a66;line-height: 26px;">57</span>,<br> <span style="color: #d19a66;line-height: 26px;">health</span>: <span style="color: #d19a66;line-height: 26px;">49</span>,<br> },<br> {<br> <span style="color: #d19a66;line-height: 26px;">name</span>: <span style="color: #98c379;line-height: 26px;">'Charizard'</span>,<br> <span style="color: #d19a66;line-height: 26px;">sex</span>: <span style="color: #98c379;line-height: 26px;">'male'</span>,<br> <span style="color: #d19a66;line-height: 26px;">lvl</span>: <span style="color: #d19a66;line-height: 26px;">76</span>,<br> <span style="color: #d19a66;line-height: 26px;">health</span>: <span style="color: #d19a66;line-height: 26px;">92</span>,<br> },<br> {<br> <span style="color: #d19a66;line-height: 26px;">name</span>: <span style="color: #98c379;line-height: 26px;">'Mew'</span>,<br> <span style="color: #d19a66;line-height: 26px;">sex</span>: <span style="color: #98c379;line-height: 26px;">'female'</span>,<br> <span style="color: #d19a66;line-height: 26px;">lvl</span>: <span style="color: #d19a66;line-height: 26px;">99</span>,<br> <span style="color: #d19a66;line-height: 26px;">candy</span>: <span style="color: #98c379;line-height: 26px;">'smart'</span>,<br> },<br> ];<br><br> Vue.component(<span style="color: #98c379;line-height: 26px;">'Arrow'</span>, {<br> <span style="color: #d19a66;line-height: 26px;">template</span>: <span style="color: #98c379;line-height: 26px;">`<br> <span class="arrow"><br> <svg id="arrow" viewbox="0 0 232 232"> <br> <defs> <br> <lineargradient id="arrow-gradient" x1="157.02" y1="90.68" x2="157.02" y2="246.27" gradientunits="userspaceonuse"> <br> <stop offset="0" :stop-color="topcolor" /> <br> <stop offset="1" :stop-color="bottomcolor" /> <br> <br> </lineargradient id="arrow-gradient" x1="157.02" y1="90.68" x2="157.02" y2="246.27" gradientunits="userspaceonuse"> </defs> <br> <path data-name="outer stroke" d="m66.42,284.52a23.47,23.47,0,0,1-5-.55a22.91,22.91,0,0,1,47,273.77a22,22,0,0,1-2.7-17l66,168.44,44.56,80.21a22.17,22.17,0,0,1,45.84,66a22.82,22.82,0,0,1,20.9-13.45,23.06,23.06,0,0,1,8.56,1.64c20.44,8.05,56.57,23.67,90.92,41.11,38.22,19.41,80.64,43.46,98.4,54.06a22.74,22.74,0,0,1,7.13,6.71,22.27,22.27,0,0,1,3.35,17.17,22.54,22.54,0,0,1-10.3,14.4c-17.12,10.45-61.08,36.68-99.07,54.38l-12.88,6c-32.36,15.09-62.93,29.34-78.37,35.08a23,23,0,0,1,66.42,284.52z" transform="translate(-43.6 -52.52)" style="fill: #4f5456" /> <br> <path data-name="inner stroke" d="m159,109.53c124.09,91.82,87.87,76.3,69.38,69a7,7,0,0,0-8.92,3.45,6.14,6.14,0,0,0-.36,4l82,166.63a6.3,6.3,0,0,1,0,3.65l59.78,260.6a6.45,6.45,0,0,0,5.08,7.75,7.17,7.17,0,0,0,4-.28c16.89-6.27,55.14-24.33,90.06-40.58,37.65-17.55,81.41-43.73,97.51-53.55a6.24,6.24,0,0,0,2-8.9,6.6,6.6,0,0,0-2.1-2c238.55,152.4,196.37,128.53,159,109.53z" transform="translate(-43.6 -52.52)" style="fill: #fff" /> <br> <path d="m97.51,174.36a22.32,22.32,0,0,0,0-11.78l80,90.68c18.69,7.87,45.44,19.78,71.7,33.12,29.6,15,61.74,32.88,82.52,44.84-20.71,12.3-53.29,31-82,44.34l-12.89,6c-21.48,10-43.47,20.27-59.54,27.28z" transform="translate(-43.6 -52.52)" style="fill: url(#arrow-gradient)" /> <br> <br> </svg id="arrow" viewbox="0 0 232 232"></span><br>`</span>,<br> <span style="color: #d19a66;line-height: 26px;">props</span>: {<br> <span style="color: #d19a66;line-height: 26px;">topColor</span>: { <span style="color: #d19a66;line-height: 26px;">type</span>: <span style="color: #e6c07b;line-height: 26px;">String</span>, <span style="color: #d19a66;line-height: 26px;">default</span>: <span style="color: #98c379;line-height: 26px;">'#eee'</span> },<br> <span style="color: #d19a66;line-height: 26px;">bottomColor</span>: { <span style="color: #d19a66;line-height: 26px;">type</span>: <span style="color: #e6c07b;line-height: 26px;">String</span>, <span style="color: #d19a66;line-height: 26px;">default</span>: <span style="color: #98c379;line-height: 26px;">'#888'</span> },<br> },<br> });<br> Vue.component(<span style="color: #98c379;line-height: 26px;">'Bg'</span>, {<br> <span style="color: #d19a66;line-height: 26px;">template</span>: <span style="color: #98c379;line-height: 26px;">`<br> <svg class="cell" viewbox="0 0 300 436"> <br> <defs> <br> <lineargradient id="bg-gradient" x1="157.02" y1="90.68" x2="157.02" y2="246.27" gradientunits="userspaceonuse"> <br> <stop offset="0" stop-color="rgba( 255, 255, 255, 0.3 )" /> <br> <stop offset="1" stop-color="rgba( 255, 255, 255, 0.5 )" /> <br> <br> <lineargradient id="bg-gradient-selected" x1="157.02" y1="90.68" x2="157.02" y2="246.27" gradientunits="userspaceonuse"> <br> <stop offset="0" stop-color="rgba(255, 246, 146, 0.7)" /> <br> <stop offset="1" stop-color="rgba(255, 225, 85, 0.8)" /> <br> <br> </lineargradient id="bg-gradient-selected" x1="157.02" y1="90.68" x2="157.02" y2="246.27" gradientunits="userspaceonuse"> </lineargradient id="bg-gradient" x1="157.02" y1="90.68" x2="157.02" y2="246.27" gradientunits="userspaceonuse"> </defs> <br> <path class="bg" d="m270.88,433c242,438,196,441,155,441s-93.84-3.61-115.88-8c14,428,11,405,9,368c-.92-17-4-70-4-145s9,77,9,77c1-37,5.23-59,30.12-64s114,5,155,5s91.77,2,115.88,8s300,40,301,77c0,0,4,71,4,146s-1.36,124.73-3,145c299,405,299.77,428,270.88,433z" transform="translate(-5 -5)" style="fill: url(#bg-gradient)" /> <br> <path class="stroke" d="m155,15.31c18.41,0,80.61.55,108.25,7.62,10.49,2.69,17.29,8.7,21.39,18.91,3.59,8.94,5.34,21.33,5.87,41.45,0,.68,3.72,68.76,3.72,139.71,0,64.71-1,116.58-2.79,138.73-.22,2.86-.42,5.62-.62,8.3-2.22,30.4-3.56,48.75-27.5,53-26.06,4.64-68.58,7.64-108.32,7.64-38.49,0-88.09-3.5-108.3-7.64-22.62-4.63-25.37-26.25-27.21-61.29l-.13-2.36c-1-18.54-3.59-67.8-3.59-136.4,0-70.95,3.68-139,3.72-139.74,1-36.47,5.43-55.81,27.22-60.31,24.25-5,72.83-7.64,108.29-7.64m0-1c-38.14,0-85.35,2.87-108.5,7.66s-27.08,25.84-28,61.26c0,0-3.72,68-3.72,139.77s2.87,122.56,3.72,138.81c1.86,35.42,4.65,57.44,28,62.22,20.51,4.2,70.36,7.66,108.5,7.66s81.63-2.87,108.5-7.66,26.15-26.8,28.94-62.22c1.53-19.41,2.79-67,2.79-138.81s-3.72-139.77-3.72-139.77c-.93-35.42-5.58-55.52-28-61.26s193.14,14.31,155,14.31z" transform="translate(-5 -5)" style="fill: #fff" /> <br> <br>` </svg class="cell" viewbox="0 0 300 436"></span>,<br> });<br> Vue.component(<span style="color: #98c379;line-height: 26px;">'Pokeball'</span>, {<br> <span style="color: #d19a66;line-height: 26px;">template</span>: <span style="color: #98c379;line-height: 26px;">`<br> <svg class="pokeball" viewbox="0 0 204.54 207.46"> <br> <path d="m9.57,128.66l60.57,0s.42,1.17,1.49,3.35c10.51,22.12,34.09,31.79,56.93,22.92,12.07-4.69,20.49-13.53,24.76-26.27h60.6c-3.66,40.18-40.45,85.21-95.06,88.75c60.8,221.14,15.86,177.72,9.57,128.66z" transform="translate(-9.57 -10.14)" /> <br> <path d="m214.11,99.09h153.33a15.33,15.33,0,0,0-1.28-3.46c-8-16.74-21.42-25.84-39.89-25.95c93.44,69.56,80,78.77,71.65,95.58c-.77,1.53-1.51,3.51-1.51,3.51h9.79c5.15-45.56,47-89.37,102.94-88.95s209.31,54.53,214.11,99.09z" transform="translate(-9.57 -10.14)" /> <br> <path d="m111.72,134.54a20.39,20.39,0,1,1,20.53-19.9a20.5,20.5,0,0,1,111.72,134.54z" transform="translate(-9.57 -10.14)" /> <br> <br> <br> ` </svg class="pokeball" viewbox="0 0 204.54 207.46"></span>,<br> });<br> Vue.component(<span style="color: #98c379;line-height: 26px;">'Male'</span>, {<br> <span style="color: #d19a66;line-height: 26px;">template</span>: <span style="color: #98c379;line-height: 26px;">`<br> <svg class="icon male" viewbox="0 0 426.667 426.667"> <br> <path style="fill:#50c8ef;" d="m165.705,426.667c74.334,426.667,0,352.333,0,260.962c0-91.366,74.334-165.7,165.705-165.7> <br> c91.366,0,165.7,74.334,165.7,165.7C331.405,352.333,257.071,426.667,165.705,426.667z M165.705,157.235 <br> c-57.199,0-103.735,46.532-103.735,103.731s46.532,103.735,103.735,103.735c57.195,0,103.735-46.532,103.735-103.735 <br> C269.436,203.767,222.899,157.235,165.705,157.235z"/> <br> <polygon style="fill:#50c8ef;" points="426.667,165.705 364.698,165.705 364.698,61.969 260.962,61.969 260.962,0 426.667,0 " /> <br> <br> <rect x="297.325" y="3.092" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 490.914 400.0457)" style="fill:#50c8ef;" width="61.968" height="190.518" /> <br> ` </path style="fill:#50c8ef;" d="m165.705,426.667c74.334,426.667,0,352.333,0,260.962c0-91.366,74.334-165.7,165.705-165.7> </svg class="icon male" viewbox="0 0 426.667 426.667"></span>,<br> });<br> Vue.component(<span style="color: #98c379;line-height: 26px;">'Female'</span>, {<br> <span style="color: #d19a66;line-height: 26px;">template</span>: <span style="color: #98c379;line-height: 26px;">`<br> <svg class="icon female" viewbox="0 0 417.606 417.606"> <br> <br> <path style="fill:#f05228;" d="m251.906,331.41c-91.379,0-165.709-74.338-165.709-165.705c0-91.371,74.334-165.705,165.709-165.705> <br> c91.366,0,165.7,74.334,165.7,165.705C417.606,257.072,343.272,331.41,251.906,331.41z M251.906,61.975 <br> c-57.203,0-103.735,46.532-103.735,103.735c0,57.195,46.532,103.735,103.735,103.735c57.199,0,103.735-46.537,103.735-103.735 <br> C355.637,108.507,309.105,61.975,251.906,61.975z"/> <br> <br> <rect x="58.314" y="233.078" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 -79.7284 623.65)" style="fill:#f05228;" width="61.968" height="190.518" /> <br> <br> <rect x="-5.991" y="297.329" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 -79.764 623.5881)" style="fill:#f05228;" width="190.518" height="61.968" /> <br> <br>` </path style="fill:#f05228;" d="m251.906,331.41c-91.379,0-165.709-74.338-165.709-165.705c0-91.371,74.334-165.705,165.709-165.705> </svg class="icon female" viewbox="0 0 417.606 417.606"></span>,<br> });<br><br> Vue.component(<span style="color: #98c379;line-height: 26px;">'Pokemon'</span>, {<br> <span style="color: #d19a66;line-height: 26px;">template</span>: <span style="color: #98c379;line-height: 26px;">`<br> <div class="radio" class="pokemon" :class="{ selected: isselected }"> <br> <bg :selected="isselected"> <br> <pokeball></pokeball> <br> <arrow v-if="isselected"> <br> <label><br> <input class="radio" type="radio" name="poke" :id="name" :value="name" v-model="selectedpokemon"> <br> <span class="lvl">Lv. {{ lvl }}</span> <br> <span class="sex" :class="sex"><br> <female v-if="sex === 'female'"> <br> <male v-else> <br> </male v-else> </female v-if="sex === 'female'"></span> <br> <img class="sprite" :src="sprite" /> <br> <span class="heart" v-if="partner"></span> <br> <span v-if="candy" class="candy" :class="candy"></span> <br> <div class="details"> <br> <h2 class="name"> {{ nickname }} <br> <div class="hp"> <br> <div class="bar"> <br> <div class="health" :style="{ width: healthpercent }" :class="{ low: health > <= 50, critical: health <= 15 }"> </div class="health" :style="{ width: healthpercent }" :class="{ low: health > </div class="bar"> </div class="hp"> </h2 class="name"> </div class="details"> </input class="radio" type="radio" name="poke" :id="name" :value="name" v-model="selectedpokemon"></label> </arrow v-if="isselected"> </bg :selected="isselected"> </div class="radio" class="pokemon" :class="{ selected: isselected }"></span></span></code></pre> </section>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, PingFangSC-light, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;overflow-wrap: break-word;text-align: left;"> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005339" data-ratio="0.5027777777777778" data-type="jpeg" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/50af70e47e5fd7c384235ad203527c84.jpg"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">Cursor 好用是真的好用,也是笔者体验过最好用的 AI 辅助工具了,在试用期过后,也看到很多人对 Cursor 每月的 </span><code style=""><span leaf="">20$</span></code><span leaf=""> 费用望而却步!毕竟这 </span><code style=""><span leaf="">20$</span></code><span leaf=""> 能让我喝好几碗羊肉汤...!</span></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">近期国产大模型 DeepSeek 发布了 v3 版本,性能大幅提升,可以媲美当前的老大哥 Claude-3.5-Sonnet,同时价格也很美丽,如果说 Cursor 每个月要花 20$,DeepSeek 可能把后面的单位 </span><code style=""><span leaf="">\$</span></code><span leaf=""> 去掉就可以了,瞬间是不是感觉香了?毕竟能省不少啊。</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005336" data-ratio="0.2662192393736018" data-type="png" data-w="894" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/6f9819fb06c8b1d0454b974b24806219.png"></span> <figcaption style="color: rgb(136, 136, 136);font-size: 12px;line-height: 1.5em;letter-spacing: 0em;text-align: center;font-weight: normal;margin-top: 5px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"> <span leaf="">DeepSeek V3 费用</span> </figcaption> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">于是,把 DeepSeek-V3 接到了 Cursor,体验下来 Cursor 对自定义的模型还是有功能限制的,例如,只能使用 Cursor Chat 模式、文件内容唤起提问或终端唤起提问发现不太灵通,当然如果你对 Cursor Chat 模式已经满足了也 ok 的,因为我想要 Agent 功能,这个只能在 Composer 模式下用,同时 Composer 还支持关联多文件修改。详情参见 </span><a href="https://mp.weixin.qq.com/s?__biz=MzU3NTg5MjU1Mw==&mid=2247488983&idx=1&sn=ec373d963ccb72d1498ba1942a2787ab&scene=21#wechat_redirect" style="color: rgb(248, 57, 41);font-weight: bold;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(30, 107, 184);border-bottom-color: rgb(248, 57, 41);border-left-color: rgb(30, 107, 184);border-right-color: rgb(30, 107, 184);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-decoration: none;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;overflow-wrap: break-word;"><code style=""><span leaf="">我把最近爆火的 DeepSeek-V3 接到了 Cursor!</span></code></a></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">最近,又发现了一个当前</span><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">最具性价比的组合 Cline + DeepSeek-V3</span></strong><span leaf="">(还不用担心🪜问题 😎)</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 5px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(248, 57, 41);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">Cline 是什么?</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">Clien 是一个开源的 AI 助手,以 VS Code 插件的形式来使用(目前唯一支持的也就是 VS Code 编辑器),使用和上手都很简单。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">主要功能如下:</span></strong></p> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;font-weight: normal;"> <p style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">高度可扩展性</span></strong><span leaf="">:Cline 支持很多 API 提供商,例如 penRouter、Anthropic、OpenAI、Google Gemini 等,与 OpenAI 兼容的 API 也同样支持,这里我们就会用到 DeepSeek。还能通过 LM Studio/Ollama 使用本地模型。<img class="rich_pages wxw-img" data-imgfileid="100005337" data-ratio="1.0913978494623655" data-type="png" data-w="744" style="display: block;margin: 0px auto;max-width: 100%;height: auto !important;" src="/upload/74e118e14f236cae234941441e097cf1.png"></span></p> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;font-weight: normal;"> <p style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">终端命令支持</span></strong><span leaf="">:Cline 可以在终端直接执行命令并接收输出,例如安装依赖 </span><code style=""><span leaf="">npm install</span></code><span leaf=""> 这个命令有时候网络不好了,很耗时的,但你也不用等它完成,有个 “Proceed While Running” 按钮,意思是运行时继续,这会让命令在后台运行同时 Cline 还能执行任务。代码生成成功之后,要运行 </span><code style=""><span leaf="">npm run dev</span></code><span leaf=""> 命令,Cline 也是可以直接运行的。<img class="rich_pages wxw-img" data-imgfileid="100005340" data-ratio="0.5981481481481481" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;height: auto !important;" src="/upload/e8af53aaa051648acc00caa44978dd67.png"></span></p> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;font-weight: normal;"> <p style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">创建和编辑文件</span></strong><span leaf="">:Cline 可以直接在编辑器中创建和编辑文件,展示更改的差异视图。还能监控 linter / 编译器错误(缺少导入、语法错误等),这样他就可以自己解决过程中出现的问题。Cline 所做的所有更改都记录在文件的时间轴中,如果需要,提供了一种简单的方法来跟踪和恢复修改。</span></p> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;font-weight: normal;"> <p style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">MCP</span></strong><span leaf="">:全称为模型上下文协议,可实现 LLM 应用程序与外部数据源和工具之间的无缝集成,详情参见 </span><code style=""><span leaf="">https://github.com/modelcontextprotocol</span></code></p> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;font-weight: normal;"> <p style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">为当前的任务请求添加上下文</span></strong><span leaf="">,支持以下四个。<img class="rich_pages wxw-img" data-imgfileid="100005338" data-ratio="0.40185185185185185" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;height: auto !important;" src="/upload/50aa30c065e7f9fc7f40e3c2e302745d.png"></span></p> </section></li> </ul> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 5px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(248, 57, 41);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">Cline + DeepSeek-V3 集成和 Demo</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在 VS Code 应用商店搜索 </span><code style=""><span leaf="">cline</span></code><span leaf=""> 并安装</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005342" data-ratio="0.32407407407407407" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/d9eb87c7caf2736918d4db958ca06b04.png"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">左侧工具栏点击笑脸按钮,配置 DeepSeek-V3 的模型和 API 地址,注意,模型 ID 一定要填写 </span><code style=""><span leaf="">deepseek-chat</span></code><span leaf="">,目前 DeepSeek 已将模型 </span><code style=""><span leaf="">deepseek-chat</span></code><span leaf=""> 升级到了 DeepSeek-V3。笔者在这篇 </span><a href="https://mp.weixin.qq.com/s?__biz=MzU3NTg5MjU1Mw==&mid=2247488983&idx=1&sn=ec373d963ccb72d1498ba1942a2787ab&scene=21#wechat_redirect" style="color: rgb(248, 57, 41);font-weight: bold;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(30, 107, 184);border-bottom-color: rgb(248, 57, 41);border-left-color: rgb(30, 107, 184);border-right-color: rgb(30, 107, 184);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-decoration: none;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;overflow-wrap: break-word;"><code style=""><span leaf="">我把最近爆火的 DeepSeek-V3 接到了 Cursor!</span></code></a><span leaf=""> 文章中也有介绍过。</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005343" data-ratio="0.8777777777777778" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/a4e927c7c613467dcf8323973e34a3a2.png"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">接下来打开 Clien Chat 窗口,就可以发送请求了</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005345" data-ratio="0.512962962962963" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/89dfc5342e7c98b373d03168ce0f6181.png"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">以下是笔者录制的视频,记录了完整的 Cline + DeepSeek-V3 配置和实现一个 Todo List Demo 过程。</span></p> <section class="channels_iframe_wrp" nodeleaf=""> <mp-common-videosnap class="js_uneditable custom_select_card channels_iframe videosnap_video_iframe mp_common_widget" data-type="video" data-id="export/UzFfAgtgekIEAQAAAAAAMPYLkwqU0AAAAAstQy6ubaLX4KHWvLEZgBPEnqI8AjkDUOyJzNPgMIuWi2VDT4WA0UuDUmZAPdV0" data-url="https://findermp.video.qq.com/251/20304/stodownload?encfilekey=rjD5jyTuFrIpZ2ibE8T7YmwgiahniaXswqzOnic2emqkYAhfNDZEZ97zv9iaX6dyzr6UERGDQHl0LD90ibxa2hkzWroMz2HpLEVicpnsJvF8tv9f1comVlt1S7pug&token=AxricY7RBHdX6icWxvXE2cjR6rDm8iagqOaxiaMKtxJajcBKjbIdpjYXA1cgNvggSicORPv3lDsPka8Qa8aBR4GmddR0SbZWXnJkbHCzbCjrpD8ibOgMVzcSnMHPdiaI5ibnHib8OBuewwOWDkjmibFZEp4xP1TRoPhLrlL0N6mrGqia1kcia78&idx=1&hy=SH&m=&scene=2&uzid=2" data-headimgurl="http://wx.qlogo.cn/finderhead/SXryYH6DzyaP9fsoAtrN0HJc7fic17Jz5WpL7fdPZAXWJL1cONySiaIj2bE6hyb92oORJEokmw5fU/0" data-nickname="AI智见录" data-username="v2_060000231003b20faec8c4ea8f1dcad1cf03ed33b077eb8dfb7ad908940def8ce10d341ca98e@finder" data-desc="2025 开年王炸组合:Cline + DeepSeek-V3,聊聊使用后感受: 1. Cline 感觉更适合一些没有代码经验,想完全依赖聊天交互搭建整个应用的群体,应付一些小项目 ok。如果不想每月话费 Cursor 20$,可以试试这个。 2. 对于企业级项目,公司多人维护的,当前还是 Cursor 吧(个人更习惯),AI 辅助工具我现在定位还是辅助为主,类似 Cline 的 " data-mediatype="" data-width="1080" data-height="1440" data-nonceid="3713874394216685843" data-parentwidth="304.1481628417969" data-isdisabled="0" data-errortips=""></mp-common-videosnap> </section> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 5px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(248, 57, 41);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">Cline + DeepSeek-V3 使用感受</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">DeepSeek-V3 是提供了大模型能力,整体还是 Cline 的使用体验。这个小 Demo 项目的搭建速度还是挺快的,</span><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">我开启了 </span><code style=""><span leaf="">Auto-approve</span></code><span leaf=""> 功能,允许 Cline 读取、编辑文件、执行一些安全的命令</span></strong><span leaf="">,所以视频中的 Demo 是没有直接参与代码的,全部都是 Cline 来完成,这个和 Cursor 的 Agent + Yolo 有点像。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">回到文件内部做些修改时,</span><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">发现没有 Tab 补全</span></strong><span leaf="">,对于习惯 Cursor 补全的来说,确实有点不习惯。</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005341" data-ratio="0.41203703703703703" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/28be248d5346b3fcc3df45f57e6c4e93.png"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">无法在文件内唤起内联 Chat</span></strong><span leaf="">,如果想对某块内容做修改,也没法选择具体的行,需要在 Cline Chat 窗口描述,但它的修改结果也会有类似 git diff 的差异对比,能清楚的看到改前和改后区别。</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100005344" data-ratio="0.5592592592592592" data-type="png" data-w="1080" style="display: block;margin: 0px auto;max-width: 100%;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 16px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;height: auto !important;" src="/upload/74bd09968572bcbd93d151e64e4df910.png"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">Cline Chat 窗口来回跳,体验有点不好... 不知道是不是我哪里设置的问题。</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 5px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(248, 57, 41);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">结论</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">Cline 感觉更适合一些没有代码经验</span></strong><span leaf="">,想完全依赖聊天交互搭建整个应用的群体,应付一些小项目 ok。如果不想每月花费 Cursor 20$,可以试试这个。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);font-size: 16px;line-height: 1.8em;letter-spacing: 0.04em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(248, 57, 41);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">对于企业级项目,公司多人维护的,当前还是 Cursor 吧(个人更习惯),AI 辅助工具我现在定位还是辅助为主</span></strong><span leaf="">,类似 Cline </span><code style=""><span leaf="">Auto-approve</span></code><span leaf=""> 或 Cursor Agent 在搭建新项目或写一些小 Demo 时确实惊艳,在逻辑复杂的大型项目中还是有点担忧的,弄不好就改了不该改的文件...</span></p> </section>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, 'Microsoft YaHei', PingFangSC-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;overflow-wrap: break-word;text-align: left;"> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">三范式是数据库设计中最基本的三个规范,那么,三范式到底是什么?在实际开发中,为了性能,我们需要违反三范式吗?这篇文章,我们一起来聊一聊。</span></p> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: center;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: 100%;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;border-bottom-color: rgb(0, 150, 136);color: rgb(0, 150, 136);line-height: 1.5em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: 100%;height: auto;align-items: unset;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 10px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;transform: none;-webkit-box-reflect: unset;"><span leaf="">1. 三大范式</span></span><span style="display: none;"></span></h1> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">1. 第一范式(1NF)</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">第一范式要求数据库中的每个表格的每个字段(列)都具有原子性,即字段中的值不可再分割。换句话说,每个字段只能存储一个单一的值,不能包含集合、数组或重复的组,即确保每列保持原子性。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">如下示例: 假设有一个学生表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Student</span></code><span leaf="">,结构如下:</span></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">学生ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">姓名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">电话号码</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">张三</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">123456789, 987654321</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">李四</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">555555555</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在这个表中,</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">电话号码</span></code><span leaf="">字段包含多个号码,违反了1NF的原子性要求。为了满足1NF,需要将电话号码拆分为单独的记录或创建一个新的表。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">满足 1NF后的设计:</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">学生表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Student</span></code></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">学生ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">姓名</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">张三</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">李四</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">电话表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Phone</span></code></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">电话ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">学生ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">电话号码</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">123456789</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">987654321</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">3</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">555555555</span> </section></td> </tr> </tbody> </table> </section> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">1.2 第二范式(2NF)</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">第二范式要求满足第一范式,并且消除表中的部分依赖,即非主键字段必须完全依赖于主键,而不是仅依赖于主键的一部分,即</span><span leaf="">确保表中的每列都和主键相关。</span><span leaf="">这主要适用于复合主键的情况。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">如下示例:假设有一个订单详情表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">OrderDetail</span></code><span leaf="">,结构如下:</span></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">订单ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">商品ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">商品名称</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">数量</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">单价</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1001</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">苹果</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">10</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2.5</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1001</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">橙子</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">5</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">3.0</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1002</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">苹果</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">7</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2.5</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在上述表中,主键是复合主键 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">(订单ID, 商品ID)</span></code><span leaf="">。</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">商品名称</span></code><span leaf="">和</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">单价</span></code><span leaf="">只依赖于复合主键中的</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">商品ID</span></code><span leaf="">,而不是整个主键,存在部分依赖,违反了2NF。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">满足 2NF后的设计:</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">订单详情表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">OrderDetail</span></code></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">订单ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">商品ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">数量</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1001</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">10</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1001</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">5</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1002</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">7</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">商品表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Product</span></code></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">商品ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">商品名称</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">单价</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">苹果</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2.5</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">橙子</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">3.0</span> </section></td> </tr> </tbody> </table> </section> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">1.3 第三范式(3NF)</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">第三范式要求满足第二范式,并且消除表中的传递依赖,即非主键字段不应依赖于其他非主键字段。换句话说,所有非主键字段必须直接依赖于主键,而不是通过其他非主键字段间接依赖,或者说:</span><span leaf="">确保每列都和主键列直接相关,而不是间接相关。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">如下示例:假设有一张员工表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Employee</span></code><span leaf="">,结构如下:</span></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">员工ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">员工姓名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">部门ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">部门名称</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">E01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">王五</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">销售部</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">E02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">赵六</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">技术部</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">E03</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">孙七</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">销售部</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在这张表中,</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">部门名称</span></code><span leaf="">依赖于</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">部门ID</span></code><span leaf="">,而</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">部门ID</span></code><span leaf="">依赖于主键</span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">员工ID</span></code><span leaf="">,形成了传递依赖,违反了3NF。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">满足3NF后的设计:</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">员工表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Employee</span></code></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">员工ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">员工姓名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">部门ID</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">E01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">王五</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D01</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">E02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">赵六</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D02</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">E03</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">孙七</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D01</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">部门表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Department</span></code></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">部门ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">部门名称</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">销售部</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">D02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">技术部</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">通过将部门信息移到单独的表中,消除了传递依赖,使得数据库结构符合第三范式。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">最后,我们总结一下数据库设计的三大范式:</span></p> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">第一范式(1NF):</span></strong><span leaf=""> 确保每个字段的值都是原子性的,不可再分。</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">第二范式(2NF):</span></strong><span leaf=""> 在满足 1NF的基础上,消除部分依赖,确保非主键字段完全依赖于主键。</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">第三范式(3NF):</span></strong><span leaf=""> 在满足 2NF的基础上,消除传递依赖,确保非主键字段直接依赖于主键。</span> </section></li> </ul> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: center;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: 100%;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;border-bottom-color: rgb(0, 150, 136);color: rgb(0, 150, 136);line-height: 1.5em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: 100%;height: auto;align-items: unset;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 10px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;transform: none;-webkit-box-reflect: unset;"><span leaf="">2. 破坏三范式</span></span><span style="display: none;"></span></h1> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在实际工作中,尽管遵循数据库的三大范式(1NF、2NF、3NF)有助于提高数据的一致性和减少冗余,但在某些情况下,为了满足性能、简化设计或特定业务需求,我们可能需要违反这些范式。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">下面列举了一些常见的破坏三范式的原因及对应的示例。</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.1 性能优化</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在高并发、大数据量的应用场景中,严格遵循三范式可能导致频繁的联表查询,增加查询时间和系统负载。为了提高查询性能,设计者可能会通过冗余数据来减少联表操作。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">假设有一个电商系统,包含订单表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Orders</span></code><span leaf=""> 和用户表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Users</span></code><span leaf="">。在严格 3NF设计中,订单表只存储 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">用户ID</span></code><span leaf="">,需要通过联表查询获取用户的详细信息。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">但是,为了查询性能,我们通常会在订单表中冗余存储 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">用户姓名</span></code><span leaf=""> 和 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">用户地址</span></code><span leaf="">等信息,因此,查询订单信息时无需联表查询 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Users</span></code><span leaf=""> 表,从而提升查询速度。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏 3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">订单ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户姓名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户地址</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">订单日期</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">总金额</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1001</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">张三</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">北京市</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2023-10-01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">500元</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1002</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">李四</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">上海市</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2023-10-02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">300元</span> </section></td> </tr> </tbody> </table> </section> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.2 简化查询和开发</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">严格规范化可能导致数据库结构过于复杂,增加开发和维护的难度,为了简化查询逻辑和减少开发复杂度,我们也可能会选择适当的冗余。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">比如,在内容管理系统(CMS)中,文章表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Articles</span></code><span leaf=""> 和分类表 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Categories</span></code><span leaf=""> 通常是独立的,如果频繁需要显示文章所属的分类名称,联表查询可能增加复杂性。因此,通过在 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Articles</span></code><span leaf=""> 表中直接存储 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">分类名称</span></code><span leaf="">,可以简化前端展示逻辑,减少开发工作量。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏 3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">文章ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">标题</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">内容</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">分类ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">分类名称</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">文章一</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">…</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">C01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">技术</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">A02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">文章二</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">…</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">C02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">生活</span> </section></td> </tr> </tbody> </table> </section> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.3 报表和数据仓库</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在数据仓库和报表系统中,通常需要快速读取和聚合大量数据。为了优化查询性能和数据分析,可能会采用冗余的数据结构,甚至使用星型或雪花型模式,这些模式并不完全符合三范式。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在销售数据仓库中,为了快速生成销售报表,可能会创建一个包含维度信息的事实表。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏 3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">销售ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">产品ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">产品名称</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">类别</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">销售数量</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">销售金额</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">销售日期</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">S01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">P01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">手机</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">电子</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">100</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">50000元</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2023-10-01</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">S02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">P02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">书籍</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">教育</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">200</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">20000元</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2023-10-02</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在事实表中直接存储 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">产品名称</span></code><span leaf=""> 和 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">类别</span></code><span leaf="">,避免了需要联表查询维度表,提高了报表生成的效率。</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.4 特殊业务需求</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在某些业务场景下,可能需要快速响应特定的查询或操作,这时通过适当的冗余设计可以满足业务需求。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">比如,在实时交易系统中,为了快速计算用户的账户余额,可能会在用户表中直接存储当前余额,而不是每次交易时都计算。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏 3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">当前余额</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">王五</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">10000元</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">赵六</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">5000元</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在交易记录表中存储每笔交易的增减,但直接在用户表中维护 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">当前余额</span></code><span leaf="">,避免了每次查询时的复杂计算。</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.5 兼顾读写性能</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在某些应用中,读操作远多于写操作。为了优化读性能,可能会通过数据冗余来提升查询速度,而接受在数据写入时需要额外的维护工作。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">社交媒体平台中,用户的好友数常被展示在用户主页上。如果每次请求都计算好友数量,效率低下。可以在用户表中维护一个 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">好友数</span></code><span leaf=""> 字段。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">好友数</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">Alice</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">150</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">Bob</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">200</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">通过在 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Users</span></code><span leaf=""> 表中冗余存储 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">好友数</span></code><span leaf="">,可以快速展示,无需实时计算。</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.6 快速迭代和灵活性</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在快速发展的产品或初创企业中,数据库设计可能需要频繁调整。过度规范化可能导致设计不够灵活,影响迭代速度。适当的冗余设计可以提高开发的灵活性和速度。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">一个初创电商平台在初期快速上线,数据库设计时为了简化开发,可能会将用户的收货地址直接存储在订单表中,而不是单独创建地址表。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">订单ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">用户名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">收货地址</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">订单日期</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">总金额</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">O1001</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">李雷</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">北京市海淀区…</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2023-10-01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">800元</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">O1002</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">U02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">韩梅梅</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">上海市浦东新区…</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">2023-10-02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">1200元</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">这样设计可以快速上线,后续根据需求再进行规范化和优化。</span></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 150, 136);line-height: 1.8em;letter-spacing: 0em;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 3px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">2.7 降低复杂性和提高可理解性</span></span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">有时,过度规范化可能使数据库结构变得复杂,难以理解和维护。适度的冗余可以降低设计的复杂性,提高团队对数据库结构的理解和沟通效率。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在一个学校管理系统中,如果将学生的班级信息独立为多个表,可能增加理解难度。为了简化设计,可以在学生表中直接存储班级名称。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 150, 136);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">破坏3NF后的设计:</span></strong></p> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">学生ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">姓名</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">班级ID</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">班级名称</span> </section></th> <th valign="top" style="color: rgb(255, 255, 255);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgb(0, 150, 136);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;"> <section> <span leaf="">班主任</span> </section></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">S01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">张三</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">C01</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">三年级一班</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">李老师</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">S02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">李四</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">C02</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">三年级二班</span> </section></td> <td valign="top" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 150, 136);border-bottom-color: rgb(0, 150, 136);border-left-color: rgb(0, 150, 136);border-right-color: rgb(0, 150, 136);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">王老师</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">通过在学生表中直接存储 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">班级名称</span></code><span leaf=""> 和 </span><code style="color: rgb(0, 150, 136);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: rgba(27, 31, 35, 0.05);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">班主任</span></code><span leaf="">,减少了表的数量,简化了设计。</span></p> <h1 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: center;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: 100%;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;border-bottom-color: rgb(0, 150, 136);color: rgb(0, 150, 136);line-height: 1.5em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: 100%;height: auto;align-items: unset;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 10px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;transform: none;-webkit-box-reflect: unset;"><span leaf="">3. 总结</span></span><span style="display: none;"></span></h1> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">本文,我们分析了数据库的三范式以及对应的示例,它是数据库设计的基本规范。但是,在实际工作中,为了满足性能、简化设计、快速迭代或特定业务需求,我们很多时候并不会严格地遵守三范式。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: justify;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">所以说,架构很多时候都是业务需求、数据一致性、系统性能、开发效率等各种因素权衡的结果,我们需要根据具体应用场景做出合理的设计选择。</span></p> </section>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;text-align: left;> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">前言</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">大家好,我是<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">田螺</strong>。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">我们日常开发中,经常跟MQ(消息队列)打交道。本文田螺哥梳理了MQ的8种使用场景。</p> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100029240" data-ratio="0.3212962962962963" data-s="300,640" src="/upload/efbf37d32ffa4d5bc71998077bc72baa.png" data-type="png" data-w="1080" style=""></p> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">1. 异步处理</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">面试官在问我们MQ作用时,很多伙伴马上想到<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">异步处理、解耦、流量削锋</strong>等等。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">MQ 最常见的应用场景之一就是<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">异步处理</strong>。</p> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;border-top: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(239, 112, 96);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 249, 249);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <span style="display: none;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0px;"></span> <p style="text-indent: 0em;padding-top: 8px;padding-bottom: 8px;color: rgb(0, 0, 0);line-height: 1.8em;letter-spacing: 0px;">比如,在用户注册场景中,当用户信息保存成功后,系统需要发送一个短信、或者邮箱消息,通知用户注册成功。如果这个短信或者邮箱消息发送<strong style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">比较耗时</strong>,则<strong style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">可能拖垮注册接口</strong>。又或者如果调用第三方短信、邮件发送接口失败,也会影响注册接口。一般我们不希望一个通知类的功能,去影响注册主流程,这时候,则可以使用<strong style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">MQ来实现异步处理</strong>。</p> </blockquote> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">简要代码如下</strong>:先保存用户信息,然后发送注册成功的MQ消息</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"> // 用户注册方法<br> public void registerUser(String username, String email, String phoneNumber) {<br> // 保存用户信息(简化版)<br> userService.add(buildUser(username,email,phoneNumber))<br> // 发送消息<br> String registrationMessage = <span style="color: #98c379;line-height: 26px;">"User "</span> + username + <span style="color: #98c379;line-height: 26px;">" has registered successfully."</span>;<br> // 发送消息到队列<br> rabbitTemplate.convertAndSend(<span style="color: #98c379;line-height: 26px;">"registrationQueue"</span>, registrationMessage);<br> }<br></code></pre> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">消费者从队列中读取消息<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">并发送短信或邮件</strong>:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">@Service<br>public class NotificationService {<br><br> // 监听消息队列中的消息并发送短信/邮件<br> @RabbitListener(queues = <span style="color: #98c379;line-height: 26px;">"registrationQueue"</span>)<br> public void handleRegistrationNotification(String message) {<br> // 这里可以进行短信或邮件的发送操作<br> System.out.println(<span style="color: #98c379;line-height: 26px;">"Sending registration notification: "</span> + message);<br><br> // 假设这里是发送短信的操作<br> sendSms(message);<br><br> // 也可以做其他通知(比如发邮件等)<br> sendEmail(message);<br> }<br> }<br></code></pre> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">2. 解耦</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在微服务架构中,各个服务通常需要进行<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">相互通信</strong>。使用 MQ 可以帮助<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">解耦服务</strong>,避免直接调用导致的强耦合。</p> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100029241" data-ratio="0.275092936802974" data-s="300,640" src="/upload/1c8420c151ba0f9d4cfeea531488dd3b.png" data-type="png" data-w="1076" style=""></p> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;border-top: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(239, 112, 96);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 249, 249);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <span style="display: none;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0px;"></span> <p style="text-indent: 0em;padding-top: 8px;padding-bottom: 8px;color: rgb(0, 0, 0);line-height: 1.8em;letter-spacing: 0px;">一个电商平台的库存服务和支付服务。支付服务在处理支付后,需要向库存服务发送扣库存的请求,但不直接调用 API,而是通过 MQ 发送消息,让库存服务异步处理。</p> </blockquote> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">支付服务在支付成功后将消息发送到 RocketMQ:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">import org.apache.rocketmq.client.producer.DefaultMQProducer;<br>import org.apache.rocketmq.common.message.Message;<br><br>public class PaymentService {<br><br> private DefaultMQProducer producer;<br><br> public PaymentService() throws Exception {<br> producer = new DefaultMQProducer(<span style="color: #98c379;line-height: 26px;">"PaymentProducerGroup"</span>);<br> producer.setNamesrvAddr(<span style="color: #98c379;line-height: 26px;">"localhost:9876"</span>); // RocketMQ NameServer 地址<br> producer.start();<br> }<br><br> public void processPayment(String orderId, int quantity) throws Exception {<br> // 1. 模拟调用支付接口(例如:支付宝、微信支付等)<br> boolean paymentSuccessful = callPayment(orderId, quantity);<br><br> <span style="color: #c678dd;line-height: 26px;">if</span> (paymentSuccessful) {<br> // 2. 支付成功后,创建支付消息并发送到 RocketMQ<br> String messageBody = <span style="color: #98c379;line-height: 26px;">"OrderId: "</span> + orderId + <span style="color: #98c379;line-height: 26px;">", Quantity: "</span> + quantity;<br> Message message = new Message(<span style="color: #98c379;line-height: 26px;">"paymentTopic"</span>, <span style="color: #98c379;line-height: 26px;">"paymentTag"</span>, messageBody.getBytes());<br> producer.send(message); <br> }<br> }<br>}<br></code></pre> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">库存服务从 RocketMQ 中消费支付消息,并处理扣库存的逻辑:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">public class InventoryService {<br><br> private DefaultMQPushConsumer consumer;<br><br> public InventoryService() throws Exception {<br> consumer = new DefaultMQPushConsumer(<span style="color: #98c379;line-height: 26px;">"InventoryConsumerGroup"</span>);<br> consumer.setNamesrvAddr(<span style="color: #98c379;line-height: 26px;">"localhost:9876"</span>);<br> consumer.subscribe(<span style="color: #98c379;line-height: 26px;">"paymentTopic"</span>, <span style="color: #98c379;line-height: 26px;">"paymentTag"</span>);<br><br> // 消息监听器<br> consumer.registerMessageListener((msgs, context) -> {<br> <span style="color: #c678dd;line-height: 26px;">for</span> (MessageExt msg : msgs) {<br> String messageBody = new String(msg.getBody());<br> // 执行扣库存操作<br> reduceStock(messageBody);<br> }<br> <span style="color: #e6c07b;line-height: 26px;">return</span> null; // 返回消费成功<br> });<br><br> consumer.start();<br> System.out.println(<span style="color: #98c379;line-height: 26px;">"InventoryService started..."</span>);<br> }<br>}<br><br></code></pre> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">3.流量削锋</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">在高并发的情况下,有些请求可能会产生瞬时流量峰值,直接处理可能会导致服务过载。比如:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 春运快到了,12306的抢票就是这种案例。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 又或者双12这种大促,订单压力会比较大。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 秒杀的时候,也需要避免流量暴涨,打垮应用系统的风险 </section></li> </ul> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这些场景,我们都可以使用MQ来进行流量的削峰填谷,确保系统平稳运行。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><img class="rich_pages wxw-img" data-imgfileid="100029242" data-ratio="0.21443965517241378" src="/upload/e66d3d85275c2247d45962e4e5ac8bfe.png" data-w="928"></p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">假设秒杀系统每秒最多可以处理2k个请求,每秒却有5k的请求过来,可以引入消息队列,秒杀系统每秒从消息队列拉2k请求处理得了。</p> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">4.延时任务</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;border-top: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(239, 112, 96);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 249, 249);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <span style="display: none;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0px;"></span> <p style="text-indent: 0em;padding-top: 8px;padding-bottom: 8px;color: rgb(0, 0, 0);line-height: 1.8em;letter-spacing: 0px;">在电商平台的订单处理中,如果用户下单后一定时间内未支付,需要自动取消订单。通过MQ的<strong style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">延时队列功能</strong>,可以设置消息延迟消费的时间,当消息到达延迟时间后,由消费者处理取消订单的逻辑。</p> </blockquote> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">当用户下单时,生成一个订单并发送一条延迟消息到RocketMQ。延迟时间可以根据订单的超时时间设置:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">@Service<br>public class OrderService {<br> <br> @Autowired<br> private RocketMQTemplate rocketMQTemplate;<br> <br> public void createOrder(Order order) {<br> // 保存订单逻辑(省略)<br> <br> // 计算延迟时间(单位:毫秒)<br> long delay = order.getTimeout();<br> <br> // 发送延迟消息<br> rocketMQTemplate.syncSend(<span style="color: #98c379;line-height: 26px;">"orderCancelTopic:delay"</span> + delay,<br> MessageBuilder.withPayload(order).build(),<br> 10000, // 消息发送超时时间(单位:毫秒)<br> (int) (delay / 1000) // RocketMQ的延迟级别是以秒为单位的,因此需要转换为秒<br> );<br> }<br>}<br></code></pre> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;border-top: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(239, 112, 96);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 249, 249);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <span style="display: none;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0px;"></span> <p style="text-indent: 0em;padding-top: 8px;padding-bottom: 8px;color: rgb(0, 0, 0);line-height: 1.8em;letter-spacing: 0px;">注意:RocketMQ的延迟级别是固定的,如1s、5s、10s等。如果订单的延迟时间不是RocketMQ支持的延迟级别的整数倍,那么消息将不会精确地在预期的延迟时间后被消费。为了解决这个问题,你可以选择最接近的延迟级别,或者根据业务需求进行适当的调整。</p> </blockquote> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">创建一个用来消费延迟消息的消费者,处理取消订单的逻辑。例如:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">@Component<br>@RocketMQMessageListener(topic = <span style="color: #98c379;line-height: 26px;">"orderCancelTopic"</span>, consumerGroup = <span style="color: #98c379;line-height: 26px;">"order-cancel-consumer-group"</span>)<br>public class OrderCancelListener implements RocketMQListener <order> { <br> <br> @Override <br> public void onMessage(Order order) { <br> // 取消订单逻辑 <br> // 检查订单状态,如果订单仍处于未支付状态则进行取消 <br> System.out.println( <span style="color: #98c379;line-height: 26px;">"Cancelling order: "</span> + order.getOrderId()); <br> // (省略实际的取消订单逻辑) <br> } <br>} <br> </order></code></pre> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">5. 日志收集</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">消息队列常用于日志系统中,将应用生成的日志异步地发送到日志处理系统,进行统一存储和分析。</p> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 假设你有一个微服务架构,每个微服务都会生成日志。你可以将这些日志通过消息队列(如Kafka)发送到一个集中式的日志收集系统(如 ELK(Elasticsearch, Logstash, Kibana) 或 Fluentd),从而实现日志的统一管理。 </section> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">生产者(发送日志到 Kafka)</strong></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">// 配置和发送日志到 Kafka 主题 <span style="color: #98c379;line-height: 26px;">"app-logs"</span><br>KafkaProducer <string, string> producer = new KafkaProducer<>(config); <br>String logMessage = <span style="color: #98c379;line-height: 26px;">"{\"level\": \"INFO\", \"message\": \"Application started\", \"timestamp\": \"2024-12-29T20:30:59\"}"</span>; <br>producer.send(new ProducerRecord<>( <span style="color: #98c379;line-height: 26px;">"app-logs"</span>, <span style="color: #98c379;line-height: 26px;">"log-key"</span>, logMessage)); <br> </string, string></code></pre> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">消费者(收集日志信息)</strong></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">@Service<br>public class LogConsumer {<br> // 使用 @KafkaListener 注解来消费 Kafka 中的日志<br> @KafkaListener(topics = <span style="color: #98c379;line-height: 26px;">"app-logs"</span>, groupId = <span style="color: #98c379;line-height: 26px;">"log-consumer-group"</span>)<br> public void consumeLog(String logMessage) {<br> // 打印或处理收到的日志<br> System.out.println(<span style="color: #98c379;line-height: 26px;">"Received log: "</span> + logMessage);<br> }<br>}<br><br></code></pre> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">6.分布式事务</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">业界经常使用<code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>MQ</code>来实现分布式事务。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">我举个下订单的场景,使用MQ实现分布式事务的例子吧。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">我们先来看,一条普通的MQ消息,从产生到被消费,大概流程如下:</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><img class="rich_pages wxw-img" data-imgfileid="100029243" data-ratio="0.5354713313896987" src="/upload/82abc939caffc9df681d055073cd9bc1.png" data-w="1029"></p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 生产者产生消息,发送带MQ服务器 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> MQ收到消息后,将消息持久化到存储系统。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> MQ服务器返回ACk到生产者。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> MQ服务器把消息push给消费者 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 消费者消费完消息,响应ACK </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> MQ服务器收到ACK,认为消息消费成功,即在存储中删除消息。 </section></li> </ul> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">回到<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">下订单</strong>这个例子,订单系统创建完订单后,再发送消息给下游系统。如果订单创建成功,然后消息没有成功发送出去,下游系统就无法感知这个事情,出导致数据不一致。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这时候就可以使用MQ实现分布式事务消息。大家看下这个流程:</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><img class="rich_pages wxw-img" data-imgfileid="100029244" data-ratio="0.6591549295774648" src="/upload/fcb8d73929df4f26c9e90240213373be.png" data-w="1065"></p> <ol data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 生产者产生消息,发送一条半事务消息到MQ服务器 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> MQ收到消息后,将消息持久化到存储系统,这条消息的状态是待发送状态。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> MQ服务器返回ACK确认到生产者,此时MQ不会触发消息推送事件 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 生产者执行本地事务 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 如果本地事务执行成功,即commit执行结果到MQ服务器;如果执行失败,发送rollback。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 如果是正常的commit,MQ服务器更新消息状态为可发送;如果是rollback,即删除消息。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 如果消息状态更新为可发送,则MQ服务器会push消息给消费者。消费者消费完就回ACK。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 如果MQ服务器长时间没有收到生产者的commit或者rollback,它会反查生产者,然后根据查询到的结果执行最终状态。 </section></li> </ol> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">7. 远程调用</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">我以前公司(微众)基于MQ(RocketMQ),自研了<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">远程调用框架</strong>。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">RocketMQ 作为远程调用框架,主要就是金融场景的适配性。</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">消息查询功能</strong>:RocketMQ提供了消息查询功能,方便微众银行在需要时进行消息对账或问题排查。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">金融级稳定性</strong>:RocketMQ在金融领域的应用非常广泛,得到了众多金融机构的认可。其稳定性和可靠性能够满足微众银行对金融级消息服务的需求。 </section></li> </ul> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">还有可以基于RocketMQ的定制开发:<strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">多中心多活、灰度发布、流量权重与消息去重、背压模式</strong>(能够根据后续服务的治理能力决定拉取的消息数量,确保系统的稳定运行。)</p> <h2 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 3px 3px 0px 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-right: 5px;overflow: unset;padding: 3px 10px 1px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">8. 广播通知:事件驱动的消息通知</span><span style="display: none;"></span><span style="border-color: rgb(0, 0, 0) transparent rgb(239, 235, 233) rgb(0, 0, 0);align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none solid solid none;border-width: 1px 20px 36px 1px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"> </span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">消息队列(MQ) 可以非常适合用于 广播通知。在广播通知场景中,消息队列可以将消息推送到多个订阅者,让不同的服务或者应用接收到通知。</p> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;border-top: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(239, 112, 96);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 249, 249);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <span style="display: none;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0px;"></span> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;"> <strong>系统通知</strong>:向所有用户广播应用更新、系统维护、公告通知等。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">事件驱动的消息通知</strong>:如库存更新、用户状态变化、订单支付成功等事件通知,多个系统可以订阅这个事件。 </section></li> </ul> </blockquote> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">针对事件驱动的消息通知,我们以 <strong style="background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">订单支付成功</strong> 事件为例,假设多个系统(如库存管理系统、用户积分系统、财务系统等)都需要监听这个事件来进行相应处理。</p> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100029245" data-ratio="0.4887323943661972" data-s="300,640" src="/upload/1875d6c9384380586891d77a7873ddf0.png" data-type="png" data-w="710" style=""></p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">当订单支付成功 事件发生时,系统会通过消息队列广播一个事件通知(比如消息内容是订单ID、支付金额等),其他系统可以根据这个事件来执行相应的操作,如:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 库存系统:根据订单信息减少库存。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 用户积分系统:增加用户积分。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> 财务系统:记录支付流水。 </section></li> </ul> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">发送订单支付成功事件:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">// 创建订单支付成功事件消息<br>String orderEventData = <span style="color: #98c379;line-height: 26px;">"{\"orderId\": 12345, \"userId\": 67890, \"amount\": 100.0, \"event\": \"ORDER_PAYMENT_SUCCESS\"}"</span>;<br>Message msg = new Message(<span style="color: #98c379;line-height: 26px;">"order_event_topic"</span>, <span style="color: #98c379;line-height: 26px;">"order_payment_success"</span>, orderEventData.getBytes());<br><br>// 发送消息<br>producer.send(msg);<br></code></pre> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">事件消费者(接收并处理订单支付成功事件):</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">库存系统:</strong> </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"> // 注册消息监听器<br> consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {<br> <span style="color: #c678dd;line-height: 26px;">for</span> (Message msg : msgs) {<br> String eventData = new String(msg.getBody());<br> System.out.println(<span style="color: #98c379;line-height: 26px;">"Inventory system received: "</span> + eventData);<br> <br> // 处理库存减少逻辑<br> // 解析消息(假设是 JSON 格式)<br> // updateInventory(eventData); // 假设调用库存更新方法<br> }<br> <span style="color: #e6c07b;line-height: 26px;">return</span> ConsumeConcurrentlyStatus.CONSUME_SUCCESS;<br> });<br></code></pre> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">积分系统:</strong> </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"> // 注册消息监听器<br> consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {<br> <span style="color: #c678dd;line-height: 26px;">for</span> (Message msg : msgs) {<br> String eventData = new String(msg.getBody());<br> System.out.println(<span style="color: #98c379;line-height: 26px;">"Points system received: "</span> + eventData);<br><br> // 处理用户积分增加逻辑<br> // updateUserPoints(eventData); // 假设调用积分更新方法<br> }<br> <span style="color: #e6c07b;line-height: 26px;">return</span> ConsumeConcurrentlyStatus.CONSUME_SUCCESS;<br> });<br></code></pre> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <strong style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">财务系统:</strong> </section></li> </ul> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg ush8nb3hz5sy4v8gawec7p7juufjaqiofrp7arx6vkmia2gwvqicnuqzqvpxs3dsbjxmibjt4gpey5omtd2rpq2rupkmxjz56 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"> // 注册消息监听器<br> consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {<br> <span style="color: #c678dd;line-height: 26px;">for</span> (Message msg : msgs) {<br> String eventData = new String(msg.getBody());<br> System.out.println(<span style="color: #98c379;line-height: 26px;">"Finance system received: "</span> + eventData);<br><br> // 处理财务记录逻辑<br> // recordPaymentTransaction(eventData); // 假设调用财务记录方法<br> }<br> <span style="color: #e6c07b;line-height: 26px;">return</span> ConsumeConcurrentlyStatus.CONSUME_SUCCESS;<br> });<br></code></pre> </section> <section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="-webkit-tap-highlight-color: transparent;margin-bottom: 0px;padding-right: 10px;padding-left: 10px;outline: 0px;white-space: normal;word-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;word-break: break-word;text-align: left;> <blockquote data-tool="mdnice编辑器" style="-webkit-tap-highlight-color: transparent;margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-top: 3px none rgba(0, 0, 0, 0.4);border-right: 3px none rgba(0, 0, 0, 0.4);border-bottom: 3px none rgba(0, 0, 0, 0.4);border-left-color: rgb(239, 112, 96);color: var(--weui-FG-1);border-radius: 0px;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 249, 249);width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;overflow: auto;"> <p style="-webkit-tap-highlight-color: transparent;padding-top: 8px;padding-bottom: 8px;outline: 0px;text-indent: 0em;color: rgb(0, 0, 0);line-height: 1.8em;letter-spacing: 0px;">最后,坚持创作不易,田螺哥工作七年多,整理了日常工作的踩坑专栏,已经更新到83篇啦~有需要的伙伴可以购买,购买了的伙伴,都说非常有用,很多坑自己也踩过,49.9永久买断</p> </blockquote> </section>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, PingFangSC-light, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;text-align: left;" data-mpa-powered-by="yiban.io"> <h1 data-tool="mdnice编辑器" style="border-color: rgb(248, 57, 41) rgb(0, 0, 0) rgb(0, 0, 0);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: solid none none;border-width: 2px 1px 1px;border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: center;line-height: 1.5em;overflow: unset;text-align: center;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(255, 255, 255);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 57, 41);line-height: 1.8em;letter-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px 0px 13px 13px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 3px 5px 5px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">面试官之问:知道你的接口“QPS”是多少吗?</span><span style="display: none;"></span></h1> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">1. 什么是QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> QPS(Query Per Second)即每秒请求数,是指服务器在一秒内能处理的请求数量。它是衡量服务器处理能力的一个重要指标。</p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">2. 如何估算接口的QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 估算接口QPS的方法主要有两种:</p> <ol data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">自己在接口里记录</strong>:在接口中记录能体现该接口特性的、具有唯一性的字符串,然后通过统计日志中该字符串的出现次数来估算QPS。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">利用Tomcat的access log</strong>:通过配置Tomcat的access log功能,记录访问日志,然后统计特定接口日志的出现次数来估算QPS。 </section></li> </ol> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">3. 如何在接口中记录QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 在接口中记录QPS可以通过在代码中添加日志记录来实现。例如,在Spring Boot应用中,可以在接口方法中添加一个唯一的日志信息:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg anblvjpkybmxxiatva61gmocfjxfaifwiblktajqo0bahpswk5lwko5wmiae1cfib2xxsjb4imxkyhorcczom3tdkybkqibwiwpiav 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;">@RestController</span><br><span style="color: #61aeee;line-height: 26px;">@RequestMapping</span>(<span style="color: #98c379;line-height: 26px;">"/home"</span>)<br><span style="color: #c678dd;line-height: 26px;">public</span> <span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">class</span> <span style="color: #e6c07b;line-height: 26px;">IndexController</span> </span>{<br> <span style="color: #5c6370;font-style: italic;line-height: 26px;">// 省略其他代码</span><br> <span style="color: #61aeee;line-height: 26px;">@RequestMapping</span>(<span style="color: #98c379;line-height: 26px;">"/index"</span>)<br> <span style="line-height: 26px;">String <span style="color: #61aeee;line-height: 26px;">index</span><span style="line-height: 26px;">()</span> </span>{<br> Logger logger = LoggerFactory.getLogger(IndexController<span style="line-height: 26px;">.<span style="color: #c678dd;line-height: 26px;">class</span>)</span>;<br> logger.info(<span style="color: #98c379;line-height: 26px;">"渣渣辉"</span>); <span style="color: #5c6370;font-style: italic;line-height: 26px;">// 唯一性的字符串</span><br> <span style="color: #c678dd;line-height: 26px;">return</span> <span style="color: #98c379;line-height: 26px;">"index"</span>;<br> }<br>}<br></code></pre> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">4. 如何使用Tomcat的access log来估算QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 要使用Tomcat的access log功能,需要在配置文件中设置以下属性:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg anblvjpkybmxxiatva61gmocfjxfaifwiblktajqo0bahpswk5lwko5wmiae1cfib2xxsjb4imxkyhorcczom3tdkybkqibwiwpiav 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">server.tomcat.accesslog.directory=logs<br>server.tomcat.accesslog.enabled=true<br></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这样,每次访问接口时,Tomcat都会在日志中记录一条访问记录,格式如下:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg anblvjpkybmxxiatva61gmocfjxfaifwiblktajqo0bahpswk5lwko5wmiae1cfib2xxsjb4imxkyhorcczom3tdkybkqibwiwpiav 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">127.0.0.1 - - [19/Aug/2019:23:55:27 +0800] <span style="color: #98c379;line-height: 26px;">"POST /home/index HTTP/1.1"</span> 200 138<br></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">通过统计日志中特定接口记录的出现次数,就可以估算出该接口的QPS。</p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">5. 如何通过日志文件统计QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 可以通过执行一系列命令来统计日志文件中的QPS。例如,对于一个名为<code style="color: rgb(248, 57, 41);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;height: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>xxx.log</code>的日志文件,可以使用以下命令:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg anblvjpkybmxxiatva61gmocfjxfaifwiblktajqo0bahpswk5lwko5wmiae1cfib2xxsjb4imxkyhorcczom3tdkybkqibwiwpiav 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">cat xxx.log | grep <span style="color: #98c379;line-height: 26px;">'GET /mvc2'</span> | cut -d <span style="color: #98c379;line-height: 26px;">' '</span> -f4 | uniq -c | sort -n -r<br></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这个命令的意思是:</p> <ul data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>cat xxx.log</code>:读取日志文件内容。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>grep 'GET /mvc2'</code>:过滤出包含<code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>GET /mvc2</code>的行。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>cut -d ' ' -f4</code>:提取每行的第四个字段(通常是时间戳)。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>uniq -c</code>:统计每个唯一时间戳的出现次数。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;"> <code style="background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin-left: 2px;margin-right: 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;font-family: " operator mono, consolas, monaco, menlo, monospace;word-break: break-all;>sort -n -r</code>:按数值排序并反向输出,以便最高的QPS值在最上面。 </section></li> </ul> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">6. 如何估算集群的QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 估算集群的QPS需要根据负载均衡的策略来确定。例如,如果使用了轮询策略,并且有32台机器,那么集群的QPS大约是单机QPS的32倍。</p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">7. 如何估算系统能承受秒杀活动的QPS?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 假设预估有三千万流量,根据二八原则,80%的流量是在20%的时间段内产生的,可以预估QPS如下:</p> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="304196186" data-ratio="0.15471698113207547" data-s="300,640" data-type="png" data-w="265" style="height: auto !important;" src="/upload/6f297b2c1badd22ba0a1a91dffe48c0f.png"></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">即当前系统每天平均QPS为2777。还需要计算当天最高QPS可以通过系统平均OPS的倍数计算出来。比如我们预先得知系统的的最高倍数为平均的1.5倍,那么会得到系统峰值的QPS为:</p> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="304196187" data-ratio="0.11475409836065574" data-s="300,640" data-type="png" data-w="244" style="height: auto !important;" src="/upload/0a4c8eabe65b8e946244eb55e35e2c16.png"></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">这样我们可以计算出这个秒杀活动大概需要多少台机器可以承受的住。我们可以使用压测工具计算出每台机器可承受的QPS,比如为500,那么我们就可以计算出需要的机器数为:</p> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="304196188" data-ratio="0.24" data-s="300,640" data-type="png" data-w="125" style="height: auto !important;" src="/upload/f0479821413fe030013b18fcb27d3d99.png"></p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">即大约需要8台机器。这种方法是一种粗略的指导方向,具体我们还需要根据业务打出富余。</p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(34, 34, 34);line-height: 1.8em;letter-spacing: 0em;padding-left: 10px;border-style: none none none solid;border-width: 1px 1px 1px 5px;border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(248, 57, 41);border-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">8. 为什么说一般2000QPS就够了?</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><strong style="color: rgb(248, 57, 41);background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;">答:</strong> 这个数字并不是绝对的,它取决于具体的业务需求和系统设计。但是,2000QPS对于许多应用来说已经足够高,能够满足大部分场景的需求。如果需要处理更高的QPS,可能需要优化系统架构、增加服务器或者使用更高效的负载均衡策略。</p> <p data-tool="mdnice编辑器" style="color: rgb(53, 53, 53);line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">以上是关于如何估算接口QPS的面试问答,涵盖了QPS的概念、估算方法、日志记录、命令统计以及集群QPS的估算,以及如何估算系统能承受秒杀活动的QPS。</p> </section>
作者:微信小助手
<p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">大家好,我是牛皮糖!</span></strong><span leaf=""> 今天要给大家带来一个超级实用的开源项目——</span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">PDFMathTranslate</span></strong><span leaf="">。这个项目,对于科研工作者和学术研究者来说,简直就是神器一般的存在!</span></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100004992" data-ratio="0.4982078853046595" data-s="300,640" src="/upload/c26ebd171b2699dda5634f1650d29e8c.png" data-type="png" data-w="1116" type="block"></span></p> <p style="font-family: " microsoft yahei;font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">🚀 快速阅读:</span></strong></p> <ol style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">1. </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">PDFMathTranslate</span></strong><span leaf=""> 是一款开源的 PDF 文档翻译工具,支持科技论文等 PDF 文件的翻译,保留原文排版,包括公式和图表。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf=""><img src="/upload/a7a2fea58633255881603611a5f60599.png" class="rich_pages wxw-img" data-ratio="0.5901730876605249" data-s="300,640" data-type="png" data-w="1791" type="block" data-imgfileid="100004990"></span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">2. 支持双语对照,保持原有目录结构,兼容多种翻译服务,如 Google、DeepL、Ollama 和 OpenAI 等。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">3. 可通过命令行工具进行操作,实现文档的快速翻译和双语对照查看。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section style="text-align: center;" nodeleaf=""> <img class="rich_pages wxw-img" data-imgfileid="100004994" data-ratio="0.7333333333333333" data-s="300,640" src="/upload/ac4e3a5e974a6d1c35278136a701fcc4.png" data-type="png" data-w="1080" type="block"> </section></li> </ol> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">PDFMathTranslate 是什么:</span></strong></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf=""> </span></strong><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">PDFMathTranslate</span></strong><span leaf="">是一款开源的 PDF 文档翻译工具,设计用于翻译科技论文等 PDF 文件。它能保留原文的排版,包括公式和图表,支持双语对照,保持原有目录结构,兼容多种翻译服务,如 Google、DeepL、Ollama 和 OpenAI 等。用户基于命令行工具操作,实现文档的快速翻译和双语对照查看。</span></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">PDFMathTranslate 的主要功能:</span></strong></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">保留原排版</span></strong><span leaf="">:</span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">PDFMathTranslate</span></strong><span leaf="">能完整保留 PDF 文档中的公式、图表和目录结构,确保翻译后的文档与原文版式一致。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">双语对照</span></strong><span leaf="">:支持生成双语对照文档,方便用户对照原文和译文。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">全文翻译</span></strong><span leaf="">:提供全文翻译功能,用户可以选择翻译整个文档。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">部分文档翻译</span></strong><span leaf="">:支持用户选择特定页面或章节进行翻译。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">多种翻译服务支持</span></strong><span leaf="">:兼容 Google、DeepL、Ollama、OpenAI 等多种翻译服务,用户可以根据需求选择。</span> </section></li> </ul> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">如何运行 PDFMathTranslate:</span></strong><span leaf=""> 安装要求 Python 版本 >=3.8, <=3.12,使用以下命令安装:</span></p> <pre style="color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;padding: 0px !important;><span data-cacheurl="" data-remoteid="" style="padding: initial;display: block;height: 25px;background-color: transparent;background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/4QtDCkraacMByAuVSn6pN8urYnffnOTN540xISyE46SdQLFapNvWrxayiadXSeN91mtratz1WFADg6TCygDpeSRf0bfIibK0Sk/640?wx_fmt=svg&from=appmsg);"></span><code style="display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;font-family: Menlo, " operator mono, consolas, monaco, monospace;font-size: 14px;margin: 0px;white-space: nowrap;><span leaf="">pip install pdf2zh</span></code></pre> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">在命令行中执行翻译指令,在工作目录下生成翻译文档 </span><code style="text-align: left;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">example-zh.pdf</span></code><span leaf=""> 和双语对照文档 </span><code style="text-align: left;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">example-dual.pdf</span></code><span leaf="">,默认使用 Google 作为翻译服务。</span></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">项目地址:</span></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">https://github.com/Byaidu/PDFMathTranslate</span><span style="text-align: left;line-height: 1.75;color: rgb(87, 107, 149);"><span leaf=""><br></span></span></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span style="text-align: left;line-height: 1.75;color: rgb(87, 107, 149);"><span leaf="">也可以在线体验:https://pdf2zh.com/</span></span></p>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com"> <h2 data-tool="mdnice编辑器" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top: 1px solid rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">本文目录</span></h2> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><strong><span style="font-size: 14px;">- </span></strong></strong><strong>尼恩说在前面</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><span style="font-size: 14px;">- </span></strong>招商银行的高阶Java后端面试真题</strong></p> <h5 data-sourcepos="299:1-299:178" style="letter-spacing: 0.578px;white-space: normal;"><span style="font-size: 14px;letter-spacing: 0.578px;"> -</span><span style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.034em;>尼恩将给出全部答案:</span></h5> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><strong><span style="font-size: 14px;">- </span></strong></strong><strong>本文目录</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><span style="font-size: 14px;">- </span></strong>招行面试:如何根据应用场景选择合适的消息中间件?</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><span style="font-size: 14px;">- </span></strong>三大MQ的简单对比</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><span style="font-size: 14px;">- </span></strong>第一大mq:RabbitMQ</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>RabbitMQ优点</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>RabbitMQ缺点</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>RabbitMQ使用场景:</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><strong><span style="font-size: 14px;">- </span></strong></strong><strong>第二大mq:Kafka</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>Kafka优点:</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>Kafka缺点:</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>Kafka使用场景:</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><strong><span style="font-size: 14px;">- </span></strong></strong><strong>第三大mq:RocketMQ</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>RocketMQ优点</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>RocketMQ缺点</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>为什么阿里会自研RocketMQ?</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><strong><span style="font-size: 14px;">- </span></strong></strong><strong>RocketMQ、Kafka、RabbitMQ的全面对比和PK</strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 性能PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 功能PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 可靠性 PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 运维 PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 社区生态 PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 支持的队列数 PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><span style="font-family: " helvetica neue;font-size: 14px;letter-spacing: 0.578px;> - </span>三大mq 适用场景 PK</p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong style="font-family: " helvetica neue;font-size: 13px;letter-spacing: 0.578px;white-space: normal;><strong><span style="font-size: 14px;">- </span></strong></strong><strong><span style="font-stretch: normal;font-family: " pingfang sc;>三大</span>mq <span style="font-stretch: normal;font-family: " pingfang sc;>如何选择?</span></strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong><span style="font-stretch: normal;font-family: " pingfang sc;>- 说在最后:有问题找老架构取经</span></strong></p> <p style="font-stretch: normal;font-size: 13px;font-family: " helvetica neue;><strong><span style="font-stretch: normal;font-family: " pingfang sc;><br></span></strong></p> <h2 data-sourcepos="81:1-81:73" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">招行面试:如何根据应用场景选择合适的消息中间件?</span></h2> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">分布式、微服务、高并发架构中,消息队列(Message Queue,简称MQ)扮演着至关重要的角色。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">消息队列用于实现系统间的异步通信、解耦、削峰填谷等功能。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">目前常见的MQ实现包括RabbitMQ、RocketMQ和Kafka。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RocketMQ、Kafka、RabbitMQ如何选择?</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">接下来,尼恩给大家 对比RocketMQ和RabbitMQ和Kafka,帮助大家在技术选型时做出最佳的技术选型。</span> </section> <h2 data-sourcepos="94:1-94:26" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">三大MQ的简单对比</span></h2> <table data-sourcepos="96:1-104:77" style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;"> <thead style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;"> <tr data-sourcepos="96:1-96:70" style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;"> <td style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;"><strong><span style="font-size: 15px;">特性</span></strong></td> <td style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;" width="166"><strong><span style="font-size: 15px;">RabbitMQ</span></strong></td> <td style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;" width="93"><strong><span style="font-size: 15px;">RocketMQ</span></strong></td> <td style="line-height: 1.75em;padding: 6px 13px;border-color: rgb(198, 203, 209) rgb(223, 226, 229) rgb(223, 226, 229);background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;" width="79"><strong><span style="font-size: 15px;">Kafka</span></strong></td> </tr> </thead> <tbody> <tr data-sourcepos="98:1-98:74" style="background-color: rgb(255, 255, 255);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="98:2-98:17" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">公司/社区</span> </section></td> <td data-sourcepos="98:19-98:43" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">Rabbit</span> </section></td> <td data-sourcepos="98:45-98:58" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">阿里</span> </section></td> <td data-sourcepos="98:60-98:73" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">Apache</span> </section></td> </tr> <tr data-sourcepos="99:1-99:72" style="background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="99:2-99:17" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">开发语言</span> </section></td> <td data-sourcepos="99:19-99:43" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">Erlang</span> </section></td> <td data-sourcepos="99:45-99:56" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">Java</span> </section></td> <td data-sourcepos="99:58-99:71" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">Scala & Java</span> </section></td> </tr> <tr data-sourcepos="100:1-100:85" style="background-color: rgb(255, 255, 255);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="100:2-100:17" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">协议支持</span> </section></td> <td data-sourcepos="100:19-100:46" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">AMQP,XMPP,SMTP,STOMP</span> </section></td> <td data-sourcepos="100:48-100:64" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">自定义协议</span> </section></td> <td data-sourcepos="100:66-100:84" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">自定义协议</span> </section></td> </tr> <tr data-sourcepos="101:1-101:74" style="background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="101:2-101:16" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">可用性</span> </section></td> <td data-sourcepos="101:18-101:43" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">高</span> </section></td> <td data-sourcepos="101:45-101:57" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">高</span> </section></td> <td data-sourcepos="101:59-101:73" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">高</span> </section></td> </tr> <tr data-sourcepos="102:1-102:79" style="background-color: rgb(255, 255, 255);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="102:2-102:18" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">单机吞吐量</span> </section></td> <td data-sourcepos="102:20-102:46" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">一般</span> </section></td> <td data-sourcepos="102:48-102:60" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">高</span> </section></td> <td data-sourcepos="102:62-102:78" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">非常高</span> </section></td> </tr> <tr data-sourcepos="103:1-103:82" style="background-color: rgb(246, 248, 250);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="103:2-103:17" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">消息延迟</span> </section></td> <td data-sourcepos="103:19-103:46" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">微秒级</span> </section></td> <td data-sourcepos="103:48-103:62" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">毫秒级</span> </section></td> <td data-sourcepos="103:64-103:81" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">毫秒以内</span> </section></td> </tr> <tr data-sourcepos="104:1-104:77" style="background-color: rgb(255, 255, 255);border-top-width: 1px;border-top-style: solid;border-top-color: rgb(198, 203, 209);"> <td data-sourcepos="104:2-104:18" style="padding: 6px 13px;border-color: rgb(223, 226, 229);"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">消息可靠性</span> </section></td> <td data-sourcepos="104:20-104:45" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="146"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">高</span> </section></td> <td data-sourcepos="104:47-104:59" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="113"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">高</span> </section></td> <td data-sourcepos="104:61-104:76" style="padding: 6px 13px;border-color: rgb(223, 226, 229);" width="99"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">一般</span> </section></td> </tr> </tbody> </table> <h2 data-sourcepos="106:1-106:25" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">第一大mq:RabbitMQ</span></h2> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RabbitMQ是由Pivotal开发的开源消息队列系统,基于Erlang语言开发,采用 AMQP(Advanced Message Queuing Protocol)协议。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <img class="rich_pages wxw-img" data-imgfileid="100020801" data-ratio="0.47863247863247865" src="/upload/9d47c0c14390f9b5a286f432755a6d62.jpg" data-type="jpeg" data-w="702" style="box-sizing: content-box;border-style: none;background-color: rgb(255, 255, 255);"> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">以下是RabbitMQ的一些主要特点:</span> </section> <h3 data-sourcepos="116:1-116:18" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">RabbitMQ优点</span></h3> <ul data-sourcepos="118:1-122:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>高可靠性</strong>:RabbitMQ支持消息持久化、确认机制和死信队列等功能,确保消息不会丢失。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>灵活的路由机制</strong>:支持多种交换机类型(如直连交换机、主题交换机、扇出交换机等),能够灵活地根据业务需求路由消息。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>丰富的插件</strong>:RabbitMQ拥有丰富的插件支持,如管理界面插件、监控插件等,方便运维和管理。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>低延迟</strong>:在低延迟消息传递场景中表现出色,适用于实时性要求较高的业务场景。</span> </section></li> </ul> <h3 data-sourcepos="123:1-123:18" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">RabbitMQ缺点</span></h3> <ul data-sourcepos="125:1-127:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>性能瓶颈</strong>:在高并发和大吞吐量场景下,RabbitMQ可能会遇到性能瓶颈,需要进行性能调优。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>扩展性</strong>:虽然支持集群模式,但在大规模集群下的扩展性不如Kafka和RocketMQ。</span> </section></li> </ul> <h3 data-sourcepos="128:1-128:27" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">RabbitMQ使用场景:</span></h3> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">适用于中小型企业的一般消息队列需求,如异步任务处理、系统解耦、消息通知等场景 。</span> </section> <h2 data-sourcepos="132:1-132:22" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">第二大mq:Kafka</span></h2> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">Apache Kafka是一个分布式流处理平台,最初由LinkedIn开发,并于2011年开源。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">Kafka的设计初衷是用于高吞吐量、低延迟的数据流处理和实时数据管道。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">Kafka的核心组件包括生产者、消费者、主题和分区。</span> </section> <p style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100020803" data-ratio="0.5391849529780565" data-s="300,640" src="/upload/56262e9b11eed803956b5b2dabf3a51e.jpg" data-type="png" data-w="638" style=""></p> <section style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"> <span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">Kafka优点:</span> </section> <ul data-sourcepos="146:1-151:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>高吞吐量</strong>:Kafka能够处理每秒数百万条消息,适合大规模数据流处理。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>水平扩展性</strong>:通过分区机制,Kafka可以轻松扩展,支持大规模分布式部署。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>持久化存储</strong>:Kafka将消息持久化到磁盘,确保数据的可靠性和持久性。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>高可用性</strong>:通过复制机制,Kafka能够在节点故障时继续提供服务。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>低延迟</strong>:Kafka设计为低延迟系统,适合实时数据处理。</span> </section></li> </ul> <h3 data-sourcepos="152:1-152:18" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">Kafka缺点:</span></h3> <ul data-sourcepos="154:1-157:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>复杂性</strong>:Kafka的部署和管理相对复杂,需要专业知识和经验。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>资源占用</strong>:Kafka对硬件资源要求较高,特别是磁盘和网络带宽。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>延迟一致性</strong>:Kafka采用最终一致性模型,可能导致短暂的不一致。</span> </section></li> </ul> <h3 data-sourcepos="158:1-158:24" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">Kafka使用场景:</span></h3> <ul data-sourcepos="160:1-166:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>实时数据处理</strong>:需要处理高吞吐量、低延迟的数据流,如实时日志分析、实时监控和实时推荐系统。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>大数据管道</strong>:构建数据管道,将数据从不同来源高效传输到数据湖或数据仓库。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>事件驱动架构</strong>:实现事件驱动的微服务架构,支持事件的发布和订阅。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>日志聚合</strong>:集中收集和处理分布式系统的日志数据,进行统一分析和监控。</span> </section></li> </ul> <h2 data-sourcepos="167:1-167:25" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">第三大mq:RocketMQ</span></h2> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RocketMQ是阿里巴巴开源的一款分布式消息队列系统,采用Java语言开发,具备高性能、高可靠性和高可用性的特点。2016年捐赠给Apache基金会。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RocketMQ的设计目标是高可靠性、高性能和高可用性,支持分布式事务和顺序消息等高级特性。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RocketMQ的核心组件包括生产者、消费者、主题和队列。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <img class="rich_pages wxw-img" data-imgfileid="100020802" data-ratio="0.38981481481481484" src="/upload/2a3a6cfa71204f8962657e195989e8e9.png" data-type="png" data-w="1080" style="box-sizing: content-box;border-style: none;background-color: rgb(255, 255, 255);"> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">以下是RocketMQ的一些主要特点:</span> </section> <h3 data-sourcepos="181:1-181:18" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">RocketMQ优点</span></h3> <ul data-sourcepos="183:1-188:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>高吞吐量</strong>:RocketMQ设计之初就考虑到了高吞吐量的需求,适用于大规模的消息传输场景。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>分布式架构</strong>:天然支持分布式架构,易于横向扩展,适用于大规模集群部署。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>消息顺序</strong>:支持严格的消息顺序,满足对消息顺序性有严格要求的业务场景。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>灵活的消费模式</strong>:支持多种消费模式,包括广播消费和集群消费。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>丰富的功能</strong>:支持定时消息、延迟消息、死信队列和批量消息等高级功能,满足复杂业务需求。</span> </section></li> </ul> <h3 data-sourcepos="189:1-189:18" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">RocketMQ缺点</span></h3> <ul data-sourcepos="191:1-194:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>社区活跃度</strong>:是国产的消息中间件,有活跃的国内社区支持,相关的技术文档和案例较为丰富,同时也得到了阿里巴巴等企业的技术支持。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>学习成本</strong>:相比RabbitMQ,RocketMQ的配置和使用相对复杂,学习成本较高。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>生态系统</strong>:虽然正在快速发展,但RocketMQ的生态系统和社区支持相比RabbitMQ和Kafka还有一定差距。</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;"><strong>RocketMQ使用场景:</strong></span> </section> <ul data-sourcepos="197:1-203:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>金融交易系统</strong>:需要高可靠性和顺序消息处理的金融交易系统。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>电商平台</strong>:处理高并发订单和支付消息,确保消息的可靠传递和顺序处理。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>分布式事务</strong>:支持分布式事务的业务场景,如跨服务的事务管理。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>消息通知系统</strong>:实现高可靠性的消息通知和广播,如短信、邮件通知系统。</span> </section></li> </ul> <h3 data-sourcepos="204:1-204:39" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">为什么阿里会自研RocketMQ?</span></h3> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">(1)Kafka的业务应用场景主要定位于日志传输;对于复杂业务支持不够</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">(2)阿里很多业务场景对<strong>数据可靠性、数据实时性、消息队列的个数等</strong>方面的要求很高。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">kafka针对海量数据,但是对数据的正确度要求不是十分严格。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">而阿里巴巴中用于交易相关的事情较多,对数据的正确性要求极高,Kafka不合适</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">(3)当业务成长到一定规模,采用开源方案的技术成本会变高.</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">开源方案无法满足业务的需要;旧版本、自开发代码与新版本的兼容都可能是问题;运维角度,Kafka使用 scala 编写,而阿里是java系。Kafka 的后续维护是个问题。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">(4)阿里在团队、成本、资源投入等方面约束性条件几乎没有.</span> </section> <h2 data-sourcepos="222:1-222:50" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">RocketMQ、Kafka、RabbitMQ的全面对比和PK</span></h2> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RocketMQ、Kafka、RabbitMQ 都是常用的消息中间件 ,可从性能、功能、可靠性、运维复杂度等方面进行全面PK:</span> </section> <h3 data-sourcepos="226:1-226:21" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 性能PK</span></h3> <ul data-sourcepos="230:1-231:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RocketMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">10Wtps 级别。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">采用分布式架构,能支持高并发和低延迟的消息处理,在大规模数据处理场景下表现稳定,消息发送和消费的性能较高,适合对性能要求较高的分布式系统。</span> </section> <ul data-sourcepos="236:1-237:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>Kafka</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">10Wtps 级别。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">以高吞吐量著称,擅长处理大规模的消息流数据,适用于对实时性要求高、数据量大的场景,如日志收集、实时数据处理等。</span> </section> <ul data-sourcepos="242:1-243:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RabbitMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">1Wtps 级别。</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">性能相对较弱,在处理大量消息时可能会出现性能瓶颈,但在小规模场景下表现良好,能满足一般的消息队列需求。</span> </section> <h3 data-sourcepos="248:1-248:22" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 功能PK</span></h3> <ul data-sourcepos="252:1-253:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RocketMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">支持事务消息、顺序消息、广播消息等高级特性,能满足一些对消息处理有严格要求的业务场景,如电商订单处理等。</span> </section> <ul data-sourcepos="256:1-257:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>Kafka</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">具有强大的分区、副本和多副本机制,能保证数据的高可用性和可靠性,同时支持消息的批量处理和压缩,提高了数据传输效率。</span> </section> <ul data-sourcepos="260:1-261:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RabbitMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">支持多种消息队列模式,如点对点、发布订阅、路由等,提供了丰富的插件生态,可通过插件扩展功能,如实现消息的延迟发送等。</span> </section> <h3 data-sourcepos="264:1-264:25" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 可靠性 PK</span></h3> <ul data-sourcepos="268:1-274:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RocketMQ</strong>:</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">采用分布式架构和多副本机制,保证了数据的可靠性和高可用性,支持消息的持久化和故障转移,能在节点故障时快速恢复消息处理。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>Kafka</strong>:</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">通过多副本机制和分布式存储,确保数据的可靠性和容错性,能自动进行副本的选举和故障转移,保证消息不丢失。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RabbitMQ</strong>:</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">支持消息的持久化和镜像队列等机制,可保证消息在节点故障时不丢失,但在大规模集群环境下,维护其可靠性的复杂度相对较高。</span> </section></li> </ul> <h3 data-sourcepos="275:1-275:22" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 运维 PK</span></h3> <ul data-sourcepos="279:1-280:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RocketMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">运维相对简单,提供了可视化的管理控制台,方便进行集群管理、消息监控等操作,对运维人员的技术要求相对较低。</span> </section> <ul data-sourcepos="283:1-284:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>Kafka</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">集群部署和运维相对复杂,需要对分布式系统和存储有一定的了解,涉及到多个组件的配置和管理,但有一些开源的运维工具可降低运维难度。</span> </section> <ul data-sourcepos="287:1-288:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RabbitMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">运维复杂度适中,提供了管理界面,但在集群扩展和性能调优方面需要一定的技术经验,对运维人员的要求较高。</span> </section> <h3 data-sourcepos="293:1-293:28" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 社区生态 PK</span></h3> <ul data-sourcepos="297:1-298:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RocketMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">是国产的消息中间件,有活跃的国内社区支持,相关的技术文档和案例较为丰富,同时也得到了阿里巴巴等企业的技术支持。</span> </section> <ul data-sourcepos="301:1-302:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>Kafka</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">拥有庞大的开源社区,有丰富的文档、插件和周边工具,生态系统成熟,在大数据领域有广泛的应用和支持。</span> </section> <ul data-sourcepos="305:1-306:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RabbitMQ</strong>:</span> </section></li> </ul> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">社区活跃度高,有大量的开源插件和工具可供使用,商业支持也较为完善,能为企业提供专业的技术服务。</span> </section> <h3 data-sourcepos="311:1-311:34" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 支持的队列数 PK</span></h3> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">大型业务场景, Kafka 单机超过<strong>64个队列/分区</strong>,消息发送性能降低严重,需要进行深度定制和改造 ,京东就改造过;</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">大型业务场景, RocketMQ 单机支持<strong>最高5万个队列</strong>,而且 性能稳定</span> </section> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">RabbitMQ 是企业级的mq,大型的业务场景很少人使用。</span> </section> <h3 data-sourcepos="321:1-321:30" style="margin: 10px auto 5px;font-weight: bold;font-size: 20px;letter-spacing: 0.578px;white-space: normal;background-color: rgb(252, 252, 252);"><span style="margin-top: -1px;padding: 6px 20px 6px 10px;font-size: 17px;font-weight: normal;display: inline-block;line-height: 1.3;background-color: rgb(212, 224, 250);border-bottom-right-radius: 100px;color: rgb(30, 30, 30);">三大mq 适用场景 PK</span></h3> <ul data-sourcepos="325:1-330:0" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RocketMQ</strong>:适用于对消息可靠性、顺序性要求高,以及有分布式事务需求的场景,如金融交易、电商订单处理、分布式事务协调等。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>Kafka</strong>:适合用于大数据处理、实时数据流式处理、日志收集与分析等对吞吐量要求高、实时性强、消息可靠性要求低的场景。</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;"><strong>RabbitMQ</strong>:适用于中小型企业的一般消息队列需求,如异步任务处理、系统解耦、消息通知等场景,尤其适合对消息处理逻辑复杂、需要灵活配置的情况。</span> </section></li> </ul> <h2 data-sourcepos="331:1-331:28" style="font-weight: bold;font-size: 22px;margin: 10px auto 5px;border-top-width: 1px;border-top-style: solid;border-top-color: rgb(242, 242, 242);background-color: rgb(242, 242, 242);"><span style="margin-top: -1px;padding-top: 14px;padding-bottom: 14px;padding-right: 5px;padding-left: 5px;font-size: 17px;border-top: 4px solid rgb(33, 33, 34);display: inline-block;line-height: 1.5;font-weight: normal;background-color: rgb(30, 30, 30);border-bottom-right-radius: 100px;color: rgb(255, 255, 255);padding-right: 20px;padding-left: 10px;">三大mq 如何选择?</span></h2> <section style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;margin-bottom: 16px;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol;line-height: 1.75em;> <span style="font-size: 15px;">尼恩建议大家,围绕RocketMQ 和 Kafka做选型:</span> </section> <ul data-sourcepos="335:1-336:76" style="font-size: 16px;letter-spacing: normal;text-align: start;white-space: normal;padding-left: 2em;caret-color: rgb(36, 41, 46);color: rgb(36, 41, 46);font-family: system-ui, -apple-system, BlinkMacSystemFont, " segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui symbol; class="list-paddingleft-1"> <li style="font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">消息<strong>高</strong>可靠场景、队列数量<strong>庞大</strong>的场景,选择 RocketMQ</span> </section></li> <li style="margin-top: 0.25em;font-size: 15px;"> <section style="line-height: 1.75em;"> <span style="font-size: 15px;">消息可靠场景、队列数量的场景,选择 Kafka</span> </section></li> </ul> </section>