许多数据库系统都不允许对表和字段进行注释或描述,那么除了具有良好的命名约定之外,如何记录表/字段的用途呢?
(现在假设"优秀"的表名和字段名不足以记录数据库中每个表、字段和关系的全部含义.)
I know many people use UML diagrams to visualize the database, but I have rarely—if ever—seen a UML diagram including field comments. However, I have good experience with using comments inside .sql
files. The downside to this approach is that it requires the .sql
files to be manually kept up-to-date as the database structure changes over time—but if you do, you can also have it under version control.
我看到的其他一些技术是描述数据库 struct 和关系的单独文档,以及在ORM代码或其他数据库映射代码中手动维护的注释.
你过go 是如何解决这个问题的?存在哪些方法,以及与之相关的各种优缺点是什么?你希望在"完美世界"中如何解决这个问题?
Update个
正如其他人指出的那样,大多数流行的SQL引擎实际上都允许注释,这很棒.奇怪的是,人们似乎不太使用这些功能.至少在我过go 参与的项目上不是这样.