๐ง๐ฎ๐ฏ๐น๐ฒ๐, ๐๐ฅ๐จ๐, ๐ฎ๐ป๐ฑ ๐๐ผ๐ฟ๐ฒ๐ถ๐ด๐ป ๐๐ฒ๐๐
I use React and Supabase. You must define your data shape first.
PostgreSQL uses these rules for tables:
- SERIAL handles IDs automatically.
- DEFAULT fills in missing values.
- NOT NULL makes a field required.
- UNIQUE prevents duplicate values.
You use four main actions for data:
- INSERT adds data.
- SELECT reads data.
- UPDATE changes data.
- DELETE removes data.
One rule saves you from a big mistake. Always use WHERE with UPDATE and DELETE. You will wipe your whole table without it.
Apps use multiple tables. A project belongs to a client. You link them with a foreign key.
A foreign key ensures every project has a valid client. The database keeps your data clean.
Prisma lets you do this with a JavaScript API. You do not need to write raw SQL.
Building in public. Week 3 of 16.
Source: https://dev.to/chinwuba_jeffrey/continuation-tables-crud-and-foreign-keys-1o1e