Bird
Raised Fist0
Supabasecloud~20 mins

Seed data management in Supabase - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Seed Data Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate
2:00remaining
How does Supabase handle seed data execution order?

When running multiple seed files in Supabase, how does the system determine the order in which they execute?

ASupabase runs seed files based on the timestamp inside each file.
BSupabase runs seed files alphabetically by filename.
CSupabase runs seed files in parallel without guaranteed order.
DSupabase runs seed files in the order they were created in the file system.
Attempts:
2 left
💡 Hint

Think about how files are usually sorted when listed.

❓ Configuration
intermediate
2:00remaining
Which command seeds data into a Supabase project?

You want to load seed data into your Supabase database. Which CLI command should you use?

Asupabase seed apply
Bsupabase db seed
Csupabase db push
Dsupabase seed run
Attempts:
2 left
💡 Hint

Look for the command that explicitly mentions running seeds.

❓ Architecture
advanced
3:00remaining
What is the best practice for managing seed data in a team using Supabase?

Your team collaborates on a Supabase project. What is the best way to manage seed data to avoid conflicts and ensure consistency?

AStore seed files in the project repository and run them via CI/CD pipelines.
BEach developer runs their own local seed files independently without sharing.
CManually insert seed data directly into the production database.
DUse separate seed files for each developer and merge results manually.
Attempts:
2 left
💡 Hint

Think about collaboration and automation.

❓ security
advanced
3:00remaining
What security risk should you avoid when managing seed data in Supabase?

When adding seed data to your Supabase project, which practice can lead to a security risk?

AUsing environment variables to store database connection info.
BEncrypting sensitive data before adding it to seed files.
CIncluding sensitive user credentials or API keys in seed files.
DLimiting seed data to non-sensitive sample records.
Attempts:
2 left
💡 Hint

Think about what data should never be in code files.

🧠 Conceptual
expert
3:00remaining
What happens if a seed file in Supabase contains a SQL error during execution?

You run supabase seed run but one seed file has a syntax error in its SQL. What is the expected behavior?

AThe seed process stops immediately and reports the error; no further seed files run.
BThe seed process skips the faulty file and continues with the next seed files.
CThe seed process ignores errors and completes all seed files regardless.
DThe seed process rolls back all previously applied seed files and stops.
Attempts:
2 left
💡 Hint

Consider how errors usually affect batch operations.

Practice

(1/5)
1. What is the main purpose of seed data in a Supabase project?
easy
A. To delete all existing data from the database
B. To backup the database before changes
C. To add initial data automatically to the database
D. To monitor database performance

Solution

  1. Step 1: Understand seed data concept

    Seed data is used to populate the database with initial or default data automatically.
  2. Step 2: Identify the purpose in Supabase

    In Supabase, seed data helps set up consistent data for testing and development.
  3. Final Answer:

    To add initial data automatically to the database -> Option C
  4. Quick Check:

    Seed data = initial data setup [OK]
Hint: Seed data means initial data added automatically [OK]
Common Mistakes:
  • Confusing seed data with backup or monitoring
  • Thinking seed deletes data instead of adding
  • Assuming seed data is for performance tuning
2. Which command runs seed scripts in a Supabase project?
easy
A. supabase db backup create
B. supabase db migrate run
C. supabase db reset
D. supabase db seed run

Solution

  1. Step 1: Recall Supabase seed command

    The command to execute seed scripts is supabase db seed run.
  2. Step 2: Differentiate from other commands

    supabase db migrate run applies migrations, not seeds; reset and backup are unrelated.
  3. Final Answer:

    supabase db seed run -> Option D
  4. Quick Check:

    Seed scripts run with supabase db seed run [OK]
Hint: Seed scripts run with 'supabase db seed run' command [OK]
Common Mistakes:
  • Using migrate command instead of seed
  • Confusing reset with seed run
  • Trying backup commands for seeding
3. Given this seed script snippet in Supabase:
INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');
INSERT INTO users (id, name) VALUES (3, 'Charlie');
What will be the total number of users after running the seed?
medium
A. 3
B. 2
C. 1
D. 4

Solution

  1. Step 1: Count inserted rows in first statement

    The first INSERT adds 2 users: Alice and Bob.
  2. Step 2: Count inserted rows in second statement

    The second INSERT adds 1 user: Charlie.
  3. Step 3: Calculate total users inserted

    Total users = 2 + 1 = 3.
  4. Final Answer:

    3 -> Option A
  5. Quick Check:

    2 + 1 = 3 users inserted [OK]
Hint: Add all inserted rows to find total users [OK]
Common Mistakes:
  • Counting only first INSERT statement
  • Assuming duplicate rows overwrite
  • Miscounting number of values per INSERT
4. You run supabase db seed run but get an error: duplicate key value violates unique constraint. What is the likely cause?
medium
A. Database connection is lost
B. Seed script tries to insert data with existing primary keys
C. Supabase CLI is not installed
D. Seed script syntax is incorrect

Solution

  1. Step 1: Understand the error message

    The error means the seed script tries to insert rows with keys already in the database.
  2. Step 2: Identify cause in seed data context

    Duplicate primary keys cause conflicts when inserting seed data multiple times without cleanup.
  3. Final Answer:

    Seed script tries to insert data with existing primary keys -> Option B
  4. Quick Check:

    Duplicate key error = duplicate primary keys in seed [OK]
Hint: Duplicate key error means repeated primary keys in seed data [OK]
Common Mistakes:
  • Assuming syntax error causes duplicate key message
  • Blaming CLI installation for data errors
  • Ignoring database state before seeding
5. You want to seed a Supabase database with initial users but avoid duplicate entries if the seed runs multiple times. Which approach is best?
hard
A. Use INSERT ... ON CONFLICT DO NOTHING in seed scripts
B. Delete the entire database before each seed run
C. Run seed scripts only once manually
D. Use DROP TABLE users before inserting

Solution

  1. Step 1: Understand the problem of duplicates

    Running seed multiple times can cause duplicate key errors if data already exists.
  2. Step 2: Choose a safe insert method

    Using INSERT ... ON CONFLICT DO NOTHING skips inserting duplicates safely.
  3. Step 3: Evaluate other options

    Deleting database or tables is risky and inefficient; running seed once is error-prone.
  4. Final Answer:

    Use INSERT ... ON CONFLICT DO NOTHING in seed scripts -> Option A
  5. Quick Check:

    Safe inserts prevent duplicates with ON CONFLICT [OK]
Hint: Use ON CONFLICT DO NOTHING to avoid duplicate inserts [OK]
Common Mistakes:
  • Dropping tables can cause data loss
  • Assuming seed runs only once always
  • Deleting whole database is overkill
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard