From 2c4319afcb7ebf799cb7dd20bb2d6f71ef4df8c6 Mon Sep 17 00:00:00 2001 From: simonpetit Date: Fri, 7 Nov 2025 13:46:58 +0000 Subject: [PATCH] completing draft --- drafts/postgres_messaging_app.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drafts/postgres_messaging_app.md b/drafts/postgres_messaging_app.md index d40d7f6..16d9f77 100644 --- a/drafts/postgres_messaging_app.md +++ b/drafts/postgres_messaging_app.md @@ -3,4 +3,36 @@ Here is a funny idea I came up with : using postgres to make an instant messaging app. +## The tables +First create a basic user table: + + CREATE TABLE users ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + username VARCHAR + ); + + +Then create a conversation table: + + CREATE TABLE conversation ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR + ); + +And a participant table: + + CREATE TABLE participant ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + user_id UUID REFERENCES users(id), + conversation_id UUID REFERENCES conversation(id) + ); + +Then a message table : + + CREATE TABLE message ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + sender_id UUID REFERENCES participant(id), + conversation_id UUID REFERENCES conversation(id), + content VARCHAR + );