Two ways to read
- Service Layer for one document's details: an order with its lines, an invoice, a customer's record.
- Direct SQL for anything that aggregates: sales by month, debtor ageing, top items, stock value. One SELECT, at most 500 rows, read-only.
The model picks. You ask in plain words.
What keeps it read-only
- The database login we use is read-only (
db_datareader), created by your admin. It is never an administrative account. - Every statement is checked before it runs: one SELECT, nothing else. Anything else is refused before it reaches the server.
- Row and time limits apply. A query that takes too long is cut off with a sentence, not left running.
Where the SQL path is not used
Phone callers never trigger it: their questions are scoped and answered the fast way. It is a staff tool, and it only exists when your admin has configured the read-only connection.
When an answer looks wrong
Each answer shows the code that produced it, so a colleague can see which tables and dates were used. If the assumption is wrong (calendar year instead of financial year, say), teach it once and the next query uses the right basis. See Memory and teaching.