advancedTop 30 Scenario-Based Questions
You're designing a multi-tenant SaaS for 10,000 tenants. Which isolation model and how do you prevent cross-tenant data leakage?
Shared Schema + Row-Level Security for 10,000 tenants: 1) Add UUID tenant_id to every table. 2) Composite index: CREATE INDEX ON orders(tenant_id, order_date). 3) RLS: ALTER TABLE orders ENABLE ROW LEVEL SECURITY; CREATE POLICY orders_tenant ON orders USING (tenant_id = current_setting('app.tenant_id')::UUID). 4) Application: SET LOCAL app.tenant_id = ? on every connection checkout. 5) Never expos
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response