Database Design Principles in Jalno
Naming Principles
- The package name is always stated at the beginning of the table name.
- The table name is written after the package name, separated by an underscore (
_). - The table name is usually written in plural form.
- The different parts of the table name are separated from one another using underscores (
_).
Column Principles
- Usually, in most tables (except for special-purpose ones), the first column is always named the identifier (
id). This column is defined as the Primary index and as Auto Increment. - The status column (
status) is used in every table except special ones. This column holds a numeric value, and the smallest numeric type,TINYINT, is used for it. (Constants corresponding to the statuses are defined in the table'sModelclass, and direct use of the raw status values is avoided.) - For columns that relate to the identifier column (
id) of another table,_idmust be appended to their name. For example, a column nameduserthat refers to an identifier in theuserpanel_userstable is stored asuser_id. - For columns that store a String value, if the number of characters is predictable or is fewer than 255, a
VarChartype with a limited, specified length must be used. For example, the user's name in theuserpanel_userstable is limited to 100 characters. - The Collation of columns that store a String value must be
utf8mb4_unicode_ci, to comprehensively cover all characters. - Avoid creating columns that refer to multiple identifiers of another table as a String; for this case, create a separate table instead. For example, to store the identifiers of several categories for a post, rather than in a single column, create a table for the one-to-one relationship between a post and a category.
Model Creation Principles
Unlike table names, Model names are declared in singular form. The status constants must also be declared as Public in this class. For example, the users' Model class is declared as User, while its table name is declared as userpanel_users.