Chapter 17 · Security, Privacy, Governance, and Auditability

Least Privilege Starts with the Data Model

Design least-privilege access from the data model upward, using ownership boundaries, roles, views, row-level controls, and narrowly scoped database permissions.

Beginner70–100 minutesLeast privilege + access designLast reviewed: August 2026

Learning outcomes

Security starts before permissions are granted. A database model defines ownership boundaries, identities, and relationships that make access-control rules either clear or fragile. Least privilege means every human, service, job, and integration receives only the permissions required for its purpose—and no broader capability by default.

01

Connect data ownership to database authorization.

02

Distinguish application roles from database roles.

03

Use views, stored operations, and row-level restrictions to narrow access.

04

Design WorkshopHub permissions around job responsibilities.

Least privilege as a modeling concern

If every table mixes public, operational, administrative, and sensitive fields, permissions become coarse. Separating data by responsibility can make privilege boundaries enforceable.

Example: Customer data

model · example
Customer(  customer_id,  display_name,  billing_email,  internal_risk_note,  tax_identifier)

A technician may need display_name but should not automatically receive tax_identifier or internal risk notes.

Split by sensitivity when useful

model · example
Customer(  customer_id,  display_name,  service_contact_email)CustomerBillingProfile(  customer_id,  tax_identifier,  billing_email,  billing_terms)

This is not mandatory in every design, but a separate table can create a clean authorization boundary.

Database roles

model · example
app_readapp_writereporting_readmigration_adminsupport_readonly

Use roles that correspond to capabilities rather than individual users when possible.

Application roles are not the same

The application may define:

model · example
techniciandispatcherbilling_managertenant_admin

while the database connection may use one service account. Authorization can exist in both layers, but the database should still limit the service account to what that service truly needs.

Avoid universal database credentials

A single credential with:

model · example
SELECT, INSERT, UPDATE, DELETEON ALL TABLES

for every service increases blast radius. Separate services should generally have separate credentials and grants.

Blast-radius rule

Compromise of one service should not automatically grant access to unrelated tables or administrative operations.

Views as permission boundaries

sql · example
CREATE VIEW technician_work_order_view ASSELECT work_order_id,       asset_id,       status_code,       problem_descriptionFROM work_order;

A role can receive SELECT on the view without direct access to every WorkOrder column.

Stored operations

Instead of granting broad table UPDATE, a service can be allowed to execute a narrow operation such as:

model · example
close_work_order(work_order_id, actor_id)

when the DBMS/security model supports safe encapsulation.

Column-level permissions

Some databases support column-specific grants. These can help with a few sensitive fields, though many fine-grained column grants become operationally hard to manage.

Row-level security

Row-level policies can restrict which rows a role sees:

model · example
tenant_id = current_tenant()

This is especially useful for multi-tenant systems, but policy correctness and connection context must be tested rigorously.

Read-only really means read-only

Reporting and support roles should not receive write privileges unless there is a specific operational requirement. Separate repair/admin tooling from ordinary diagnostic access.

Migration privileges

Schema migrations may require:

model · example
CREATEALTERDROPINDEXREFERENCES

The runtime application account usually should not have all of those privileges.

Ownership and DDL

Table ownership can bypass ordinary grants in some DBMSs. Use dedicated ownership roles carefully and avoid making routine application connections object owners.

Secrets are not ordinary columns

Database passwords, API keys, and encryption keys should not be stored as plaintext application data merely because “the database is secure.” Use secret-management systems and scoped credentials.

Service-to-table map

ServiceNeedsShould not need
DispatchWorkOrder, AssignmentBilling credentials
InventoryPart, inventory, PartUsageCustomer tax identifiers
BillingInvoices, billing profileDiagnostic raw payloads
ReportingApproved read viewsDDL or destructive writes

Permission review

Audit grants periodically. Privileges accumulate over time through debugging, incidents, and migrations. Remove obsolete grants instead of treating permissions as permanent.

Practice: technician access

Technician portal

Technicians need customer display name, asset details, assigned WorkOrders, and PartUsage. They must not see tax identifiers or internal billing notes. How should the model support this?

Review answer

Separate billing-sensitive data where practical, expose a technician-safe view/API projection, grant the technician-facing service only required tables/views, and test that direct access to billing structures is denied.

Summary and next lesson

Least privilege begins with clear ownership and separable data responsibilities. Database roles, scoped service accounts, views, row-level controls, and restricted migration credentials reduce blast radius. The next lesson focuses on the data itself: classification, minimization, encryption, and privacy-aware modeling.

References

  • NIST guidance on least privilege and access control.
  • OWASP guidance on database security and authorization.
  • DBMS documentation for roles, grants, views, and row-level security.

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only assets compatible with the Ethereum/ERC-20 network. Do not send TRC-20/TRON assets.