Database Naming Conventions

Goals

The scope of this document is to propose a naming convention for the database schema. The main objectives are:

  1. Ensure portability of Mifos database code to different operating systems. Namely, Linux, Windows, and Mac OS X.
  2. Encourage intuitive naming of database identifiers like tables and columns.
  3. Improve readability and maintainability of database code.

Portability to databases other than MySQL is out of scope of this document.

Constraints for all identifiers

  1. Allowed characters for identifiers are a-z, 0-9, and _.
  2. All identifiers shall be in English.
  3. Underscores should be used to separate words, e.g. account_name.
  4. Do not use commonly reserved database keywords like table, column, index, etc.

Identifier Types

In addition to the constraints above, particular database identifier types have additional constraints. Maximum lengths were initially derived from the MySQL manual. While some of these restrictions are not mandatory, following them to the letter will help ensure database portability.

Identifier Type

Max length (characters)

Example

database/schema

64

mifos

table

64

customer_transactions

column

64

transaction_date

index

64

cust_hierarchy_idx

view

64

customer_loan_view

alias

255