bubble_chart StackLab

Database Migration

19 steps · pending Not started · person_outline Guest
arrow_back Back

Understand the database

Before writing SQL, let's look at what we're building. The system has three main tables:

code text
students                 books
    │                       │
    │ student_id            │ book_id
    │                       │
    └──────────┐   ┌─────────┘
               ▼   ▼
              borrow
The borrow table acts as the connection between students and books. For example:
code text
CLIFF AMADEUS → Jurassic Park
JAN XAVIER    → Project Hail Mary
RON EDMUND    → 1984
This gives us a simple relationship:
    1. One student can have many borrowing records.
    2. One book can appear in many borrowing records over time.
    3. Each borrowing record belongs to one student and one book.
    4. A borrow_return_date of NULL means the book has not been returned yet.
    5. A non-NULL borrow_return_date means the book has been returned.
Think of borrow as a transaction table. It records who borrowed which book and when.

login Sign in to save your progress permanently. info Progress is saved in your browser session
format_list_numbered Step 2 of 19