Welcome to the heart of your Supabase project: the database! Even if you're new to databases, Supabase makes it incredibly approachable. At its core, a relational database is organized into 'tables.' Think of a table like a spreadsheet: it stores information in a structured way.
Each table represents a specific type of data. For example, if you're building a blog, you might have a 'posts' table to store all your blog articles, a 'users' table for your registered users, and a 'comments' table for comments on those posts.
graph TD;
A[Database] --> B(Tables);
B --> C(Posts Table);
B --> D(Users Table);
B --> E(Comments Table);
Within each table, you have 'columns.' Columns define the individual pieces of information for each entry in that table. So, in our 'posts' table, you might have columns like 'title', 'content', 'published_at', and 'author_id'. Each row in the table represents a single post, and each column holds a specific detail about that post.
graph TD;
A[Posts Table] --> B(ID);
A --> C(Title);
A --> D(Content);
A --> E(Published At);
A --> F(Author ID);
Every column needs a 'data type' to specify what kind of information it can hold. Common data types include:
- Text/Varchar: For strings of characters (names, descriptions).
- Integer: For whole numbers (quantities, IDs).
- Boolean: For true/false values (e.g., 'is_published').
- Timestamp: For dates and times.
- UUID: Universally Unique Identifiers, often used for primary keys.
Supabase uses PostgreSQL under the hood, so you'll encounter a rich set of data types.
One of the most crucial columns in any table is the 'primary key'. This is a unique identifier for each row. It ensures that every record in your table can be distinctly identified and easily referenced. Supabase automatically generates a UUID primary key for you when you create a new table, which is a great default.
Understanding tables and columns is the foundational step to designing your database schema in Supabase. As we move forward, we'll see how to create these tables and populate them with data.