Skip to content

Database Tables ​

Database tables define where your app's data is stored. WP-Nexus supports three storage backends, each with different strengths.

Creating a Table ​

Navigate to your app and click the Tables tab. Click Create Table and fill in:

  • Name -- display name (e.g., "Products", "Events")
  • Slug -- auto-generated identifier (same rules as app slugs: lowercase, letters/digits/underscores, must start with a letter)
  • Storage Type -- choose one of the three options below

Storage Types ​

Custom Table (custom_table) ​

Creates a dedicated SQL table in your WordPress database (named {wp_prefix}nexus_app_{appId}_{slug}, e.g., wp_nexus_app_1_products). Best for:

  • High-performance queries on structured data
  • Large datasets where WordPress post queries would be slow
  • Data that does not need WordPress admin UI (post editor, categories, etc.)

Custom Post Type (custom_post_type) ​

Stores data as WordPress posts with a custom post type. Best for:

  • Content that benefits from the WordPress editor
  • Data you want to expose to themes, other plugins, or the REST API
  • Leveraging WordPress built-in features (revisions, status, author, featured image)

When you select CPT storage, a configuration panel appears where you can set the post type label, menu icon, and supported features.

Taxonomy (taxonomy) ​

Stores data as WordPress taxonomy terms. Best for:

  • Categorization and tagging systems
  • Hierarchical data (parent/child relationships)
  • Shared vocabularies across post types

When you select Taxonomy storage, a configuration panel lets you specify the taxonomy slug, labels, and whether it is hierarchical.

Defining Columns ​

After creating a table, click it to open the Schema Editor. Click + Add Column to define each field.

Column Properties ​

PropertyDescription
NameThe column identifier (e.g., title, price, email). Must be a valid column name.
TypeThe data type. See the list below.
NullableWhether the column allows empty values.
DefaultThe default value when no value is provided.
IndexedAdds a database index for faster queries on this column.
UniqueAdds a unique constraint -- no two rows can share the same value.

Column Types ​

Types are organized into categories in the type dropdown.

Generic ​

TypeLabelUse Case
stringShort TextNames, titles, short text (default type for new columns)
textLong TextDescriptions, paragraphs, longer content
integerNumber (Integer)Counts, quantities, IDs
floatNumber (Decimal)Prices, percentages, measurements
boolYes / NoFlags, toggles, active/inactive

Specialized ​

TypeLabelUse Case
emailEmailEmail addresses with validation
urlURLWeb addresses and links
phonePhonePhone numbers
colorColorColor values (hex codes, etc.)
imageImage URLImage URLs and media references

Date / Time ​

TypeLabelUse Case
dateDateBirth dates, deadlines
datetimeDate & TimeTimestamps, event start times

Advanced ​

TypeLabelUse Case
jsonJSONFlexible structured data, arrays, nested objects
richtextRich TextHTML content, formatted articles
referenceReferenceForeign key to another table, post type, or taxonomy

Reference Columns ​

When you set a column type to reference, a Target dropdown appears. You can reference:

  • Another app table -- e.g., table:products
  • WordPress posts -- post_type:post
  • WordPress pages -- post_type:page
  • WordPress categories -- term:category
  • WordPress tags -- term:post_tag

Reference columns store the target row's ID. Use the Relation Picker widget and Lookup node to work with relationships in the UI and pipelines.

Schema Migration ​

When you modify columns and click Save, WP-Nexus applies the schema changes to the underlying database:

  • New columns are added via ALTER TABLE.
  • Removed columns are dropped.
  • Type changes are applied in place where possible.
  • Index and uniqueness changes are applied automatically.

WARNING

Removing a column permanently deletes all data in that column. Changing a column type may cause data loss if the existing data is incompatible with the new type.

Best Practices ​

  • Index columns that you filter or sort by frequently -- it significantly improves query speed.
  • Use reference for relationships instead of manually storing IDs in integer columns -- it enables the Relation Picker widget and the Lookup node.
  • Use text for longer content -- choose Short Text (string) for names and titles, Long Text (text) for paragraphs and descriptions.
  • Use json sparingly -- it is flexible but harder to query and index than flat columns.