Skip to main content

Supabase Database

Supabase provides a full PostgreSQL database for storing your app’s data. Create tables, write queries, and let your data scale.

Prerequisites


Creating Tables

In Supabase Dashboard

  1. Go to Table Editor in sidebar
  2. Click Create a new table
  3. Name your table (e.g., tasks)
  4. Add columns

Via Nativeline

You can also ask Nativeline:

Common Column Types


Example: Tasks Table


Row Level Security (RLS)

Always enable RLS on tables with user data. Without it, anyone with your API key can read everything!

Enable RLS

  1. Table Editor → Select table
  2. Toggle “RLS” to enabled
  3. Add policies

Common Policies

Users see only their data:
Users create own data:
Users update own data:
Users delete own data:

CRUD Operations

Create (Insert)

Read (Select)

Update

Delete


Querying Data

Basic Queries

Filtering Options


Relationships

One-to-Many

Tasks belong to a category:

Querying with Relationships


Handling Errors

Common Database Errors

Error Handling in App


Performance Tips

If you often query by a column (like user_id), add an index:
Instead of select("*"), specify columns:
Store frequently-accessed data locally and sync with Supabase.

Testing Database Operations

In Supabase Dashboard

  1. Table Editor → Select table
  2. View, add, edit, delete rows manually
  3. Great for testing and debugging

Via SQL Editor

  1. SQL Editor in Supabase sidebar
  2. Write and run queries directly
  3. Test policies and queries

Next Steps

Storage

Upload files and images

Realtime

Live data updates