- Learning PostgreSQL 10(Second Edition)
- Salahaldin Juba Andrey Volkov
- 351字
- 2021-07-02 22:42:11
Database naming conventions
A naming convention describes how names are to be formulated. Naming conventions allow some information to be derived based on patterns, which helps the developer to easily search for and predict the database object names. Database naming conventions should be standardized across the organization. There is a lot of debate on how to name database objects. For example, some developers prefer to have prefixes or suffixes to distinguish the database object type from the names. For example, one could suffix a table or a view with tbl and vw respectively.
With regard to database object names, one should try to use descriptive names, and avoid acronyms and abbreviations if possible. Also, singular names are preferred, because a table is often mapped to an entity in a high-level programming language; thus, singular names lead to unified naming across the database tier and the business logic tier. Furthermore, specifying the cardinality and participation between tables is straightforward when the table names are singular.
In the database world, compound object names often use underscore but not camel case due to the ANSI SQL standard specifications regarding identifiers quotation and case sensitivity. In the ANSI SQL standard, non-quoted identifiers are case-insensitive.
In general, it is up to the developer to come up with a naming convention that suits with the needs at hand; in existing projects, do not invent any new naming conventions, unless the new naming conventions are communicated to the team members. In this book, we use the following conventions:
- The names of tables and views are not suffixed
- The database object names are unique across the database
- The identifiers are singulars including table, view, and column names
- Underscore is used for compound names
- The primary key is composed of the table name and the suffix id
- A foreign key has the same name of the referenced primary key in the linked table
- The internal naming conventions of PostgreSQL are used to rename the primary keys, foreign keys, and sequences
Do not use keywords to rename your database objects. The list of SQL keywords can be found at https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html.
- 數(shù)據(jù)中心建設(shè)與管理指南
- 離散事件系統(tǒng)建模與仿真
- Maya 2012從入門(mén)到精通
- B2B2C網(wǎng)上商城開(kāi)發(fā)指南
- Supervised Machine Learning with Python
- 電腦主板現(xiàn)場(chǎng)維修實(shí)錄
- 突破,Objective-C開(kāi)發(fā)速學(xué)手冊(cè)
- 激光選區(qū)熔化3D打印技術(shù)
- Ansible 2 Cloud Automation Cookbook
- Drupal高手建站技術(shù)手冊(cè)
- 數(shù)據(jù)要素:全球經(jīng)濟(jì)社會(huì)發(fā)展的新動(dòng)力
- 工業(yè)機(jī)器人操作
- 新一代人工智能與語(yǔ)音識(shí)別
- 項(xiàng)目實(shí)踐精解:C#核心技術(shù)應(yīng)用開(kāi)發(fā)
- Windows Server 2012 Automation with PowerShell Cookbook