What Is Row-Level Security and Why Does a Hospital Database Need It?
Row-Level Security (RLS) is a rule enforced by the database itself — not by the application code sitting on top of it — that restricts which rows any given query can ever return. For a hospital, that means one hospital's data (in a multi-location deployment) or one staff role's permitted records stays isolated even if a bug exists somewhere in the application layer, because the database refuses to return rows the query isn't allowed to see in the first place.
Why This Is Stronger Than Application-Level Checks Alone
Application-level permission checks are only as reliable as every code path that remembers to apply them — one missed check in one API route can expose data. Database-enforced RLS (as PostgreSQL implements it) applies the restriction at the lowest level, so it holds even if a specific screen or endpoint forgets to check permissions explicitly.