SQL & Data Management

Chapter 13
Data Security, Governance, Privacy, and Ethics

Bachelors Program in Business Analytics
SQL & Data Management   •   Bachelor

Data Security, Governance, Privacy, and Ethics

Introduction and Context

Modern organizations depend on data to forecast demand, evaluate customers, optimize operations, detect fraud, and support strategic decisions. The same data can create substantial harm when it is disclosed improperly, altered without authorization, retained unnecessarily, or used in ways that people did not reasonably expect. SQL and database management therefore involve more than storing and retrieving accurate records. They also require controls that preserve confidentiality, integrity, availability, accountability, privacy, and ethical legitimacy.

Data security concerns protection against unauthorized access, alteration, destruction, or disruption. Data governance establishes decision rights, policies, standards, and accountabilities for managing data as an organizational asset. Privacy concerns the appropriate collection, use, disclosure, and retention of information relating to identifiable or reasonably identifiable people. Ethics addresses whether data practices are fair, responsible, transparent, and respectful, even when a particular practice is technically legal.

These areas overlap but are not identical. A database may be secure against external intrusion while still being used unfairly. Conversely, a company may have a well-intentioned privacy policy but fail to protect its database through weak authentication. Responsible data management requires all dimensions to operate together.

Learning Objectives

By the end of this chapter, students should be able to:

  1. Distinguish authentication, authorization, auditing, encryption, masking, and related security controls.
  2. Apply least privilege and role-based access control to SQL environments.
  3. Explain data ownership, stewardship, classification, retention, and governance structures.
  4. Interpret major privacy principles and recognize common regulatory obligations.
  5. Evaluate ethical risks involving bias, surveillance, consent, secondary use, and automated decisions.
  6. Design a practical control framework for a business database.
  7. Analyze a data-security and privacy problem and recommend proportionate solutions.

1. A Security and Governance Model

A useful starting point is the security triad:

  • Confidentiality: data is accessible only to authorized people and systems.
  • Integrity: data remains accurate, complete, consistent, and protected from unauthorized modification.
  • Availability: authorized users can access data and services when required.

Security controls can also be classified by purpose:

Control typeMain purposeExamples
PreventiveStop an unwanted eventAccess control, encryption, constraints
DetectiveIdentify an event or violationAudit logs, intrusion alerts
CorrectiveRestore or reduce harmBackup restoration, account suspension
DeterrentDiscourage misconductMonitoring notices, disciplinary policies
CompensatingProvide alternative protectionManual review when a technical control is unavailable

Security is not achieved by a single product. It is a system of policies, people, processes, technologies, and evidence. For example, encryption can protect a stolen database file, but it does not prevent an authorized employee from exporting sensitive records. A permission model may restrict access, but it does not guarantee that the permitted user will use data ethically.

2. Authentication and Authorization

Authentication verifies identity: who or what is attempting access? Common methods include passwords, hardware tokens, authenticator applications, certificates, and biometrics. Multi-factor authentication combines two or more independent factors, such as something a user knows, possesses, or is. A password and a second code generated on a trusted device are stronger than a password alone.

Passwords should not be stored in plaintext. Systems normally store a salted, computationally expensive password hash. A salt is a random value stored with the password record and used to make identical passwords produce different hashes. Password hashing is different from encryption: encryption is designed to be reversible with a key, whereas password hashing is intended to be one-way.

Authorization determines what an authenticated identity may do. Typical database privileges include SELECT, INSERT, UPDATE, DELETE, and execution of stored procedures. Authorization should follow the principle of least privilege: each user or service receives only the access required for legitimate duties, for only as long as necessary.

Role-based access control (RBAC) assigns permissions to roles rather than directly to individual users. For example:

CREATE ROLE sales_analyst;
GRANT SELECT ON sales_summary TO sales_analyst;
GRANT sales_analyst TO analyst_27;

The exact syntax differs among database systems. The design principle is general: permissions are attached to a business role, and users receive roles according to job responsibilities. Separation of duties is a related principle. A person who creates a supplier should not necessarily be the same person who approves payment to that supplier.

Access should be reviewed periodically. Important practices include automatic removal of access when employment ends, time-limited privileged access, approval for elevated permissions, service-account inventory, and testing for privilege escalation. Shared accounts weaken accountability and should generally be avoided.

3. Encryption, Masking, and Tokenization

Encryption at rest protects stored data, including database files, backups, and removable media. Encryption in transit protects data moving between clients, application servers, databases, and external services. Transport Layer Security (TLS) is commonly used for network communication. Encryption depends on key management: keys must be generated, stored, rotated, backed up, and revoked appropriately.

