Skip to content

Database tables, keys and queries

Concept · Beginner · Core concepts

Understand the record shape and relationships before connecting them to a page.

Understand the record shape and relationships before connecting them to a page.

A products table might contain id, name and price. Each row is one product; each column describes one value. Choose types that represent the value you need to store, rather than treating every field as display text.

The id identifies one product even when its name changes. An edit or delete action should receive that key, validate it and restrict which matching record the current user may modify. A product name is a poor substitute for a stable key.

An order_items record can contain order_id and product_id to connect an order to its products. Database Manager lets you define supported relationships. A relationship describes how records connect; the server query still decides which fields and related records to return.

A query can select a subset of columns, filter records, sort them and limit the result count. Return only the data the page needs. An empty array means the query returned no rows; it is different from a failed database connection.

Configure the database connection for the project target and use it from Server Connect. App Connect receives the action’s output, not database credentials. Validate submitted input and enforce access in the server action before reads or writes.

You can distinguish a table, a record, a primary key, a related key and a query result.