Fundamental Concept
Yee Base uses naming conventions like prefixes and pre-defined keywords on variables to automate and simplify repetitive works.
Database Table Naming
Table should be name in singular form and all lowercase (e.g. organization, individual, event). Use underscore '_' if the table name is form by 2 words (e.g. startup_stage).
If it is a many-to-many relationship table, for example: Intermediate table startup_stage2intake links startup_stage table with intake table. Ordering of table name in this format can be easily decided by asking this question: "who is linking to who?". In this case, we are linking many startup stages to an intake table.
Database Column Naming
Type
Description
Example
ID
following Yii framework concept, each table should have an auto incremental id
column.
id
Code
Use as a unique alphanumerical identifier of a record. Could be UUID too. A foreign table who links to this table will use country_code
for example to refer it. However, not all column ended with _code
is refer to a unique foreign column (such as as_role_code
, external_code
...)
code
Slug
Like code but to expose to the public thru the URL, normally hold value in URL friendly format like 'hello-world-123'
slug
String
None numerical value within 255 characters do not have any naming convention to the column name
full_name
, location
Text
Like string, but plain text with a larger range of value using data type like text
or longtext
has a prefix of text_
text_note
, text_short_description
HTML Text
Like text, but rich HTML text a prefix of html_
html_content
, html_body
Date
Yee store date in database using unixtimestamp format. Prefix with name date_
and name in past tense (optional). All table have default field of date_added
and date_modified
to track when a record is created and last modified.
date_added
, date_modified
, date_submit
URL
Prefix of url_
and usually store like String using varchar (255)
url_website
Image
Store the relative path of user uploaded image file to the upload folder (in s3).
image_cover
, image_photo
File
Store the relative path of user uploaded none image file to the upload folder (in s3).
file_proof
Ordering
Stored as double
data type in database, default to 0
, larger number on top, indicated this table has a sorting mechanism for admin to rearrange data manually.
ordering
Active
A common boolean field to use as 'soft delete' for use case where data is never deleted from a table. Data type set to tinyint (1)
and default to value 1
.
is_active
Boolean
Like Active column, boolean column start with prefix is_
and followed by an adjective or past tense verb. Data type set to tinyint (1)
and default to value 1
.
is_highlight
Enum
No specific prefix but use the unique enum
data type.
status
Json
Prefix with json_
and stored as text
or longtext
data type with NULL. This is a special method to allow unstructured value store in a specific records for developer flexibility.
json_extra
Spatial
Information about a physical object that can be represented by numerical values in a geographic coordinate system. Prefix with latlong_
and stored as point
.
latlong_address
I18N
Suffix with the i18n code such as _en
mark the column is for specific languages usage.
title_en
, title_ms
, title_zh_cn
Last updated
Was this helpful?