Encryption does not eliminate all risks. If an attacker obtains both encrypted data and the decryption key, confidentiality may be lost. Keys should therefore be separated from ordinary data, access to them should be restricted, and key-use events should be logged.

Data masking changes the visible representation of data while preserving enough structure for a particular purpose. A customer-service representative may see XXXX-XXXX-XXXX-4821 rather than a full payment-card number. Static masking creates a sanitized copy, often for development or testing. Dynamic masking changes what a user sees at query time according to permissions.

Tokenization replaces a sensitive value with a token. The original value is held in a protected mapping system. Tokenization is useful when business processes need a consistent reference but do not need the original value. Masking, tokenization, anonymization, and pseudonymization are not interchangeable. Proper anonymization aims to remove the possibility of reasonably identifying a person; pseudonymized data may still be linked to a person using additional information.

A secure design should minimize the need to expose sensitive values. For example, an analytics team may need customer age bands and regional sales but not names, addresses, or full payment details.

4. Auditing, Monitoring, and Incident Response

Auditing creates evidence about what happened, who performed an action, when it occurred, and, where relevant, what object or record was affected. Database audit logs may capture successful and failed logins, privilege changes, access to sensitive tables, data exports, schema changes, and administrative actions.

Audit logs should be protected against unauthorized alteration, synchronized to a reliable time source, retained according to policy, and reviewed intelligently. Logging everything without analysis can produce large volumes of noise. High-value monitoring focuses on events such as a user accessing thousands of customer records, an unusual export, repeated failed authentication, or a change to a payroll table outside normal working hours.

An incident-response process commonly includes:

  1. Preparation and assignment of responsibilities.
  2. Detection and initial analysis.
  3. Containment of the threat.
  4. Eradication of the underlying cause.
  5. Recovery and service validation.
  6. Notification where legally or contractually required.
  7. Post-incident learning and control improvement.

The objective is not merely to identify a perpetrator. It is to limit harm, preserve evidence, restore trustworthy operations, and prevent recurrence.

5. Data Governance and Accountability

Data governance is the organizational system through which data-related decisions are made and enforced. It answers questions such as: Who may define a customer? Which value is the authoritative revenue figure? How long should records be retained? Who approves access? What quality standard must a dataset meet?

Important governance roles include:

  • Data owner: accountable for a data domain, its business purpose, risk decisions, and access policy.
  • Data steward: manages definitions, quality rules, metadata, issue resolution, and operational adherence.
  • Data custodian: operates technical infrastructure and implements security and availability controls.
  • Data subject: the person to whom personal data relates.
  • Governance committee or council: resolves cross-functional priorities and establishes standards.

Ownership does not mean that an individual personally owns every record. It means that a role has accountability for decisions. Stewardship is usually a hands-on coordinating function.

A governance program should include a data inventory, classification scheme, business glossary, metadata catalogue, quality rules, access procedures, retention schedule, issue-management process, and periodic control review. Data lineage is especially important in analytics: it records how data moves from source systems through transformations to reports or models. Without lineage, managers may not know which source produced a metric or which transformation introduced an error.

Data Classification

Classification labels should reflect sensitivity and consequence. A four-level example is:

ClassificationTypical examplesTypical controls
PublicPublished annual reportIntegrity checks and approval
InternalRoutine operating proceduresAuthenticated employee access
ConfidentialPricing plans, employee recordsLeast privilege, encryption, monitoring
RestrictedHealth, payment, or identity dataStrong authentication, masking, strict logging, limited retention

Classification is meaningful only when labels lead to different controls. Over-classification can obstruct legitimate work; under-classification can expose people and the organization to serious harm.

6. Privacy Principles and Regulatory Thinking

Privacy regulation differs across jurisdictions and sectors, but several principles recur:

  • Lawfulness, fairness, and transparency: processing should have a valid basis, should not be deceptive or unfair, and should be explained clearly.
  • Purpose limitation: collect and use information for specified, legitimate purposes.
  • Data minimization: collect no more personal data than is reasonably needed.
  • Accuracy: keep personal information correct and enable correction.
  • Storage limitation: retain information only as long as justified.
  • Security and confidentiality: protect data with appropriate technical and organizational measures.
  • Accountability: be able to demonstrate compliance rather than merely claim it.

Legal requirements may include notice, consent in particular circumstances, rights of access and correction, deletion or restriction rights, portability, breach notification, records of processing, impact assessments, and controls over international transfers. The exact requirement depends on the applicable law, the organization, the type of data, and the role of the organization in processing it.

