| CPSC 343 |
Database Theory and Practice |
Fall 2026 |
CPSC 343 Review Information — Exam 4
Exam 4 is a written in-class (one hour) exam covering data
integrity, security, and privacy — authentication and
authorization concepts, transactions and concurrency control,
database-level access control, SQL injection and input validation,
auditing, and the ethics and privacy of personal data. Expect two
kinds of questions:
- short answer questions about concepts — definitions, what a
mechanism does and doesn't protect against, and when to use one
mechanism over another
- applying the concepts to a scenario, code, or data, as in the
homeworks and project — identifying the anomaly in an
interleaving of transactions and what prevents it, deciding where a
transaction or a locking read is needed, identifying and fixing
injectable or IDOR-vulnerable code, choosing privileges and views for
a database account,
identifying PII, and analyzing a privacy or ownership question about
a database design
Short answers should be short — generally 1-3 sentences, or
1-2 sentences per part for a question with several parts. A list
rather than complete sentences is fine where appropriate. Time is
limited, so don't write more than necessary!
The exam is about concepts rather than the Java implementation
— you won't need to read or write any of the application's
Java code (routes, services, DAOs, JDBC).
The topics covered on the exam are listed below. The items under
"Self check" are study goals — examples of the kinds of things
you should be able to do rather than actual exam questions or a
complete list of what the exam might ask. As a starting point for
studying, try to explain each topic without notes (including an
example of your own where appropriate) and then answer the
associated self check items. As a pacing guide, you should be able
to start writing answers for definition/recall questions right away
and "apply the concept" questions (name the anomaly in an
interleaving, spot an injection or IDOR vulnerability, label the PII
in a table) after a minute or two of thinking.
For practice applying the concepts, see the "Example question
types" and "Practice" sections at the end.
Authentication and Authorization
Topics:
- Authentication vs. authorization
- Application users vs. database accounts
- Storing credentials; salts
- Session-based authentication; login tokens
- Role-based vs. row-level authorization
- Insecure direct object references (IDOR)
- Avoiding information leakage
Self check:
- Distinguish authentication from authorization and give an
example of a failure of each.
- Explain the difference between an application user and a
database account, including who authenticates each and which
database account the application uses when it handles a request.
- Compare storing passwords directly, storing them encrypted, and
storing them hashed.
- Explain why a fast hash such as SHA-256 isn't adequate for
passwords. Explain what a salt does and whether it needs to be kept
secret.
- Explain why an API issues a token at login rather than having
the client send the password with every request and how this
relates to REST being stateless.
- Explain how session tokens are verified and revoked and the
drawback of storing sessions on the server.
- Explain when a role check is sufficient and when row-level
authorization is needed. Explain where the current user's id should
come from and why.
- Explain what an IDOR vulnerability is, give an example, and
describe how to fix it in the query.
- Give examples of how an API's responses can unintentionally
reveal which records or usernames exist and how to avoid it.
Transactions and ACID
Topics:
- Problems with multi-step operations
- Transactions; commit and rollback
- The ACID properties
- Transactions in MySQL: autocommit; START TRANSACTION,
COMMIT, ROLLBACK; failed
statements within a transaction
- Implementing durability
- When to use a transaction
Self check:
- Explain what a transaction is and what its two possible
outcomes are.
- Define each of the ACID properties and describe the kind of
failure each prevents. Given a scenario, identify which property is
violated.
- Explain what a valid state is and who is responsible for
ensuring consistency.
- Explain what autocommit means and what MySQL's default is.
- Explain what happens in MySQL when one statement inside a
transaction fails and what the application must do about it.
- Explain how the DBMS provides durability and how it recovers
after a crash.
- State the guideline for when a multi-step operation needs a
transaction and apply it to a described operation.
Concurrency Control
Topics:
- Schedules, serial execution, and serializability
- Anomalies: lost update, dirty read, non-repeatable read, phantom
read
- Isolation levels: READ UNCOMMITTED, READ COMMITTED,
REPEATABLE
READ, SERIALIZABLE — MySQL's behavior
- Locking reads: SELECT ... FOR SHARE and SELECT
... FOR UPDATE
- Deadlock
- Choosing an isolation level or locking read for a situation
Self check:
- Define schedule and serializable schedule and explain why
serializability is the correctness criterion.
- Explain why DBMSs interleave transactions instead of running
them one at a time and what weaker isolation levels give up in
exchange.
- Describe each of the four anomalies. Given an interleaving of
two transactions, identify which anomaly (if any) occurs.
- Identify the weakest isolation level that prevents a given
anomaly in MySQL.
- Describe how MySQL behaves at READ COMMITTED,
REPEATABLE READ, and SERIALIZABLE — in
particular, what a plain SELECT sees at each level and
whether lost updates are possible at REPEATABLE READ.
- Explain what protection an isolation level gives a sequence of
statements run with autocommit on.
- Distinguish FOR SHARE from FOR UPDATE and
explain which is the better choice for a read-then-write operation
and why.
- Compare using locking reads on the rows involved with using
SERIALIZABLE and explain when each is appropriate.
- Define deadlock, describe what the DBMS does when it detects
one and what the application must do, and describe ways to make
deadlocks less likely.
- Given a read-then-write operation,
identify the race condition and describe how to fix it, including
which rows to lock and which other operations must also use the
locking read.
Database-Level Access Control
Topics:
- Database accounts
- Categories and levels of privileges; the
SELECT, INSERT, UPDATE, and
DELETE privileges
- Least privilege
- Roles
- Views; views as a security mechanism
- Limits of database-level access control
Self check:
- Explain what a MySQL account consists of and what a newly
created account can do.
- Explain whether the
application's database privileges matter when the application does
its own authorization.
- Name the categories of privileges and give an example of each,
and explain what each of
the SELECT, INSERT, UPDATE,
and DELETE privileges allows.
- Describe the levels at which privileges can be granted and the
pitfalls of column-level privileges.
- Explain the principle of least privilege and apply it to
determine the privileges an account needs given what it is used
for.
- Explain what a role is and why roles are useful.
- Explain what a view is and what it stores.
- Explain how a view can be used to limit what an account can see
and whose privileges are used to read the view's base tables.
- Distinguish what privileges control from what views control.
- Explain whether a view can limit rows to those belonging to the
current application user and why or why not.
SQL Injection and Input Validation
Topics:
- SQL injection
- Placeholders (parameterized queries)
- Limitations of placeholders
- Input validation
- Allow-lists vs. block-lists
- Placeholders vs. input validation vs. database constraints
Self check:
- Explain why concatenating user input into a SQL string is
vulnerable. Given injectable code and an input, determine the SQL
that results and what it does.
- Explain how placeholders prevent injection.
- Explain what a placeholder can and can't stand for and describe
how to safely use user input to choose a column name or sort
direction.
- Explain what injection defenses don't protect against, with
examples.
- Describe what input validation should check, where it should be
done, and what the response to invalid input should tell the client.
- Distinguish allow-lists from block-lists and explain which is
preferred and why.
- Explain the role of input validation in the application when
database constraints check the same thing. Given a rule, decide whether it
should also be a database constraint (structural) or only checked
by the application (policy).
Auditing
Topics:
- Purposes of auditing
- Contents of an audit trail
- Ways to generate audit records
- Protecting audit data
Self check:
- Describe the purposes of auditing.
- Describe what an audit trail should always record about a
change, and the considerations in deciding which values to record
and how.
- Compare the ways of generating audit records, including which
of them know the application user.
- Explain how to protect an audit trail from being altered and
what other policy decisions audit data requires.
Security vs. Privacy
Topics:
- Data security vs. data privacy
- Why privacy matters
- Issues of scale
- Intended vs. unintended uses of data
Self check:
- Distinguish data security from data privacy and give an
example where security succeeds but privacy fails.
- Describe questions about personal data that security mechanisms
don't answer and design responses for misuse by an authorized
insider.
- Describe why privay matters, including the kinds of harm that
can result when personal data is misused.
- Describe the ways large data collections change the risks of
storing data, and give an example of a social or legal harm
resulting from each.
- Distinguish intended from unintended uses of stored data and
explain what consent to one use implies about other uses.
PII and De-identification
Topics:
- Personally identifiable information (PII); kinds of PII
- Protecting PII in a database
- Anonymous, pseudonymous, and de-identified data
- Re-identification
Self check:
- Define PII. Given a table, label each column as a direct
identifier, quasi-identifier, sensitive attribute, or none of these.
- Explain whether removing direct identifiers is enough to keep a
person from being identified, using the Weld example or one of your
own.
- Describe practices for protecting PII inside a database.
- Distinguish anonymous, pseudonymous, and de-identified data,
including what links between rows each preserves and the remaining
risk of identification.
- Explain how a pseudonym mapping table should be treated and how
the number of rows tied to the same pseudonym affects risk.
- Describe design choices that reduce re-identification risk when
exporting or reporting data.
Privacy Law and Reasonable Care
Topics:
- Privacy compliance by design
- Common obligations imposed by privacy laws
- GDPR, HIPAA, and FERPA
- Due care, due diligence, and negligence
Self check:
- Explain what privacy compliance by design means and why it
matters.
- Name the common kinds of obligations privacy laws impose and
describe what each means for the design of a database.
- For each of GDPR, HIPAA, and FERPA, describe what data it covers,
who it applies to, and one or two obligations it brings.
- Distinguish due care from due diligence with an example of each
and explain why documenting decisions matters.
- Given a schema and a privacy promise or obligation, identify how
the design falls short and describe options for fixing it, including
their costs.
Ownership, Stakeholders, and Professional Responsibility
Topics:
- Stakeholders and data ownership
- Stakeholder analysis and managing conflicts of interest
- Ethical lenses
- Custodianship across the data life cycle
- Professional codes of ethics
Self check:
- Explain who has a claim on the data an organization collects.
- For a described data set, identify the stakeholders, what each
gains and risks, and where their interests conflict.
- Describe the steps for managing a conflict of interest and give
an example of a design that eases a conflict.
- Describe the four ethical lenses and the questions to consider,
and apply them to a described decision.
- Describe the custodian's responsibilities at each stage of the
data life cycle, including what responsible destruction requires.
- Explain to whom professional codes of ethics apply and give
examples of responsibilities they describe that are relevant to
database professionals.
Example Question Types
Beyond the conceptual questions above, expect questions that ask
you to apply your knowledge to a given scenario, code, schema, or
data. For example:
- Given a described problem, determine whether it is a failure of
authentication, authorization, or privacy and what would have
prevented it.
- Given a query that retrieves or modifies a
row by id, determine whether it is vulnerable to IDOR and fix it.
- Given a failure scenario, identify which ACID property is
involved.
- Given a multi-step operation, determine whether
a transaction is needed and describe what can go wrong without one.
- Given an interleaving of two transactions, identify the
anomaly, whether it can occur in MySQL at a given isolation level,
and the weakest isolation level that prevents it.
- Given a read-then-write operation, identify the race condition
and fix it with a locking read.
- Given injectable code and an input, determine the SQL that runs
and its effect and rewrite the code so it isn't vulnerable.
- Given a list of input rules, decide how each should be checked
(allow-list validation in the application, a database constraint, or
both).
- Given a description of the database accounts and what each is
used for, determine the privileges each needs and write views that
limit the columns or rows an account can see.
- Given a table, identify the direct identifiers,
quasi-identifiers, and sensitive attributes; explain how someone
could still be identified after direct identifiers are removed;
and propose a safer export.
- Given a data scenario, identify the stakeholders and conflicts of
interest and propose a design that eases a conflict.
Practice
- Work through the homework problems and any example problems
from class (in the slides), including any you didn't complete the
first time.
- For each anomaly, make up your own interleaving using a
different example (e.g. the photo album), then decide which
isolation levels prevent it in MySQL. Try
it with two MySQL sessions to check your answer.
- Review your project's service code: which operations need
transactions, which read-then-write paths need locking reads,
whether any query could be vulnerable to injection or IDOR, and what
input validation is missing.
- For your project's database, decide what privileges the API's
account needs, label the PII in each table, decide what changes
should be audited, and consider how long each kind of data should
be kept.