Database structure and relationships

6 minute read · SQL Client

The database structure explains how the app stores information. Inspect it before asking an agent to add a field or change a relationship.

Inspect structure before changing it

Select a table and open Structure. Review columns, types, defaults, nullability, primary/unique keys and indexes. Use the available CREATE definition when you need the engine's actual representation. The relationships/diagram view helps understand how tables connect; it is metadata visualization of the selected database.

For an article app, identify the article primary key and any author/category relationship. Check whether the foreign-key column is nullable and indexed before asking an agent to change the relationship. An apparent line in a design sketch is not proof that the database enforces a foreign key.

Review a schema change in context

Adding, editing or dropping a supported structure uses driver-specific DDL. MySQL/MariaDB, PostgreSQL and SQLite do not support every operation in the same way. Read the operation and target before confirming it. A useful request is: “Inspect the article table and propose an index for this existing query; show the intended change before executing it.”

For an application maintained through migrations, coordinate the schema change with its source migration so another checkout can reproduce it. A manual table edit may fix one local database while leaving the app's setup history inconsistent.

Troubleshoot missing or unexpected metadata

If a schema, routine or relation is missing, check the selected database and account privileges. Some engines expose different metadata or require a schema selection. Refresh after an authorized structure change. Unsupported engine features should be reported rather than emulated silently.

Before a destructive DDL action, use the project's appropriate backup/export procedure and review dependencies such as foreign keys and app queries. A diagram does not make dropping a table reversible. After a change, inspect the resulting schema and rerun the app behavior it supports. Continue with import and export.

Explore the shape of an unfamiliar app

Choose one table, such as articles, and inspect column names, types, defaults, nullability and keys. Open its indexes before deciding a slow filter needs application changes. Follow a foreign-key relationship to the related table and use the diagram to see how records connect. The diagram reflects available database metadata; a relationship used only in application code may not appear as a declared foreign key.

Inspect the CREATE definition and supported routines when you need the database's exact representation. Driver capabilities differ, so an unavailable structure operation should remain unavailable instead of being approximated as another engine's SQL.

Before changing a column or index, check the application's migration and any existing rows that would violate the change. Describe the intended outcome to the agent and ask for the proposed schema operation first. Apply an approved change to the intended development database, refresh Structure, then read and save a sample record through the app. Keep a recovery path for data-changing DDL. Checks and publishing explains why a successful schema command alone is not a completed feature.

Related guides: saved data, moving data.

Structure: column controls

Select a table, then Structure. Column rows show Name, Type, Null, Key, Default, Extra, Encoding and Collation. The key icon identifies a primary key. Copyable metadata cells and their context menu let you reuse an exact name or definition.

Control / field Meaning and effect
Add column Opens a definition form for a new field in the selected table. Applying it changes the database schema.
Edit column Opens the current definition. This action is not offered for SQLite in this interface.
Drop column Removes the column and its values after confirmation. Check application migrations and dependent queries first.
Name SQL identifier for the column. Renaming it can break code that uses its old name.
Type Driver-specific data type. Choose a type compatible with existing values.
Length / values Length or type-specific values, for example a VARCHAR length. It is not a default cell value.
Default (raw — quote strings yourself) A SQL expression. Write 'draft' for a literal string, 0 for a numeric zero, or a supported expression such as CURRENT_TIMESTAMP. Unquoted draft is not the same string literal.
Nullable Allows SQL NULL. NULL, an empty string and zero are different values.
Comment Metadata describing the column where the driver supports it.
Encoding Character set for textual data on supported engines.
Collation Text comparison and sorting rules. It can affect case sensitivity, indexes and uniqueness.
Apply / Save Executes the supported schema operation; reopening the form alone does not apply it.
Cancel Discards this form's unsubmitted definition.

If a column edit fails, read the database error. An incompatible type, duplicate values for a unique constraint or insufficient privileges requires a different resolution; repeatedly pressing Save will not correct the definition.

Indexes and foreign keys

Add index asks for Index name, Type and one or more columns. Column order matters for a compound index; each entry can specify ASC or DESC where supported. Drop index removes the selected index after confirmation. An index speeds some reads but also costs storage and write work.

In Relations, inspect the constraint name and referenced table/column. Add foreign key collects:

Field Meaning
Constraint name Name of this relationship in the database.
Column The child column in the selected table.
References table / Column The parent table and referenced key. Existing child values must be valid for the relationship.
ON DELETE What the database should do to child rows when a referenced parent row is deleted.
ON UPDATE What should happen when the referenced parent key changes.

For the actions offered by your engine: RESTRICT / NO ACTION prevents an operation that would violate the relationship; CASCADE propagates it to child rows; SET NULL clears the child value and requires a nullable column. SET DEFAULT, where supported, uses a valid default. Database engines differ in support and timing. Cascading a delete can remove many rows even though you clicked on one parent. SQLite relationship changes are not exposed through the same add/drop controls as MySQL/PostgreSQL; use a reviewed migration for unsupported changes.

Table Info, routines and definitions

Control Result
Table Info Displays engine-reported rows, size, index size and identity information. Estimates are not always exact row counts.
Engine / Encoding / Collation Changes the corresponding table property on supported engines. Changing text rules can require table/index rebuilding.
Comments → Save Saves the table comment. Editing the text without saving does not apply it.
Reset identity… Asks for the next identity / auto-increment value on a table with an identity column. It changes future ID allocation; existing rows are not renumbered. Choose a value that cannot collide with existing keys.
Copy definition Copies the displayed CREATE/routine definition without executing it.
Refresh Reloads metadata after an external schema change.
Routines Displays procedures/functions exposed by the driver and your privileges. Missing routines can mean missing permission or unsupported metadata.
Diagram Visualizes tables and declared relationships. A line is a relationship from available metadata, not a newly created constraint.

After applying a schema change, refresh the table and exercise the affected application form or API. Store the equivalent migration in the project so another checkout can reproduce it. See data editing and exports.

Updated Sep 21, 2026 · Need a hand?