๐๐ผ๐ป๐๐ถ๐ป๐๐ฎ๐๐ถ๐ผ๐ป: ๐ง๐ฎ๐ฏ๐น๐ฒ๐, ๐๐ฅ๐จ๐, ๐ฎ๐ป๐ฑ ๐๐ผ๐ฟ๐ฒ๐ถ๐ด๐ป ๐๐ฒ๐๐
I use React and Supabase. Define your data shape before you write queries.
PostgreSQL basics:
- SERIAL handles ID auto-increment.
- DEFAULT fills in missing values.
- NOT NULL makes a field required.
- UNIQUE stops duplicate values.
You use four main operations:
- INSERT to add data.
- SELECT to read data.
- UPDATE to change data.
- DELETE to remove data.
Always use WHERE with UPDATE and DELETE. You will change or erase every row if you forget.
Real apps use multiple tables. A project belongs to a client. Foreign keys link these tables. This keeps your data clean. The database stops you from adding a project to a client who does not exist.
Prisma provides a JavaScript API for these tasks. 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