Member-only story
Designing PostgreSQL Database Using AI: Why You Should Avoid ENUMs & How MySQL Offers More Storage Options
If you are not Medium member or have exceeded your free quota, you can read this story by clicking on this link https://rkanade.medium.com/database-conversations-2-913ebc9a5c90?sk=d7e5b013da20163b73171a76107519f6
In the earlier part of the series we looked at how to install & do bare minimum postgres configuration from best practices and security standpoint. In this part we will look at some of our experiences using AI to define our schema and some comparison points between MySQL and Postgres.
AI-powered tools like ChatGPT, Gemini, and DeepSeek have changed how developers approach database design. Today, teams routinely use AI to generate schemas, validate ideas, and build quick prototypes. But how good are these AI-generated schemas in real-world applications?
As we experimented with AI for designing our PostgreSQL database, we noticed that AI often missed crucial best practices. In this post, we will share some real-world scenarios where AI could have done a better job, and we will also compare PostgreSQL and MySQL in terms of storage optimization and data type flexibility.
When we started using it, we were expecting AI to not only generate the schema quickly but also for ensure by default
- Implement the best practices or thumb rules of database design.
- Infer relationship & take care of suggesting appropriate constraints.
- Choose the correct data types for the column.
- Optimize from a storage and query performance.
The reality was quite different & in this post we present few scenarios where the team thought AI could have done a better job in the first go.
Please note we experimented with all leading service providers and various LLMs, so in rest of the article we will just refer to this as AI rather then mentioning specific products like chatGPT, Gemini, DeepSeek etc.
Reality check #1: Lack of foreign key constraints
In the initial script generated by AI, there were no foreign key constrains defined at all. Defining foreign keys is a basic database design principle & we thought the initial…