Skip to main content

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

ColumnTypeNullableDefaultDescription
iduuidNouuid_generate_v4()Primary key
user_iduuidNo--User who created this type
nametextNo--Type label (e.g., "close friend")
descriptiontextYes--Optional description
categorytextYes--Grouping category
icontextYes--Emoji or icon identifier
colortextYes--Display color for this type
created_attimestamptzNoNOW()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);

Last updated: 2026-02-07