Consent is not a universal solution. It should be informed, specific, freely given where required, and capable of withdrawal. An organization should not collect excessive information simply because a user clicked a long and confusing agreement. Other lawful bases may exist, such as contractual necessity or a legal obligation, but organizations must not select a basis merely because it is convenient.

Privacy by design integrates privacy into architecture and processes from the beginning. Privacy by default means that the default configuration should expose the minimum information necessary. A privacy impact assessment can identify affected people, purposes, data flows, risks, mitigations, and residual risk before a system is deployed.

7. Retention, Deletion, and Backup

Retention policies specify how long categories of data should be kept and what happens at the end of the period. Retention is influenced by operational needs, legal obligations, contractual requirements, litigation holds, historical value, and risk. Keeping data indefinitely is not automatically safer. Old data increases the consequences of a breach and can preserve inaccurate or harmful information.

A retention schedule should define the record category, owner, retention trigger, retention period, disposal method, and exceptions. Secure disposal may involve cryptographic erasure, verified deletion, physical destruction, or irreversible de-identification. Deleting a live record does not necessarily remove every copy; backups, replicas, exports, and test environments must also be considered.

Deletion may be suspended by a legal hold. A legal hold preserves relevant information when litigation or investigation is reasonably anticipated. Retention and backup policies should be coordinated so that restoration does not routinely reintroduce data that was properly deleted.

8. Ethics of Data Use and Analytics

Ethical data management asks not only whether an action is permitted, but whether it is justified. Key ethical concerns include:

  • Fairness and discrimination: historical data may reflect unequal treatment and produce discriminatory outcomes.
  • Privacy and surveillance: technically possible monitoring may be disproportionate or unexpected.
  • Transparency and explainability: affected people may need understandable reasons for important decisions.
  • Autonomy: manipulative personalization can undermine meaningful choice.
  • Accountability: responsibility must remain with identifiable people and institutions, not be shifted entirely to an algorithm.
  • Beneficence and non-maleficence: data use should seek benefit and avoid foreseeable harm.
  • Contextual integrity: information shared in one context should not automatically be used in another.

A model can be statistically accurate overall while producing systematically worse outcomes for a particular group. Analysts should examine data quality, representation, outcome definitions, error rates, and impacts across relevant groups. Fairness metrics do not have one universally correct definition; improving one metric can worsen another, especially when base rates differ. Consequently, fairness assessment requires domain judgment, stakeholder engagement, and governance rather than a single numerical test.

Ethical review should occur throughout the data lifecycle. Questions include: Was collection reasonable? Were people informed? Is the proposed use compatible with the original context? Could the output cause exclusion or stigma? Can a person challenge an important decision? Are vulnerable groups affected disproportionately?

9. A Practical Control Framework

A practical program can be organized into five connected stages:

  1. Discover: inventory data assets, owners, flows, users, vendors, and risks.
  2. Classify: label sensitivity, criticality, personal-data status, and regulatory relevance.
  3. Protect: implement authentication, authorization, encryption, masking, secure development, backups, and resilience.
  4. Monitor: audit access, test controls, review quality, detect anomalies, and investigate incidents.
  5. Improve: conduct assessments, remediate weaknesses, update policies, train staff, and learn from events.

A control should have an owner, a defined objective, an implementation method, evidence of operation, and a review frequency. Frameworks such as the NIST Cybersecurity Framework, ISO/IEC 27001, COBIT, and privacy-management standards can structure governance, but adopting a framework does not by itself guarantee compliance or ethical performance. The organization must adapt controls to its risk, size, sector, technology, and legal environment.

10. Worked Application: Retail Loyalty Database

Consider an illustrative retailer, Northstar Market, which stores customer names, contact details, purchase histories, loyalty points, demographic attributes, and marketing preferences. The company wants to give analysts access to the data to improve promotions.

Background and Problem

The operational database contains detailed personal information. Several analysts use copied spreadsheets, former employees still appear in access lists, and the marketing department wants to combine purchase history with third-party demographic data. Customers were told that their information would support loyalty services and relevant offers, but the original notice did not clearly explain all proposed uses.

Analysis

The risks include excessive access, uncontrolled copies, weak retention, unclear purpose compatibility, re-identification, and discriminatory targeting. The problem is therefore not only a database-permission problem. It involves governance, privacy, security, data quality, and ethics.

Approach and Solution

Northstar assigns a data owner for customer information and stewards for loyalty and marketing domains. A data inventory and classification exercise labels contact details and purchase histories as confidential personal data. Analysts receive access through an RBAC role to a curated analytical view rather than base tables:

CREATE VIEW analyst_customer_metrics AS
SELECT
    customer_id,
    region,
    purchase_month,
    total_spend,
    loyalty_tier
