PRIMARY KEY in supabase DB
Hi everyone!
I’m creating a full stack app with tRPC and I’ve connected Prisma to a supabase postgresql DB. Everything works fine but when I try to delete columns I have a error saying that I need a PRIMAY KEY.
Can anyone please explain to me why I need that primary key in order to delete /edit my data in DB? 🙏 thanks
4 Replies
I'm confused, are you trying to delete the primary key or have you already deleted the primary key?
You need a unique field for foreign key references in other tables
Othwrwise your relational database becomes distinctly non relational which defeats the point
Thanks for the answer, @zenith
I tired to delete a column from my table and I got a warning message that I need a primary key in order to be able to delete / edit columns.
So I created a primary key and my question was why de we need a primary key, what’s the purpose 😆
Primary keys is the way that rows in other tables relate to that table
Think of it just like an ID
in fact, my PKs are usually just called
id
Here's an exampleThanks a lot for this answer