Naming Conventions: Difference between revisions

From nuBuilderForte
Jump to navigation Jump to search
No edit summary
[Updated] Naming Conventions
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
* '''nuBuilder''' and [https://www.guru99.com/database-normalization.html DB Normalisation rules] requires the use of a Primary Key ('''PK''') for each table
* All table names should be '''singular''' and '''lowercase'''


* Suggested that the PK be the name of the table followed by an underscore ('''_''') and the letters '''id'''. eg., '''person_id'''
* All field names should be '''lowercase'''


* Suggested that the PK should be a '''varchar(25)''', as it will automatically be populated by '''nuBuilder''' using the function called '''nuID()''' (when filled out as suggested), unless the PK is an ''auto-increment''ing number
* Use an underscore (_) to separate words in table and field names. 
  e.g., '''grand_total'''


* If a '''varchar(25)''' is used for the PK instead of a number it allows for better use of certain hash variables such as '''#nu_browse_filter#'''
* Prefix each field name with a 3-letter lowercase abbreviation of the table name followed by an underscore (_). 
  e.g., for the '''person''' table: '''per_name''', '''per_birthdate'''


* Also suggested that <u>Unique Indexes not be used</u>, allowing internal validating rules to check for duplicates. This is because of the way the project implements checking for PK types
* '''nuBuilder''' and [https://www.guru99.com/database-normalization.html DB Normalisation rules] require a Primary Key ('''PK''') for each table


* Foreign Keys (FK) should bear the shortname of the table as a prefix followed by an underscore (_) and then the original parent table's PK it refers to
* The PK should be the table name followed by an underscore and '''id'''. 
  e.g., '''person_id'''


* All table names are singular and lowercase
* The PK is recommended to be a '''VARCHAR(25)''', auto-generated by '''nuBuilder''' using the '''nuID()''' function 
  (unless using an AUTO_INCREMENT number)


* All field names are lowercase
* Using '''VARCHAR(25)''' for PKs allows better compatibility with hash cookies such as '''#nu_browse_filter#'''


* Delimit each word in table and field name with an underscore (_). eg., '''grand_total'''
* It is recommended that <u>Unique Indexes not be used</u>, and instead rely on internal validation rules to handle duplicate checking 
  (due to the way nuBuilder checks for PK uniqueness)
 
* Foreign Key ('''FK''') fields should begin with the shortname of the referencing table, followed by an underscore, and then the PK of the referenced table 
  e.g., in '''invoice''' table, FK to '''person''' table should be '''inv_person_id'''
 
== Getting Started ==
 
* '''Display''' and '''Input''' formatting are managed through system tables ('''zzzzsys_*'''), such as '''format''', '''form''', '''browse''', and '''report'''
 
* Start with your own tables or allow nuBuilder to generate them with standard field types (do not modify the default ID field)
 
* All nuBuilder application tables should use a '''VARCHAR(25)''' type for the PK if auto-generated in '''globeadmin''' mode
 
* For existing tables using AUTO_INCREMENT INT fields, new IDs must be generated via '''BeforeSave PHP''' code 
  or the ID field should be defined as <u>AUTO_INCREMENT NULL</u> in the DB
 
* Alternatively, conform to the VARCHAR(25) ID convention and maintain a separate unique INT or other field that previously served as the PK outside of nuBuilder
 
[[Category:Dashboard]]

Latest revision as of 15:31, 6 June 2025

  • All table names should be singular and lowercase
  • All field names should be lowercase
  • Use an underscore (_) to separate words in table and field names.
 e.g., grand_total
  • Prefix each field name with a 3-letter lowercase abbreviation of the table name followed by an underscore (_).
 e.g., for the person table: per_name, per_birthdate
  • The PK should be the table name followed by an underscore and id.
 e.g., person_id
  • The PK is recommended to be a VARCHAR(25), auto-generated by nuBuilder using the nuID() function
 (unless using an AUTO_INCREMENT number)
  • Using VARCHAR(25) for PKs allows better compatibility with hash cookies such as #nu_browse_filter#
  • It is recommended that Unique Indexes not be used, and instead rely on internal validation rules to handle duplicate checking
 (due to the way nuBuilder checks for PK uniqueness)
  • Foreign Key (FK) fields should begin with the shortname of the referencing table, followed by an underscore, and then the PK of the referenced table
 e.g., in invoice table, FK to person table should be inv_person_id

Getting Started

  • Display and Input formatting are managed through system tables (zzzzsys_*), such as format, form, browse, and report
  • Start with your own tables or allow nuBuilder to generate them with standard field types (do not modify the default ID field)
  • All nuBuilder application tables should use a VARCHAR(25) type for the PK if auto-generated in globeadmin mode
  • For existing tables using AUTO_INCREMENT INT fields, new IDs must be generated via BeforeSave PHP code
 or the ID field should be defined as AUTO_INCREMENT NULL in the DB
  • Alternatively, conform to the VARCHAR(25) ID convention and maintain a separate unique INT or other field that previously served as the PK outside of nuBuilder