官术网_书友最值得收藏!

Version control system

It is a good idea to maintain your code using a revision control system such as Git or SVN. When writing an SQL code, it is better to create an installation script and execute it in one transaction. This approach makes it easy to clean up if an error occurs.

Database objects have different properties: some are a part of the physical schema, and some control database access. The following is a proposal for organizing the database code in order to increase the separation of concern (SoC).

For each database in a PostgreSQL cluster, one should maintain the DDL script for objects that are part of the physical schema, and the DML script, which populates the tables with static data together. The state of an object in the physical schema is defined by the object structure and the data that is contained by this object; thus, the object cannot be recreated without being dropped first. Also, the structure of the physical schema object does not change often. In addition to that, the refactoring of some of the physical schema objects, such as tables, might require data migration. In other words, changing the definition of a physical schema object requires some planning.

Store the DDL scripts for objects that are not part of the physical schema, such as views and functions, separately. Keeping the definitions of views and functions together allows the developer to refactor them easily. Also, the developer will be able to extract the dependency trees between these objects.

Maintain the DCL script separately. This allows the developer to separate the security aspect from the functional requirements of the database. It allows the database developers and administrators to work closely without interfering with each other's work.

主站蜘蛛池模板: 轮台县| 通许县| 化州市| 宣城市| 开平市| 莲花县| 南雄市| 黎川县| 桦甸市| 漳平市| 洪湖市| 安吉县| 启东市| 巴彦县| 淳安县| 东光县| 三原县| 绥江县| 德兴市| 犍为县| 建瓯市| 深州市| 施秉县| 高唐县| 沙河市| 常宁市| 香港 | 织金县| 河池市| 宜兰市| 樟树市| 蒙自县| 贵南县| 鸡东县| 沾化县| 丰顺县| 平利县| 福清市| 无锡市| 沂水县| 珠海市|