Schemas
Work with the Schema Agent
The Schema Agent is an AI advisor that can read everything in one schema. Ask it to review foreign keys and naming, spot normalization problems, suggest indexes, or write views and procedures. When it proposes an object or a change, it shows a card you can apply with one click. Nothing changes until you click.
In the app: Data Model › Schemas › your schema › Schema Agent tab
Before you start¶
- Anyone who can open the schema can ask questions. Applying proposals needs Read/Write access to the schema; Read Only users don’t see the
CreateandApplybuttons. - The chat is unavailable while your organization is in read-only mode.
- Each message uses your organization’s AI allowance. See AI token allowance and usage.
Ask a question¶
- Open the schema and click the
Schema Agenttab. - Type into
Ask a question about this schema…and press Enter, or click the send button. - Wait for the reply. Answers are formatted text, often with SQL.
Some things to try:
- “Suggest an index for the Orders table.”
- “Which foreign keys don’t follow the naming convention?”
- “Could this schema be more normalized?”
- “Write a view of customers with their latest order.”
If a message fails, you see “Something went wrong — that message wasn’t processed.” with Retry.
Apply a proposal¶
When the agent writes something you could add to the schema, its reply ends with one or more proposal cards. Each card shows what it is and its name.
New objects have a Create button:
- Table
- View
- Stored procedure
- Scalar function, table-valued function or inline table function
- Index (shown with its key and included columns, and whether it’s unique)
Changes to existing objects have an Apply button:
Update view(or procedure, function): replaces the object’s SQL.Show diffcompares old and new.Replace index: replaces an existing index.Add column: adds a column to a table, shown as a one-line definition.Alter column: changes a column’s definition.
To apply one:
- Click
Show SQLorShow diffto read what will be written. - Click
CreateorApply. - The card changes to
CreatedorAppliedwith anOpenlink to the new or changed object.
New views, procedures and functions are queued for analysis automatically, which fills in their outputs, parameters and dependencies.
Warning: The agent’s SQL is a draft. Read it before you create it, and check the object afterwards, as you would code from a colleague.
When a proposal can’t be applied¶
Kenseme checks each proposal against the schema as it is when you click, not as it was when the agent wrote it. You might see:
- “This object was edited after the agent proposed the change; ask the agent again.” Someone changed the object since. Ask for a fresh proposal.
- “Column ‘…’ already exists on ‘…’.”
- “Table ‘…’ was not found in this schema.”
- “The proposal does not reference an existing object; ask the agent again.”
The error shows on the card. Nothing is written when a proposal fails.
Conversation history¶
- The conversation is saved for the schema, so it survives page reloads.
- It’s shared by everyone who opens the schema. Other users see the same messages and proposals, and whether they’ve already been created.
- The most recent 40 turns are kept.
Clear conversationremoves the history for everyone. It can’t be undone.
Note: Saved history can be cleared by the system at any time. Don’t rely on it as a record; create the objects you want to keep.
Schema Agent or Query Agent?¶
- Use the Schema Agent to review and change the design.
- Use the Query Agent tab to write a
SELECTquery over the schema. See Generate a query with AI.