FROM customer_purchase_summary;

GRANT SELECT ON analyst_customer_metrics TO marketing_analyst;

The view excludes names, precise addresses, payment details, and unnecessary transaction-level fields. Direct identifiers are replaced with controlled pseudonymous identifiers where linkage is genuinely needed. Access is protected with multi-factor authentication and reviewed quarterly. Production data is encrypted at rest and in transit. Development environments receive masked or synthetic data.

The organization establishes a retention schedule, prohibits unapproved exports, records access to restricted tables, and creates an incident-response procedure. Before using third-party demographic data, it conducts a privacy and ethics assessment covering lawful basis, notice, data quality, compatibility of purposes, bias, and the ability of customers to exercise applicable rights. Marketing campaigns are tested for disparate effects and include an understandable preference-management process.

Outcome

The solution reduces exposure while preserving the analytical purpose. It also produces clearer accountability: the owner approves purpose and risk decisions, stewards maintain definitions and quality, custodians implement technical controls, and analysts use approved data products. The retailer cannot claim that risk has disappeared, but it can demonstrate proportionate controls and a process for identifying residual risk.

Learning Points

  1. A business question should determine the minimum data needed.
  2. Views and curated data products can reduce direct exposure.
  3. Security and privacy controls must include copies, backups, vendors, and development environments.
  4. Governance assigns accountability; technology implements controls.
  5. Ethical review is necessary even when a proposed use appears technically feasible or legally arguable.

Challenges and Limitations

Security controls create cost and friction. Excessively restrictive access may delay legitimate analysis and encourage workarounds. Excessive logging can create another sensitive dataset. Masking may reduce analytical usefulness, while anonymization can be difficult when multiple datasets are combined. Deletion can conflict with legal holds, accounting requirements, fraud investigations, or backup architecture.

Governance also faces organizational challenges. Owners may disagree about definitions, business units may resist centralized standards, and responsibility may be unclear across cloud providers and contractors. A framework can become a compliance exercise if evidence is collected without meaningful risk reduction. Finally, privacy and fairness judgments often involve uncertainty. Organizations should document assumptions, consult affected stakeholders, test alternatives, and revisit decisions as context changes.

Contemporary Developments

Cloud databases, data lakes, application programming interfaces, mobile devices, and generative artificial intelligence expand both analytical capability and attack surface. Organizations should evaluate where data is processed, who can access prompts and outputs, whether providers retain submitted information, and whether generated outputs reproduce confidential or biased content.

Privacy-enhancing technologies include federated learning, differential privacy, secure multiparty computation, trusted execution environments, and synthetic data. These methods can reduce exposure but are not magic solutions. Each has assumptions, implementation costs, and possible failure modes. For example, synthetic data may still leak characteristics of its source if generated poorly, and removing identifiers does not automatically prevent re-identification.

Effective professionals therefore combine SQL competence with risk reasoning. They understand permissions, data flows, metadata, controls, and organizational accountability, while also recognizing that responsible data use requires human judgment.

Best-Practice Checklist

Before approving a database or analytics use, ask:

  • What purpose is being served, and is it clearly defined?
  • What is the minimum data required?
  • How is identity authenticated and access authorized?
  • Are sensitive data and backups encrypted?
  • Are views, masking, or tokenization appropriate?
  • Who owns the data and who stewards its quality?
  • What evidence will auditing produce?
  • How long will the data be retained, and how will it be disposed of?
  • Have privacy, fairness, security, and third-party risks been assessed?
  • Can affected people understand, challenge, or correct important outcomes?
  • What happens if the system fails or data is breached?

Chapter Summary

Responsible SQL and data management integrates security, governance, privacy, and ethics. Authentication establishes identity, while authorization controls permitted actions. Least privilege, RBAC, separation of duties, encryption, masking, tokenization, auditing, and incident response provide complementary protection. Governance assigns ownership and stewardship, defines standards, maintains metadata and lineage, and establishes accountability. Privacy principles emphasize purpose limitation, minimization, accuracy, retention limits, transparency, security, and demonstrable accountability. Ethical practice extends beyond legal compliance to questions of fairness, autonomy, proportionality, contextual integrity, and human responsibility. Effective controls are risk-based, evidence-producing, regularly reviewed, and designed around the minimum data necessary for a legitimate purpose.

Key Terms

Authentication: Verification of a user or system identity.

Authorization: Determination of what an authenticated identity may access or do.

Least privilege: Granting only the access necessary for an approved task.

Role-based access control: Assigning permissions to roles and assigning users to those roles.

Separation of duties: Dividing sensitive responsibilities among different people or roles.

