Skip to Content
DocumentationDataGuidesSet Up the Database

Set Up the Database

Momen provides a PostgreSQL-backed relational database. Open the Data tab → Data model to configure tables, fields, relations, constraints, and permissions.

Conceptual background: Relational Data Modeling. Vector search: Set Up Vector Search.

Data model

Add table

Each project includes system tables (e.g. account, payment). System tables cannot be deleted. Among system tables, only the account table supports adding custom fields.

Properties:

  • Name — avoid reserved words like log, column, index
  • Description — optional
  • Turn on permissions for all roles — grant table CRUD to all roles

New table

Add fields

Every table includes id, created_at, and updated_at (system-managed, not editable).

  • Name — avoid reserved words like column
  • Type — see Data Types
  • Required, Unique, Turn on permissions for all roles

Momen uses Decimal for precise numbers. Custom code (JavaScript) or float APIs can introduce precision loss (e.g. 0.1 + 0.20.30000000000000004) if written back to the database.

New field

Add relations

Tables link via id. Example: account ↔ posts (author).

When creating a relation, set:

  • Target table
  • Relation type — one-to-one or one-to-many (many-to-many via junction table — see Relational Data Modeling · Many-to-many)
  • Relation names on each side
  • Turn on permissions for all roles

Relation settings

For many-to-many: create a junction table; both sides link one-to-many to it.

Many-to-many

Sync changes

Sync changes so the data model takes effect online.

On live apps, schema changes can break in-flight requests. Proceed carefully.

Constraint settings

Unique constraints prevent duplicate values on one or more columns.

Open constraint settings

Table menu → Edit Constraints.

Add constraint

Each table has a default id uniqueness constraint.

  • Constraint name — unique, lowercase
  • Column set — single or combined uniqueness
  • Storage limit — combined row data in constrained columns ≤ 8,191 bytes (UTF-8 encoding affects character count)

Example: unique combination of title + user_account per author.

Sync changes

  1. Existing violating data blocks sync
  2. After sync, constraints cannot be edited — delete a column in the set to remove
  3. Sync again after changes

Permission management

Momen combines RBAC and ABAC for data security. See Permissions.

Last updated on