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

  • Learning PostgreSQL 11
  • Salahaldin Juba Andrey Volkov
  • 315字
  • 2021-07-02 13:11:47

Version control systems

It's recommended you maintain your code using a revision-control system, such as Git or SVN. When writing SQL code, it's better to create an installation script and execute it in one transaction. This approach makes it easy to clean up if an error occurs. Also, a good practice is to create a rollback script to quickly return schema to the previous state if something goes wrong at the application level.

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 concerns (SoC).

For each database in a PostgreSQL cluster, you 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, such as a table or index in the physical schema, is defined by the object structure and the data that is contained by this object; thus, the object can't be recreated without being dropped first. Also, the structure of the physical schema object doesn't change often. In addition, 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 aren't 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. This means that the database developers and administrators can work closely without interfering in each other's work.

主站蜘蛛池模板: 桐梓县| 岱山县| 紫云| 怀远县| 高阳县| 麦盖提县| 江西省| 岚皋县| 古蔺县| 全椒县| 五家渠市| 武义县| 阿图什市| 七台河市| 马公市| 五大连池市| 平昌县| 巨鹿县| 兴义市| 克东县| 宾川县| 雅安市| 芮城县| 南昌县| 蒙城县| 白河县| 松桃| 梨树县| 长宁区| 榆社县| 芦溪县| 淮北市| 通河县| 金湖县| 永嘉县| 阿城市| 溧水县| 西乡县| 云南省| 太康县| 康保县|