Short answer: open design mode in the AI2SQL builder, describe the app ("a library system where members borrow books and pay late fees"), and you get the tables, primary and foreign keys, an ER diagram, and CREATE TABLE SQL for PostgreSQL, MySQL, SQL Server or Oracle. You can then ask for changes and query the design in plain English.
How it works
- Describe the app. Open design mode in the AI2SQL builder and describe what the database is for, for example: a course registration system for a university with students, courses, sections, instructors and enrollments.
- Get the tables and CREATE TABLE SQL. AI2SQL designs the tables, columns, primary keys and foreign keys and writes the CREATE TABLE statements for your database (PostgreSQL, MySQL, SQL Server or Oracle).
- See the ER diagram. The builder draws an entity relationship diagram from the CREATE TABLE statements, with one-to-many and many-to-many relationships shown through their foreign keys.
- Change it and query it. Ask for changes in plain English (add a waitlist, split a table) and ask questions against the design; AI2SQL writes the SQL against the tables you designed.
Example: a class project
A typical database course assignment: "Design a course registration system. Students enroll in sections of courses; each section has one instructor, a term and a room; enrollment stores the grade." A first design looks like this (PostgreSQL):
CREATE TABLE students (
student_id SERIAL PRIMARY KEY,
full_name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL
);
CREATE TABLE instructors (
instructor_id SERIAL PRIMARY KEY,
full_name TEXT NOT NULL
);
CREATE TABLE courses (
course_id SERIAL PRIMARY KEY,
code TEXT UNIQUE NOT NULL, -- e.g. CSE 412
title TEXT NOT NULL,
credits INT NOT NULL
);
CREATE TABLE sections (
section_id SERIAL PRIMARY KEY,
course_id INT NOT NULL REFERENCES courses(course_id),
instructor_id INT NOT NULL REFERENCES instructors(instructor_id),
term TEXT NOT NULL,
room TEXT
);
CREATE TABLE enrollments (
student_id INT REFERENCES students(student_id),
section_id INT REFERENCES sections(section_id),
grade TEXT,
PRIMARY KEY (student_id, section_id)
); And the relationships the diagram shows:
- courses → sections: one course has many sections.
- instructors → sections: one instructor teaches many sections.
- students ↔ sections: many-to-many, resolved by
enrollmentswith a composite primary key.
From there, ask for what the assignment adds ("add prerequisites between courses", "add a waitlist with positions") or ask questions against the design ("list students taking more than 15 credits this term") and AI2SQL writes the SQL against your tables.
Check the design before you hand it in
For the full process and more project ideas, see database design for students.
- Every table has a primary key, and every relationship has a foreign key on the "many" side.
- Many-to-many relationships have their own table (like
enrollments). - No repeating groups or comma-separated lists in a column (first normal form).
- Non-key columns depend on the whole key (watch composite keys for second normal form).
- Names follow your course's convention (singular or plural, snake_case).
Already have a schema?
Paste your CREATE TABLE statements into the builder instead. It draws the diagram, lists the tables and lets you ask questions against them without connecting a database. When you are ready to query real data, connect PostgreSQL, MySQL or SQL Server read-only, or let Claude or ChatGPT query it through AI2SQL.