Quiz - Postgres on Neon
Branching a 10 GB Neon database is near-instant and adds almost no storage, while the old pg_dump/restore copy takes minutes and a fresh 10 GB on disk. Which single architectural fact is the root cause of that difference?
A spec says: a user can belong to many projects, and a project can have many users. What shape does this take in a normalized schema?
project_members) holding a foreign key to each side, keyed on the pair of those two columns.project_id foreign-key column on the user table.project_ids column on user and a user_ids column on project.project_id column expresses one-to-many (each user in exactly one project), which the spec contradicts. The comma-separated columns are a 1NF violation and can’t be foreign-key-enforced or indexed.The course commits to a Neon dev branch as the default local database rather than Docker Postgres. What is the reasoning, and what does choosing Docker instead cost a student given how the app is wired?
DATABASE_URL, a student who prefers Docker changes one variable and loses nothing downstream.DATABASE_URL contract is that the choice is orthogonal to everything downstream: the same migrations, the same seed, and the same db client run against any of the three options. Docker’s cost is real but it’s drift (and losing offline only), not query rewrites or a second set of migrations — those don’t change at all.Your deploy step runs drizzle-kit migrate, a long stream of ALTER/CREATE statements in one session. A teammate points it at the pooled DATABASE_URL (the -pooler host) to keep it consistent with the app. Why is that the wrong URL, and which client exists for this job?
dbUnpooled.dbUnpooled, which is the only client with write access.dbUnpooled (over DATABASE_URL_UNPOOLED, skipping the pooler) exists. The pooled URL isn’t read-only and doesn’t hard-cap statements; the failure is severed sessions, not rejected writes.A Server Component reads the invoice list to render a page; a Server Action later reads an account balance, decides, then deducts credits and inserts a charge atomically. Match each to its client. Select all that apply.
db — the pooled HTTP client: one fetch per query, no held connection.dbTx — the WebSocket client over the same pooled URL — because an interactive read-decide-write needs one connection held across several steps.DATABASE_URL — the unpooled URL is for migrations and long maintenance sessions, not “transactions.” Which driver? A one-shot render read takes HTTP (db); a read-modify-write that must be all-or-nothing takes the WebSocket transaction client (dbTx), which holds its connection only for the transaction’s few milliseconds — something transaction-mode pooling handles fine.Quiz complete
Score by topic