Introduction Installation Projects Tables Inserts Searches Updates Deletes CLI Production Installation Conclusion

Tables - Flaarum Tutorials

A table is a store of similar information. In flaarum a table structure (or definition) is enforced. This helps checks for typing errors and reduces bugs in a setup.

Supported Data Types

The following datatypes are supported in flaarum:

Table Defintion Statements

The syntax is very different from SQL. The syntax also does not support comments.

Sample One

table: users
  firstname string required
  surname string required
  email email unique required
  dob date
  biography text

Note that:

  1. The primary key is automatically created. It is of type `int` and is named `id`. Also it is autoincremented and it is unique.
  2. Each section is ended with '::' and is compulsory even if only the fields section is present.

Sample Two

table: grades
  userid int required
  grade int required
  creation_dt datetime
  remarkid int required
  creation_year int required
  userid users on_delete_delete
  remarkid remarks on_delete_empty

Note that:

  1. Foreign keys in Flaarum only supports linking against the `id` of a table.
  2. A foreign_key part takes either an on_delete_delete or an on_delete_empty or an on_delete_restrict with on_delete_restrict being the default.

Sample Three

table: logs1
table_type: logs
	ipaddr string
	loggedin bool

Note that:

  1. Tables of type logs have their ids to be set to a random string.
  2. Tables of types logs have an automatically created "created" field of type datetime
  3. You can only search a logs table with the created field or the id field.

Supported Actions on Tables

Tables can be deleted, emptied, renamed all from your own programs.

< Previous Next >