0
0
Supabasecloud~10 mins

Data types and constraints in Supabase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a column with a text data type in Supabase.

Supabase
CREATE TABLE users (username [1] NOT NULL);
Drag options to blanks, or click blank then click option'
AINTEGER
BVARCHAR(255)
CTEXT
DBOOLEAN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INTEGER or BOOLEAN for text data.
Using VARCHAR without specifying length.
2fill in blank
medium

Complete the code to add a primary key constraint to the id column.

Supabase
CREATE TABLE products (id [1] PRIMARY KEY, name TEXT);
Drag options to blanks, or click blank then click option'
ASERIAL
BDATE
CTEXT
DBOOLEAN
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT as a primary key without uniqueness.
Using BOOLEAN or DATE for id columns.
3fill in blank
hard

Fix the error in the column definition to correctly enforce a NOT NULL constraint.

Supabase
CREATE TABLE orders (order_id INTEGER [1]);
Drag options to blanks, or click blank then click option'
AUNIQUE
BNULL
CDEFAULT NULL
DNOT NULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using NULL or DEFAULT NULL which allow empty values.
Confusing UNIQUE with NOT NULL.
4fill in blank
hard

Fill both blanks to create a table with a unique email column and a created_at timestamp with default current time.

Supabase
CREATE TABLE users (email [1] UNIQUE, created_at [2] DEFAULT now());
Drag options to blanks, or click blank then click option'
ATEXT
BBOOLEAN
CTIMESTAMP
DINTEGER
Attempts:
3 left
💡 Hint
Common Mistakes
Using BOOLEAN or INTEGER for email or timestamp.
Forgetting UNIQUE constraint on email.
5fill in blank
hard

Fill all three blanks to define a table with an id primary key, a price column that cannot be negative, and a status column with a default value.

Supabase
CREATE TABLE items (id [1] PRIMARY KEY, price [2] CHECK (price >= 0), status [3] DEFAULT 'available');
Drag options to blanks, or click blank then click option'
ASERIAL
BNUMERIC
CTEXT
DBOOLEAN
Attempts:
3 left
💡 Hint
Common Mistakes
Using BOOLEAN for price or status.
Not using CHECK to prevent negative prices.