Get your API key

Lesson 4 of 5

Design your tables: from one messy sheet to a clean database

Primary keys, foreign keys, one-to-many and many-to-many for a tuition centre; money in paise, dates as dates, no passwords; and a schema review before any code.

8 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson you will turn one messy sheet into a few clean tables, read a table diagram with keys and relations, and review the schema your agent proposes before it writes any code.

You need: a notes app or paper; your coding agent for the last step · Time: 8 minutes

  1. Here is how a small tuition centre often tracks everything, in one Excel sheet:

    Student Phone Batch Batch timing Fee paid Paid on
    Riya Sharma 98xxxxxx10 Maths 11 Mon-Wed 5 pm 2500 03-11-2026
    Riya Sharma 98xxxxxx10 Physics 11 Tue-Thu 6 pm 2000 03-11-2026
    Riya Sharma 97xxxxxx55 Maths 11 Mon-Wed 5 pm 2,500 2 Dec
    Aman Khan 99xxxxxx21 Maths-11 evening 5pm 2500 04/11/26

    Look closely and the problems jump out:

    • Riya's phone is written three times, and one copy is now different. Which one is right?
    • The same batch is spelled two ways, and its timing is copied into every row. Change the timing and you must fix every row.
    • Dates and amounts are typed in four styles, so no formula can add them up reliably.
    • "Who has not paid for December?" is almost impossible to answer.
    Why?

    A database built like this sheet has the same bugs, only hidden behind screens. Agents often create one big table because it is the quickest thing that works today. Your job is to ask for a design that still works when there are 300 students.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. One table per thing
  2. Keys: how tables point at each other
  3. One-to-many and many-to-many
  4. Rules that save you later
  5. Ask for the schema before the code
  6. Recap