如何记录数据库结构? [英] How do you document your database structure?

查看:189
本文介绍了如何记录数据库结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多数据库系统不允许对表和字段进行注释或描述,那么除了明显具有良好的命名约定外,如何记录表/字段的用途?

Many database systems don't allow comments or descriptions of tables and fields, so how do you go about documenting the purpose of a table/field apart from the obvious of having good naming conventions?

(现在假设优秀的表和字段名称不足以记录数据库中每个表,字段和关系的完整含义。)

(Let's assume for now that "excellent" table and field names are not enough to document the full meaning of every table, field and relationship in the database.)

我知道很多人使用UML图来可视化数据库,但是我很少...如果有的话,看到一个包含字段注释的UML图。但是,我在使用 .sql 文件中的注释有很好的经验。这种方法的缺点是,它需要 .sql 文件手动保持最新的数据库结构随时间变化,但如果你这样做,你可以

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.

我看到的一些其他技术是描述数据库结构和关系的独立文档,并在ORM代码或其他数据库映射代码中手动维护注释。

Some other techniques I have seen are separate document describing database structure and relationships and manually maintained comments inside ORM code or other database-mapping code.

您以前如何解决这个问题?什么方法存在,什么是与他们相关的各种利弊?

How have you solved this problem in the past? What methods exists and what are the various pros and cons associated with them? How you would you like this solved in "a perfect world"?

更新

正如其他人所指出的,大多数流行的SQL引擎事实上允许评论,这是伟大的。奇怪的是,人们似乎没有使用这些功能。至少不是我过去参与的项目。

As others have pointed out, most of the popular SQL engines do in fact allow comments, which is great. Oddly enough, people don't seem to be using these features much. At least not on the projects I have been involved with in the past.

推荐答案

MySQL 允许对表和行进行注释。 PostgreSQL也 。从其他答案,Oracle和MSSQL也有评论。

MySQL allows comments on tables and rows. PostgreSQL does as well. From other answers, Oracle and MSSQL have comments too.

对我来说,一个UML图的组合,用于快速刷新字段名称,类型和约束,文档(TeX,但可以是任何格式),其中包含与数据库相关的所有数据库的特殊值,字段注释,访问记录等。 -

For me, a combination of UML diagram for a quick refresher on field names, types, and constraints, and an external document (TeX, but could be any format) with extended description of everything database-related - special values, field comments, access notes, whatever - works best.

这篇关于如何记录数据库结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