Tables
Tables are the foundation of your app’s data layer. After connecting a database, you select which tables to import and configure how their fields behave within your application.
What is an App Table?
Section titled “What is an App Table?”An App Table is a representation of a database table within EmberBlocks. When you import a table, EmberBlocks creates a configuration layer that lets you:
- Rename fields for user-friendly display names
- Hide fields that shouldn’t be visible in the app
- Set defaults for new rows
- Define computed values using formulas
- Control editability of specific fields
The underlying database table remains unchanged - EmberBlocks only reads and writes data based on your configuration.
Importing Tables
Section titled “Importing Tables”To import tables from a connected database:
- Navigate to the Data tab in your app
- Click Tables in the sidebar
- Click Add Tables button
- Select the connection (if you have multiple)
- Check the tables you want to import
- Click Import Selected
Table Selection Tips
Section titled “Table Selection Tips”- Start small: Import only the tables you need initially
- Check row counts: Large tables may affect performance
- Consider relationships: Import related tables together
Table Configuration
Section titled “Table Configuration”After importing a table, click on it to configure its settings.
General Settings
Section titled “General Settings”| Setting | Description |
|---|---|
| Display Name | The name shown in the UI (can differ from the database table name) |
| Enabled | Whether this table is active in your app |
Field Configuration
Section titled “Field Configuration”Each field in your table can be configured independently:
| Setting | Description |
|---|---|
| Display Name | User-friendly name for the field |
| Visible | Whether the field appears in components |
| Read-only | Prevents editing this field (useful for IDs, timestamps) |
| Default Value | Static value for new rows |
| Default Formula | Formula evaluated when creating new rows |
| Computed Formula | Formula evaluated on create and update |
Field Types
Section titled “Field Types”EmberBlocks maps PostgreSQL data types to app-friendly types:
| PostgreSQL Type | App Type | UI Input |
|---|---|---|
integer, bigint, smallint | Number | Number input |
numeric, decimal, real, double | Decimal | Decimal input |
varchar, text, char | Text | Text input/textarea |
boolean | Boolean | Toggle/checkbox |
date | Date | Date picker |
timestamp, timestamptz | DateTime | DateTime picker |
time, timetz | Time | Time picker |
json, jsonb | JSON | JSON editor |
uuid | UUID | Text input (auto-generated) |
bytea | Binary | File upload |
| Array types | Array | Multi-select/tags |
Default Values
Section titled “Default Values”Set default values for new rows using static values or formulas.
Static Defaults
Section titled “Static Defaults”Simple fixed values:
| Field Type | Example Default |
|---|---|
| Text | "New Item" |
| Number | 0 |
| Boolean | true |
| Date | 2024-01-01 |
Formula Defaults
Section titled “Formula Defaults”Dynamic values evaluated at row creation:
-- Current user's email{{$user.email}}
-- Current timestampNOW()
-- Auto-generated IDCONCAT("ORD-", TEXT(NOW()))
-- Based on app context{{$app.name}}Computed Values
Section titled “Computed Values”Computed fields automatically update their value whenever a row is created or modified.
Use Cases
Section titled “Use Cases”Full Name Field:
CONCAT({{$row.first_name}}, " ", {{$row.last_name}})Total Calculation:
{{$row.quantity}} * {{$row.unit_price}}Status Based on Date:
IF({{$row.due_date}} < TODAY(), "Overdue", "Active")Lookup from Related Table:
LOOKUP(categories, id = {{$row.category_id}}).nameVisibility Settings
Section titled “Visibility Settings”Control which fields appear in your app:
Hiding Fields
Section titled “Hiding Fields”Hide fields that are:
- Internal IDs not meaningful to users
- System fields (created_at, updated_at)
- Sensitive data (passwords, tokens)
- Join columns used only for relationships
Making Fields Read-Only
Section titled “Making Fields Read-Only”Mark fields as read-only when:
- They’re auto-generated (IDs, timestamps)
- They’re computed by database triggers
- Users shouldn’t modify them (audit fields)
- They’re managed by external systems
Refreshing Schema
Section titled “Refreshing Schema”Database schemas change over time. To sync EmberBlocks with your database:
- Go to the Data tab
- Click on the table
- Click Refresh Schema
EmberBlocks will:
- Detect new columns and add them as fields
- Identify removed columns (won’t delete automatically)
- Update data types if changed
Working with Primary Keys
Section titled “Working with Primary Keys”EmberBlocks automatically detects primary keys from your database schema. Primary keys are:
- Used to identify rows for updates and deletes
- Displayed with a key icon in field lists
- Typically set as read-only
Composite Keys
Section titled “Composite Keys”Tables with composite primary keys (multiple columns) are supported. All key columns will be marked and used for row identification.
Foreign Key Relationships
Section titled “Foreign Key Relationships”EmberBlocks detects foreign key relationships for:
- Display relationship indicators
- Enable lookup formulas
- Support relational queries
Example Usage
Section titled “Example Usage”If orders.customer_id references customers.id:
-- Lookup customer name in an order contextLOOKUP(customers, id = {{$row.customer_id}}).nameTable Permissions
Section titled “Table Permissions”Table access is controlled through your database connection credentials. EmberBlocks respects:
SELECTpermission for reading dataINSERTpermission for creating rowsUPDATEpermission for editing rowsDELETEpermission for removing rows
If a permission is missing, the corresponding action will fail with a clear error message.
Performance Considerations
Section titled “Performance Considerations”Large Tables
Section titled “Large Tables”For tables with many rows:
- Enable pagination in List components
- Use filters to limit data loaded
- Index frequently queried columns in your database
- Consider views for complex aggregations
Wide Tables
Section titled “Wide Tables”For tables with many columns:
- Hide unnecessary fields to reduce data transfer
- Select specific columns when possible
- Split into multiple views for different use cases
Removing Tables
Section titled “Removing Tables”To remove a table from your app:
- Go to the Data tab
- Click the menu icon on the table
- Select Remove from App
The table is only removed from your EmberBlocks app - the actual database table is not affected.
Best Practices
Section titled “Best Practices”Naming Conventions
Section titled “Naming Conventions”- Use clear, descriptive display names
- Be consistent across your app
- Consider your users’ vocabulary
Examples:
| Database Name | Display Name |
|---|---|
cust_orders | Customer Orders |
inv_items | Inventory Items |
usr_prefs | User Preferences |
Field Organization
Section titled “Field Organization”- Order fields logically (most important first)
- Group related fields together
- Hide technical fields from end users
Data Integrity
Section titled “Data Integrity”- Use read-only for system-managed fields
- Set appropriate default values
- Use computed formulas for derived data
Next Steps
Section titled “Next Steps”With your tables configured, you can:
- Create Views - Build pages to display your data
- Add Components - Use List, Text, and other components
- Configure Actions - Enable CRUD operations