Access policies, row ownership, and public read: when to reach for each
Every table starts life answering "who may read this?" the same way: nobody but the admin. From there, three different tools widen that answer, and they are not interchangeable - each one is the right fit for a different shape of problem.
Public read: the same rows, for everyone
This is the simplest case. A blog's published posts, a shop's product catalogue, a restaurant's menu - anyone visiting the site should see the same set of rows, logged in or not. Public read turns that on for a whole table, optionally narrowed to only the rows that should actually be public (status = published, never a draft). There is no per-visitor difference here. Everyone gets the same answer, which is exactly why it is safe to leave wide open.
The trap is applying it to something that only looks like a catalogue. A table of bookings, enquiries or signups is not a catalogue just because it has rows worth listing - it has phone numbers and email addresses in it, and public read would hand every one of them to anyone who finds the link.
Row ownership: my own rows, and only mine
The next step up is personal data with no sharing involved. A customer's own orders, a member's own bookings, a user's own saved drafts. Here the right answer is different for every visitor, but it is always the same shape: "show me the rows where the owner column matches me." That is what a row-owner column is for - a plain UUID column holding the signed-in user's id, checked automatically on every read, write and delete.
This covers a huge fraction of "my account" features with nothing more exotic than one column and one setting. It falls over the moment the real rule is not "mine" but "mine, and also my manager's, and also my team's" - ownership has no concept of a second person being allowed in.
Access policies: rules that depend on a relationship
This is where roles, teams, workspaces and clients live. A finance admin can approve any expense in their own company, but not another company's. A manager can see their team's timesheets. A client can see their own invoices, but never a draft one. None of those are "is this my row" - they are "is there a row somewhere else that says I'm allowed to see this one", which usually means a memberships table: who belongs to which workspace, with what role.
An access policy is a condition, checked against that membership table, attached to a specific action on a specific table - select, insert, update or delete, each written separately. The moment a table gets even one policy, every action you did not explicitly cover gets refused, which is a feature: it is what stops a table quietly staying open on the one verb nobody thought to lock down.
The part worth designing carefully is anything that decides identity, money, or approval status. A policy should never merely check that a submitted role or status looks right - it should force the correct value on the server, regardless of what the request claims, so a self-registration form cannot make someone an approver just by including that field in the payload.
Picking one
A good short version: reach for public read when everyone sees the same thing, row ownership when everyone sees only their own and nothing more, and access policies the moment "their own" needs a second table to define - a team, a client, a role. Building the second problem with the first tool is the most common way a small app's access control quietly breaks once it has more than one kind of user.

Comments
Loading comments…