Primary keys and foreign keys
📖 Scenario: You are setting up a simple database for a library system using Supabase. You need to create tables to store information about authors and their books. Each author can have multiple books, so you will use primary keys and foreign keys to link the tables properly.
🎯 Goal: Create two tables in Supabase: authors and books. Define a primary key for each table and a foreign key in books that references the authors table to connect each book to its author.
📋 What You'll Learn
Create a table called
authors with columns id (primary key) and name (text).Create a table called
books with columns id (primary key), title (text), and author_id (foreign key referencing authors.id).Use SQL commands compatible with Supabase to define primary keys and foreign keys.
💡 Why This Matters
🌍 Real World
Databases often need to link related data, like authors and their books, using keys to keep data organized and connected.
💼 Career
Understanding primary and foreign keys is essential for database design, a key skill for backend developers and cloud engineers.
Progress0 / 4 steps