The table creates successfully, but when inserting rows without specifying order_id, Supabase gives an error. What is the most likely cause?
medium
A. No SERIAL type for auto-incrementing primary key
B. Missing semicolon at the end of the statement
C. No column defined as UNIQUE
D. Using INT instead of INTEGER for data type
Solution
Step 1: Check the primary key column definition
The order_id is INT PRIMARY KEY but lacks auto-increment, so inserting rows without specifying order_id causes errors.
Step 2: Understand SERIAL usage for auto-increment
Using SERIAL instead of INT for primary key allows automatic unique number generation, preventing insert errors.
Final Answer:
No SERIAL type for auto-incrementing primary key -> Option A
Quick Check:
Primary key needs SERIAL for auto-increment [OK]
Hint: Use SERIAL for auto-increment primary keys [OK]
Common Mistakes:
Assuming INT auto-increments automatically
Ignoring missing semicolon errors
Confusing UNIQUE with PRIMARY KEY requirements
5. You want to create a table employees with columns id (auto-incrementing primary key), name (text, required), and email (text, unique). Which SQL command correctly achieves this in Supabase?
hard
A. CREATE TABLE employees (id SERIAL PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE);
B. CREATE TABLE employees (id INT PRIMARY KEY, name TEXT, email TEXT UNIQUE NOT NULL);
C. CREATE TABLE employees (id SERIAL, name TEXT NOT NULL, email TEXT);
D. CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE);
Solution
Step 1: Define auto-incrementing primary key
Use SERIAL PRIMARY KEY for id to auto-generate unique IDs.
Step 2: Set constraints for name and email
name must be NOT NULL to be required; email must be UNIQUE to avoid duplicates.
Step 3: Verify all constraints and syntax
CREATE TABLE employees (id SERIAL PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE); correctly includes all required constraints and syntax.
Final Answer:
CREATE TABLE employees (id SERIAL PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE); -> Option A
Quick Check:
Auto-increment + NOT NULL + UNIQUE = CREATE TABLE employees (id SERIAL PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE); [OK]
Hint: Combine SERIAL, NOT NULL, and UNIQUE for correct constraints [OK]
Common Mistakes:
Forgetting NOT NULL on required columns
Using INT without SERIAL for auto-increment
Missing UNIQUE constraint on email
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.