pre-dev: initial commit

This commit is contained in:
2025-08-11 10:25:54 +07:00
parent e0ecf1c906
commit ee9b4a9035
50 changed files with 1020 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
# DATABASE MODELING CONVETION
## Naming
1. Table names are written in combination, with the following rules:
1. Basically uses `PascalCase`
2. An underscore is used in `derived-table`, separating the original name and the derived name.
3. A derived table is a table derived from another table but not used in the main flow of the business process.
4. Examples of derived table implementations include:
1. Archiving, for example: `Transaction_2019`, is an archive of the `Transaction` table for the year `2019`.
2. Trashing for deleted data, for example: `Transaction_deleted`, stores data from the deleted `transaction` table.
3. History for storing historical information, for example: `ProductStock_History`, stores historical data from the `ProductStock` table.
2. Columns are written in combination, with the following rules:
1. Basically, uses `PascalCase`
2. Use underscores to represent relationships <span>`object`-`attribute`</span> or <span>`table`-`column`</span>
<br />Example:
1. `User_Id` represents the `User` object and the `Id` attribute
2. `BestProduct_Code` represents the `BestProduct` object and the `Code` attribute
3. When more than one column has a similar definition, a `prefix` can be added to indicate the column's purpose.
<br />Example:
1. `Admin_User_Id` represents the `Admin` of the `User` object and the `Id` attribute
2. `Operator_User_Id` refers to the `Operator` of the `User` object and the `Id` column.
3. Attributes/properties in JSON (for output purpose) are written in combination, with the following rules:
1. Basically uses `camelCase`
2. Using underscores to represent relationships <span>`object`-`attribute`</span> or <span>`table`-`column`</span>
<br />Example:
1. `user_id` represents the `User` object and the `Id` attribute.
2. `bestProduct_code` represents the `bestProduct` object and the `code` attribute.
3. When more than one column has a similar definition, a `prefix` can be added to indicate the column's purpose.
<br />Example:
1. `admin_user_id` refers to the `admin` of the `user` object and `id` attribute
2. `operator_user_id` refers to the `operator` of the `user` object, column `id`
3. `newArrival_bestProduct_code` refers to the `newArrival` of the `bestProduct` object, column `code`
4. `favorite_bestProduct_code` refers to the `favorite` of the `bestProduct` object, column `code`
## Avoiding Circular Dependency
1. Prioritize the child due to it's nature to define the foreign key. This means the child is allowed to import main entities that define the table, not the base.
2. Parent imports the child's non main entities, can be the base or others depending on the needs.