PostgreSQL
AI suggested using Supabase and PostgreSQL for my users and orders; how is that different from saving files?
Database is the general umbrella term for any data storage system; PostgreSQL is a concrete, production-grade ACID relational database engine.
SQL is the standard query language for relational data; PostgreSQL is the database software that executes SQL, manages disk storage, and enforces transactions.
When to use it
- Establish foreign keys between related tables to enforce data integrity at the database layerGive AI the table schema toousers.iduuidusers.emailtext · uniqueOutputExplain how many rows are affected
- Wrap coupled steps like stock deduction and order creation in transactions for all-or-nothing executionPreview the impact before deleting or changing dataSELECT ... WHERE id=42→Confirm 1 row→DELETE
- Add indexes on frequent query columns and inspect execution plans with EXPLAIN when queries slow downLearn to read data firstQuerySELECT * FROM users WHERE id = 42 → Result42 · Jordan
- Store flexible properties in JSONB columns to balance relational structure with semi-structured schema agilityTreat input only as dataSELECT * FROM users WHERE email = $1$1 = "oil@example.com"The parameter is not executed as another piece of SQL.
When NOT to use it
- Save orders and stock in separate text files where crashes cause corrupted records and oversellingRun a write operation in production without confirming the conditionsCurrent environmentPRODUCTIONAbout to runUPDATE users ...Verify first with test data or in a transaction
- Concatenate raw user input into SQL query strings without parameterized query protectionConcatenate input directly into SQLemail = ' OR 1=1 --SELECT * FROM users WHERE email = '' OR 1=1
- Index every table column blindly, which degrades write speed and inflates storage overheadDeletion without WHERERunDELETE FROM users → Impact12,480 rows deleted
- Expose raw database ports to public internet without password protection and strict network firewallsDisplay text cannot replace stable fieldsStore only"Premium member" → Should beplan_id: pro_2026
DATABASE app_productionTABLE users (id, email)TABLE orders (id, user_id, amount)users JOIN orders