2NF and 3NF

2NF and 3NF

The 2NF and 3NF are very similar--the 2NF deals with composite primary keys and the 3NF deals with single primary keys. In general, if you do an ER diagram, convert many-to-many relationships to entities, and then convert all entities to tables, then your tables will already be in 3NF form.

Second normal form. is violated when a non-key field is a fact about a subset of a key. It is only relevant when the key is composite, i.e., consists of several fields. Consider the following inventory record:


The key here consists of the PART and WAREHOUSE fields together, but WAREHOUSE-ADDRESS is a fact about the WAREHOUSE alone. The basic problems with this design are:

  • The warehouse address is repeated in every record that refers to a part stored in that warehouse.
  • If the address of the warehouse changes, every record referring to a part stored in that warehouse must be updated. Because of the redundancy, the data might become inconsistent, with different records showing different addresses for the same warehouse.
  • If at some point in time there are no parts stored in the warehouse, there may be no record in which to keep the warehouse's address.

To satisfy second normal form, the record shown above should be decomposed into (replaced by) the two records:


The 3NF differs from the 2NF in that all non-key attributes in 3NF are required to be directly dependent on the primary key of the relation. The 3NF therefore insists that all facts in the relation are about the key (or the thing that the key identifies), the whole key and nothing but the key.

Third normal form. is violated when a non-key field is a fact about another non-key field, as in


The EMPLOYEE field is the key. If each department is located in one place, then the LOCATION field is a fact about the DEPARTMENT -- in addition to being a fact about the EMPLOYEE. The problems with this design are the same as those caused by violations of second normal form.

  • The department's location is repeated in the record of every employee assigned to that department.
  • If the location of the department changes, every such record must be updated.
  • Because of the redundancy, the data might become inconsistent, with different records showing different locations for the same department.
  • If a department has no employees, there may be no record in which to keep the department's location.

To satisfy third normal form, the record shown above should be decomposed into the two records:

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23895263/viewspace-688157/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23895263/viewspace-688157/

Delphi 12.3 作为一款面向 Windows 平台的集成开发环境,由 Embarcadero Technologies 负责其持续演进。该环境以 Object Pascal 语言为核心,并依托 Visual Component Library(VCL)框架,广泛应用于各类桌面软件、数据库系统及企业级解决方案的开发。在此生态中,Excel4Delphi 作为一个重要的社区开源项目,致力于搭建 Delphi 与 Microsoft Excel 之间的高效桥梁,使开发者能够在自研程序中直接调用 Excel 的文档处理、工作表管理、单元格操作及宏执行等功能。 该项目以库文件与组件包的形式提供,开发者将其集成至 Delphi 工程后,即可通过封装良好的接口实现对 Excel 的编程控制。具体功能涵盖创建与编辑工作簿、格式化单元格、批量导入导出数据,乃至执行内置公式与宏指令等高级操作。这一机制显著降低了在财务分析、报表自动生成、数据整理等场景中实现 Excel 功能集成的技术门槛,使开发者无需深入掌握 COM 编程或 Excel 底层 API 即可完成复杂任务。 使用 Excel4Delphi 需具备基础的 Delphi 编程知识,并对 Excel 对象模型有一定理解。实践中需注意不同 Excel 版本间的兼容性,并严格遵循项目文档进行环境配置与依赖部署。此外,操作过程中应遵循文件访问的最佳实践,例如确保目标文件未被独占锁定,并实施完整的异常处理机制,以防数据损毁或程序意外中断。 该项目的持续维护依赖于 Delphi 开发者社区的集体贡献,通过定期更新以适配新版开发环境与 Office 套件,并修复已发现的问题。对于需要深度融合 Excel 功能的 Delphi 应用而言,Excel4Delphi 提供了经过充分测试的可靠代码基础,使开发团队能更专注于业务逻辑与用户体验的优化,从而提升整体开发效率与软件质量。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
# 【实战教程】Pytest从入门到进阶:基于FastAPI的测试开发全指南 13章体系化教程,从Pytest基础到企业级实战,结合FastAPI落地测试方案,附完整可运行代码与最佳实践! ## 核心内容 覆盖环境搭建、用例编写、Fixture系统、参数化测试、覆盖率分析、插件开发、CI/CD集成等13大核心模块,分入门→进阶→高级三阶段学习路径。每章配套FastAPI实战项目(用户认证、电商API、完整电商系统等),测试用例贴合实际业务,支持本地直接运行。聚焦高频难点:Fixture作用域管理、参数化数据源设计、测试并行执行、异常处理、自定义插件开发、覆盖率优化。落地工程化实践:测试目录规范、用例隔离、日志配置、测试报告可视化、CI/CD自动化集成。 ## 技术栈 FastAPI + Pytest + Pydantic + OAuth2/JWT + RESTful API + 测试覆盖率工具 + CI/CD ## 适用人群 Python开发者、测试工程师、后端开发者、DevOps工程师(零基础可入门,有经验可进阶) ## 学习收获 掌握Pytest全流程用法,能独立设计可维护测试体系,实现高覆盖率测试与报告可视化,开发自定义插件,落地TDD与持续集成流程。 ## 快速上手 1. 进入章节目录安装依赖:`pip install fastapi uvicorn pytest fastapi.testclient` 2. 运行应用:`uvicorn app:app --reload`,访问`http://localhost:8000/docs` 3. 执行测试:`python -m pytest test_app.py -v` 配套完整代码、测试用例与配置文件,助力快速落地实际项目!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值