DEV Community

Mads Hansen
Mads Hansen

Posted on

Why your database schema is making your AI dumber

You spent weeks tuning your AI prompts.

You're using the best model. You've got RAG, context management, the works.

And your AI still gives mediocre answers when it touches your database.

The problem isn't your model. It's your schema.


AI reads your schema like a junior developer

When an AI queries your database via MCP, it doesn't know your business. It reads your column names and infers meaning.

Bad:

CREATE TABLE dev_inv (
  id UUID,
  dvc_id VARCHAR,
  lst_hb TIMESTAMP,
  sts INT
);
Enter fullscreen mode Exit fullscreen mode

The AI sees lst_hb and guesses. It might call it "last heartbeat" or "last header" or "last hub." It will probably get it wrong.

Good:

CREATE TABLE device_inventory (
  id UUID,
  device_id VARCHAR,
  last_seen_at TIMESTAMP,
  status VARCHAR CHECK (status IN ('active', 'inactive', 'offline'))
);
Enter fullscreen mode Exit fullscreen mode

Now the AI knows exactly what it's looking at.


Three schema rules that make AI dramatically better

1. Name things like you're writing documentation

customer_lifetime_value_usd > clv
last_payment_failed_at > pay_fail_ts
is_churned > churn_flag

The extra characters cost nothing. The clarity is worth everything.

2. Use enums or check constraints for status fields

Instead of status codes that mean nothing (1, 2, 3), use human-readable values. The AI will use them in its answers.

status VARCHAR CHECK (status IN ('pending', 'active', 'suspended', 'cancelled'))
Enter fullscreen mode Exit fullscreen mode

3. Add column comments

Most databases support column comments. Use them.

COMMENT ON COLUMN subscriptions.trial_ends_at IS 
  'UTC timestamp when the free trial expires. NULL if never in trial.';
Enter fullscreen mode Exit fullscreen mode

When an AI queries your schema and sees that comment, it knows exactly what the column means — and answers accordingly.


The compounding effect

Bad schema design has always hurt developer productivity. When AI models start reading your schema directly, the cost multiplies.

Every ambiguous column name is a place where the AI will guess wrong.
Every status code is a translation the AI has to do (and might get wrong).
Every missing constraint is a query the AI might construct incorrectly.

We see this constantly at Conexor.io — connecting databases to AI models via MCP. The teams with clean schemas get dramatically better AI responses.

The intelligence was always there. The schema is the interface.

Top comments (0)