Encryption: Transformation of data into a protected form using a key.

Encryption at rest: Protection of stored data.

Encryption in transit: Protection of data moving across a network.

Data masking: Hiding or transforming sensitive values for controlled use.

Tokenization: Replacing a sensitive value with a protected substitute token.

Audit log: A record of security-relevant events and actions.

Data governance: Policies, decision rights, roles, and processes for managing data.

Data owner: Role accountable for a data domain and its major decisions.

Data steward: Role responsible for operational definitions, quality, metadata, and issue resolution.

Data minimization: Collecting and using no more personal data than necessary.

Purpose limitation: Restricting data use to specified and legitimate purposes.

Pseudonymization: Replacing direct identifiers while retaining a possible link through additional information.

Anonymization: Processing intended to prevent reasonable identification of individuals.

Privacy by design: Building privacy considerations into systems and processes from the outset.

Data lineage: Documentation of data origins, transformations, and destinations.

Review Questions

Short Answer Questions

  1. How do authentication and authorization differ?
  2. What is the principle of least privilege?
  3. Distinguish encryption at rest from encryption in transit.
  4. What responsibilities typically belong to a data steward?
  5. Why is data minimization important for privacy and security?

Long Answer Questions

  1. Explain how RBAC, separation of duties, auditing, and encryption can operate together in a database environment.
  2. Discuss the principal stages of a data-governance program and the roles of owners, stewards, and custodians.
  3. Explain why legal compliance does not necessarily guarantee ethical data use.
  4. Analyze the advantages and limitations of masking, tokenization, pseudonymization, and anonymization.
  5. Describe how a privacy impact assessment could support the introduction of a new customer analytics system.

Analytical / Application Questions

  1. A company gives all analysts direct access to a customer table containing names, addresses, purchase histories, and payment information. Design a safer access model and justify each control.
  2. An algorithm used for employee screening rejects applicants from one demographic group at a substantially higher rate. Propose a structured investigation covering data, model performance, governance, and human review.
  3. A database administrator discovers that a former employee's account remains active and has accessed thousands of records. Explain the immediate response, evidence to preserve, notifications to consider, and long-term improvements required.

Multiple Choice Questions with Answers

Question 1

Which control verifies the identity of a person attempting to use a database?

A. Authentication

B. Authorization

C. Data masking

D. Retention scheduling

Correct Answer: A. Authentication

Question 2

Which principle grants a user only the permissions necessary for an approved task?

A. Purpose limitation

B. Least privilege

C. Data portability

D. Availability

Correct Answer: B. Least privilege

Question 3

What is the primary purpose of encryption in transit?

A. To define data ownership

B. To reduce storage duration

C. To protect data moving across a network

D. To remove all personal identifiers

Correct Answer: C. To protect data moving across a network

Question 4

Which role is primarily responsible for metadata, definitions, and operational data-quality issues?

A. Data subject

B. Data steward

C. External auditor

D. Network attacker

Correct Answer: B. Data steward

Question 5

Which privacy principle requires collecting no more personal data than is reasonably needed?

A. Data minimization

B. Availability

C. Separation of duties

D. Tokenization

Correct Answer: A. Data minimization

Question 6

Which statement best describes tokenization?

A. It permanently deletes a record from every backup

B. It replaces a sensitive value with a protected substitute

C. It grants every analyst access to raw data

D. It verifies a user's identity with two factors

Correct Answer: B. It replaces a sensitive value with a protected substitute

Question 7

Why should audit logs be protected from unauthorized alteration?

A. To preserve reliable evidence of events

B. To increase the number of database columns

C. To make passwords reversible

D. To eliminate the need for authorization

Correct Answer: A. To preserve reliable evidence of events

Question 8

Which practice best supports privacy by default?

A. Exposing all fields until users request restriction

B. Collecting optional information automatically

C. Configuring the system to expose the minimum necessary information

D. Retaining all records indefinitely

Correct Answer: C. Configuring the system to expose the minimum necessary information

Question 9

What is a central purpose of data lineage?

A. To document data origins and transformations

B. To replace multi-factor authentication

C. To guarantee that a model is unbiased

D. To encrypt every database column automatically

Correct Answer: A. To document data origins and transformations

Question 10

Which response sequence is most appropriate after detecting a serious database breach?

A. Delete all logs and immediately rebuild reports

B. Contain the threat, preserve evidence, investigate, recover, and improve controls

C. Publish all affected records to demonstrate transparency

D. Ignore the event unless a customer complains

Correct Answer: B. Contain the threat, preserve evidence, investigate, recover, and improve controls

SQL & Data Management
Chapter 13 of 15