Database design for students: a class project, step by step

A database course project is graded on the design: the right tables, keys and relationships, normalized and drawn as an ER diagram. Here is the process, six project ideas with their tables, and a worked example you can check yours against.

Short answer: turn the assignment into requirements, pick the entities, define the relationships and their cardinality, choose primary and foreign keys, normalize to third normal form, then draw the ER diagram and write the CREATE TABLE SQL. To check your work, describe the same system in AI2SQL's design mode and compare its tables and diagram with yours.

The six steps

  1. Write down the requirements. List what the system must store and the questions it must answer, in plain sentences taken from the assignment, for example: members borrow copies of books and pay a fine when a loan is late.
  2. Pick the entities. Underline the nouns that have their own data (member, book, copy, loan, fine). Each becomes a table; nouns that only describe something (title, due date) become columns.
  3. Define the relationships and cardinality. For each pair of entities decide one-to-one, one-to-many or many-to-many. Put the foreign key on the many side, and give every many-to-many relationship its own table.
  4. Choose primary and foreign keys. Give each table a primary key (a surrogate id or a natural key such as an ISBN), then add the foreign keys and decide what happens on delete.
  5. Normalize to third normal form. Remove repeating groups (1NF), make non-key columns depend on the whole key (2NF) and remove columns that depend on other non-key columns (3NF).
  6. Draw the ER diagram and write the SQL. Draw the ERD, write the CREATE TABLE statements, insert a few sample rows and run the queries the assignment asks for to prove the design works.

Six database project ideas, with their tables

Project Tables The relationship to get right
Library management members, books, authors, book_authors, copies, loans, fines books ↔ authors many-to-many; a copy has many loans over time
Course registration students, instructors, courses, sections, enrollments, prerequisites students ↔ sections through enrollments; courses reference themselves for prerequisites
Hospital appointments patients, doctors, departments, appointments, prescriptions, medications doctors belong to a department; an appointment links one patient and one doctor
Online store customers, addresses, products, categories, orders, order_items, payments orders ↔ products through order_items, which stores quantity and price at the time of sale
Gym membership members, plans, memberships, trainers, classes, class_bookings a member has many memberships over time; members ↔ classes through class_bookings
Hotel reservations guests, rooms, room_types, reservations, reservation_rooms, invoices one reservation can cover several rooms; room availability comes from date ranges

Worked example: a library system

Assignment: "Members borrow copies of books. A book can have several authors and several copies. A loan has a due date; a late return creates a fine."

Entities: members, books, authors, copies, loans, fines. Books and authors are many-to-many, so they get a book_authors table. A book has many copies, a copy has many loans over time, and a loan has at most one fine. In PostgreSQL:

CREATE TABLE members (
  member_id  SERIAL PRIMARY KEY,
  full_name  TEXT NOT NULL,
  email      TEXT UNIQUE NOT NULL,
  joined_on  DATE NOT NULL DEFAULT CURRENT_DATE
);
CREATE TABLE books (
  isbn       TEXT PRIMARY KEY,
  title      TEXT NOT NULL,
  published  INT
);
CREATE TABLE authors (
  author_id  SERIAL PRIMARY KEY,
  full_name  TEXT NOT NULL
);
CREATE TABLE book_authors (
  isbn       TEXT REFERENCES books(isbn),
  author_id  INT  REFERENCES authors(author_id),
  PRIMARY KEY (isbn, author_id)
);
CREATE TABLE copies (
  copy_id    SERIAL PRIMARY KEY,
  isbn       TEXT NOT NULL REFERENCES books(isbn),
  shelf      TEXT
);
CREATE TABLE loans (
  loan_id     SERIAL PRIMARY KEY,
  copy_id     INT  NOT NULL REFERENCES copies(copy_id),
  member_id   INT  NOT NULL REFERENCES members(member_id),
  loaned_on   DATE NOT NULL,
  due_on      DATE NOT NULL,
  returned_on DATE,
  CHECK (due_on >= loaned_on)
);
CREATE TABLE fines (
  loan_id    INT PRIMARY KEY REFERENCES loans(loan_id),
  amount     NUMERIC(8,2) NOT NULL CHECK (amount > 0),
  paid       BOOLEAN NOT NULL DEFAULT false
);

Two queries that prove the design answers the assignment's questions:

-- Overdue loans with the member's email
SELECT m.full_name, m.email, b.title, l.due_on
FROM loans l
JOIN members m ON m.member_id = l.member_id
JOIN copies  c ON c.copy_id   = l.copy_id
JOIN books   b ON b.isbn      = c.isbn
WHERE l.returned_on IS NULL AND l.due_on < CURRENT_DATE;

-- Unpaid fines per member
SELECT m.full_name, SUM(f.amount) AS owed
FROM fines f
JOIN loans   l ON l.loan_id   = f.loan_id
JOIN members m ON m.member_id = l.member_id
WHERE NOT f.paid
GROUP BY m.full_name
ORDER BY owed DESC;

Why it is in third normal form: author names live only in authors, the title lives only in books (not repeated on every copy), and the fine is keyed by the loan it belongs to.

Mistakes that cost marks

Using AI2SQL for your project

Open design mode and describe the system the way the assignment does. AI2SQL returns the tables, keys and CREATE TABLE SQL for PostgreSQL, MySQL, SQL Server or Oracle and draws the ER diagram. Compare it with your own design, ask why it chose a key or a table, and ask for changes ("add a reservation queue for books that are out"). You can also paste the CREATE TABLE statements you wrote to get your diagram drawn and run practice queries against it. Follow your course's rules on AI tools, and make sure you can explain every table yourself.

More on the tool itself: AI ERD generator. More on the theory: database normalization with examples.

Frequently asked

How do I design a database for a class project? +

Turn the assignment into requirements, pick the entities (tables), set the relationships and cardinality, choose primary and foreign keys, normalize to third normal form, then draw the ER diagram and write the CREATE TABLE SQL. Finish by running the queries the assignment asks for against sample data.

What is a good database project idea for students? +

Systems with clear many-to-many relationships work best: library management, course registration, hospital appointments, an online store, gym membership or hotel reservations. Each needs five to eight tables, which is the usual size for a semester project.

How many tables should a student database project have? +

Most course projects land between five and ten tables. Fewer usually means a relationship is missing; many more usually means the scope is too big for the deadline. Check your rubric, since some courses set a minimum.

Can I use AI to design my database for an assignment? +

You can use AI2SQL to get a first design, see the ER diagram and check your own work, but follow your course's rules on AI tools. Make sure you can explain every table, key and relationship, because that is what the assignment is grading.

Which database should I use: MySQL or PostgreSQL? +

Use the one your course uses. If you can choose, PostgreSQL is strict about types and constraints, which catches design mistakes early; MySQL is common in web hosting. AI2SQL writes CREATE TABLE SQL for PostgreSQL, MySQL, SQL Server and Oracle.

Is AI2SQL free for students? +

Yes, you can sign up free and use design mode with a few requests a day. Pro and Team raise the limits and start with a 7-day trial.

Get a first design and ER diagram in one sentence

Describe your assignment, get tables, keys, an ER diagram and CREATE TABLE SQL, then check and change it in plain English.

Try design mode free →

Already have an account? Open design mode directly in the builder.

Related guides