relationship_types
Overview
The relationship_types table stores user-defined categories for labeling relationships. Each user can create their own set of relationship types (e.g., "close friend", "mentor", "study buddy") with custom icons and colors. These types are then used in relationship_edges to label specific connections.
Relevant Invariants
- Invariant #7: "Human-Scale Social Contexts" -- Custom types help users maintain awareness of their social context
- Invariant #19: "Complexity Must Be Earned" -- Relationship labeling is an opt-in advanced feature
Schema
-- Pre-existing table (inferred from frontend code)
CREATE TABLE relationship_types (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES auth.users(id) NOT NULL,
name TEXT NOT NULL,
description TEXT,
category TEXT,
icon TEXT,
color TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | uuid_generate_v4() | Primary key |
user_id | uuid | No | -- | User who created this type |
name | text | No | -- | Type label (e.g., "close friend") |
description | text | Yes | -- | Optional description |
category | text | Yes | -- | Grouping category |
icon | text | Yes | -- | Emoji or icon identifier |
color | text | Yes | -- | Display color for this type |
created_at | timestamptz | No | NOW() | Creation timestamp |
RLS Policies
-- SELECT: Users can view their own relationship types
CREATE POLICY "Users can view own relationship types"
ON relationship_types FOR SELECT
USING (auth.uid() = user_id);
-- INSERT/UPDATE/DELETE: Users manage their own types
CREATE POLICY "Users can manage own relationship types"
ON relationship_types FOR ALL
USING (auth.uid() = user_id);
Related
- relationship_edges -- Instances of these types applied to connections
- profiles -- Type creator
Last updated: 2026-02-07