Planning Your App's Database with AI: Entities, a Credit Ledger, Soft Delete, and Why Hardcoding Is Bad

Planning Your App's Database with AI: Entities, a Credit Ledger, Soft Delete, and Why Hardcoding Is Bad
Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

Before an app can remember anything, someone has to decide what it remembers. In this lesson from Ariel’s no-code course, the class defines entities, the professional name for the tables in your database. The app is still the giraffe meme generator: a user arrives at the home page, gets one meme for free, is then asked to buy a package, and keeps generating and sharing. Ariel starts with plain logic, hands it to Claude Code, answers its questions like a non-programmer would, and walks away with a schema of twelve tables.

Thinking in entities

What does the app need to manage? Simple logic first.

  1. Users. If Moshe signs up and Rachel signs up, you need information about each of them: their user, their login, maybe their history.
  2. Prompt and meme history. Ariel pushes the app a little further than he normally would here, on purpose. If Moshe made a bunch of images with all kinds of prompts and one of them came out hilarious, he wants to see his history: when he worked, how much, what he did, so he can copy it or duplicate it. The image itself can be part of that history. Storing every image may be heavy, so maybe save them in very low quality, or keep them for 30 days. Either way, he wants the full prompt and the result.
  3. Packages. The user paid for, say, ten memes. The database has to know what he paid, when he paid, and how much he has left. In professional terms, that is a transaction: a payment in exchange for something.

Writing the task

He duplicates an existing task file and names it T-DB. The first line, as always: read the spec first. You cannot walk up to AI and say “here is what I want”. It does not know what you are talking about. It is like asking a person to add a feature to your software without showing them the software.

The task: build me a schema for the database, using plain SQL. The entities, in English:

  • users, based on Google login. Unless you have a reason not to, always let Google manage your users. It is a company that spends billions every year on security.
  • meme and prompt history.
  • transaction history.
  • somewhere to track how many memes are left in the package the user bought.
  • AI services: since the app uses AI, every call should be logged: what was sent, what came back, and what it cost. (OpenRouter, the provider, comes in a later lesson.)

Then: “think of more entities yourself, the more data and tables the better.” And write it to the docs.

He also points out the honest version: if you knew none of this, you could just say “build me a SQL schema” and that is more or less it. You add the parts you do understand, and you go at your own pace.

Ariel’s tip: overload your database

His advice is to load your database with everything you think is relevant, and everything you do not, and trim later if you must. People try to be very efficient, then they are missing things, and adding missing things later is hard, annoying, and the history is gone. Storage and compute are not the problems they used to be.

Opening the terminal and picking the model

In VS Code, Ctrl + backtick (the key left of 1, with the tilde) opens a terminal inside the editor, exactly like CMD. Type claude and you are in. Fable 5 already shows up in the model list: very, very expensive, and on a $20 Pro plan you would probably burn through it in a second. The course stays on Sonnet, because the whole point is building a full app on $20. He tags the task file with @, hits Enter, and lets it work.

Answering Claude’s questions

Claude comes back with design questions, and they are good ones.

  • Anonymous users. An anonymous user makes their free meme, then signs up with Google. Should that meme be attached to the account retroactively? Yes.
  • Packages: hardcoded or in the database? Hardcoded means written physically in the code. Ariel’s answer goes straight into the spec as a rule: hardcoded is bad. Nothing should be hardcoded. The database is easy to update, code is hard to update.
  • Hard delete or soft delete? When users delete something, do you really delete it forever, or just mark it deleted, hide it, and let the admin still see it? Soft delete (an is_deleted flag) allows recovery and is good for analytics, and Ariel recommends it as a default. One caveat: privacy laws. If a user asks you to delete their personal information, keeping it may be against the law, so read up on that. For memes, soft delete it is.
  • Pricing AI calls. Each meme needs two AI calls, one to help write the prompt and one for the image engine. Log them as one package or separately? Separately, every single call, because the goal is to monitor costs clearly. Today we build agentic apps with “intelligence for rent”, so you need to understand your external services. There will be a whole lesson on costs.
  • Tracking credits: three approaches. A column that says how many memes you have left; a ledger (a full history, like a bank statement); or a ledger plus a cache. Ariel admits he does not fully get the differences and goes with the recommendation. His take: in an app this small it barely matters, but in a big app you always want a ledger for the full history, while caching is pretty unnecessary for something this tiny.

When Claude asks whether it all looks right, he answers the way the course always does: “I am not a coder. You audit, check yourself, and continue.” But if you have the time and patience, he says, ask it what everything means. Integer, primary key, all those words: “explain it to me line by line.” That is how he learned servers. He sat for a few days, and AI explained it line by line.

Twelve tables from five ideas

The plan comes back, and a collapsed view shows the relationships. The tables: anonymous sessions, giraffe styles, memes, users, purchases, transactions, the ledger (like your bank history), remaining credits, AI calls, admin approval for the main gallery, likes (hearts on memes, which Ariel had not even thought of), and settings.

He gave it five things and got twelve tables back, which is a sign the planning is getting good. It also means he now has to learn about his own app, which, he says, is exactly right.

The last step is adding a reference to the main spec. And why plan the frontend and database before the backend? Because the backend’s job is to serve both sides. Once both sides are clear, you can ask for the thing that ties them together, which is the next lesson: planning the backend in eight layers.

๐Ÿ”ฅ Roast Corner

Ariel’s professional database advice, verbatim in spirit: overload it. Everything you think you need, and everything you don’t. More tables is better. And Claude, who has never once been told “that’s enough”, took five bullet points and returned twelve tables, including a likes table for giraffe memes that its own product manager had not thought of. This is the first meme generator in history with a ledger. Not a counter, a ledger, “like a bank statement”. The giraffes now have better financial records than most startups.

Then the model picker. Fable 5 is right there, and the verdict is “very, very expensive, on the $20 plan you’ll suck it dry in a second”. This from the man whose relationship with tokens is best described as arson. On camera, he is a disciplined Sonnet user. Off camera, we have the bills.

But my favourite part is soft delete. Picture Moshe. Moshe made a giraffe meme at 2 a.m. that he deeply regrets, and he hits delete. Moshe thinks it is gone. It is not gone. It has an is_deleted flag, a row in the ledger, two logged AI calls with their exact cost, three likes, and it is waiting for admin approval for the main gallery. Hardcoded is bad, Moshe. Forgetting is worse.

๐Ÿค– AI for Humans

In rural America, getting a heart ultrasound usually means traveling to a hospital with a specialist sonographer, and there are not many of those in rural areas. A team at Duke University School of Medicine, as part of the large RURAL study, tried a different model: a mobile health unit visiting ten rural counties in Alabama, Kentucky, Louisiana and Mississippi, where nurses, nursing assistants and CT technicians who had never done a heart ultrasound captured scans with real-time guidance from AI software, after just two hours of training. Every scan was then reviewed off-site by certified experts at the Duke Clinical Research Institute’s imaging lab.

The preliminary results, presented at the American Heart Association’s Scientific Sessions 2026: across 4,597 participants, 98% of scans included all six required views, the experts rated them adequate more than 99% of the time, and the median scan took 9.5 minutes. The scans found 133 critical results, most often a heart pumping weaker than normal, and 99% of those were returned to participants within three days. The AHA is clear that this is a non-peer-reviewed abstract, so the findings are preliminary. Source: American Heart Association Newsroom.

It is the same pattern as this lesson, with far higher stakes: a non-expert works with AI, and a rigorous review layer checks the result. Here, the payoff is not a cleaner schema. It is people finding out about a heart problem without having to drive hours to find a specialist.

Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

๐Ÿ’ฌ Comments