Database Security, Privacy, Ethics and GovernanceIntroductionDatabases are strategic assets because they store the information on which organisations make operational, financial and analytical decisions. A security failure can expose personal information, disrupt services, enable fraud, damage reputation and create regulatory liability. Database management therefore extends beyond storage, indexing and query processing. It also requires controls that preserve confidentiality, integrity, availability, privacy, accountability and responsible use. Database security concerns protection against unauthorised access, alteration, disclosure and destruction. Privacy concerns the justified collection and use of information about identifiable people. Ethics concerns whether data practices are fair, transparent and socially responsible, even when they are technically legal. Governance establishes decision rights, policies, standards and accountability so that data remains trustworthy throughout its life cycle. These concerns are closely connected but not identical. Encryption may protect confidential data without making its collection legitimate. A user may be authorised to access a table but still misuse the information. A database may be secure from attackers but contain inaccurate or biased data. Effective governance addresses all these dimensions together. Learning ObjectivesBy the end of this chapter, students should be able to: 1. Explain database security, privacy, ethics and governance as related but distinct disciplines. 2. Apply authentication, authorisation, roles, least privilege and separation of duties. 3. Select suitable encryption, masking, auditing and backup controls. 4. Explain common injection attacks and design preventive measures. 5. Analyse privacy, retention, data lineage, quality and stewardship requirements. 6. Relate database practices to regulatory compliance and responsible data use. 7. Design a practical governance approach for an organisational database. 1. The Security and Governance LandscapeThe traditional security objectives are confidentiality, integrity and availability, often called the CIA triad. Confidentiality means that information is disclosed only to permitted parties. Integrity means that information and database operations remain accurate, complete and protected from unauthorised modification. Availability means that authorised users can access systems and data when needed. Modern data management adds several objectives: - Accountability: actions can be attributed to responsible identities.
- Authenticity: users, systems and data sources are genuine.
- Non-repudiation: evidence exists to prevent a participant from credibly denying a recorded action, although absolute non-repudiation is difficult in ordinary database systems.
- Privacy: personal data is handled according to justified purposes, user expectations and applicable law.
- Resilience: the organisation can recover from failure, attack or corruption.
A useful distinction is between a threat, a vulnerability, a control and a risk. A threat is a potentially harmful event, such as credential theft. A vulnerability is a weakness that the threat can exploit, such as an exposed password or excessive privilege. A control reduces the likelihood or impact of the event. Risk is the possibility of loss arising from a threat exploiting a vulnerability. In practice, risk is assessed qualitatively or quantitatively, but no single formula captures every organisational context. Database security operates in layers. These include physical facilities, operating systems, networks, database management systems, applications, identities, data and organisational processes. A firewall cannot compensate for a vulnerable application, and a strong password cannot correct inaccurate permissions. This is the principle of defence in depth. 2. Identity, Authentication and AuthorisationAuthenticationAuthentication verifies an identity. Common factors are: - Something the user knows, such as a password.
- Something the user has, such as a hardware token or authenticator application.
- Something the user is, such as a fingerprint.
Multi-factor authentication combines factors from different categories. Using a password and a one-time code is generally stronger than using two passwords. Passwords should be stored as salted, slow, one-way password hashes rather than reversible encryption or plaintext. Salting ensures that identical passwords do not produce identical stored values and reduces the value of precomputed attack tables. Service accounts and application identities require special treatment. They should have narrowly defined permissions, managed credentials, rotation procedures and monitoring. Shared accounts weaken accountability because actions cannot reliably be assigned to individuals. AuthorisationAuthorisation determines what an authenticated identity may do. Permissions commonly include SELECT, INSERT, UPDATE, DELETE, EXECUTE and administrative privileges. Authorisation should be based on least privilege: grant only the access necessary for a legitimate task, for only as long as it is needed. Role-based access control (RBAC) assigns permissions to roles and roles to users. For example, a hospital database might define Receptionist, Clinician, BillingOfficer and DatabaseAdministrator roles. RBAC reduces administrative complexity and supports review. Attribute-based access control (ABAC) evaluates attributes such as department, purpose, location, data sensitivity and time. ABAC is more expressive but generally more complex to design and test. Separation of duties prevents one person from completing a high-risk process alone. For example, one employee may create a supplier and another may approve payment. Privileged access management adds controls such as approval, time-limited elevation, session recording and emergency-access review. Authorisation should be enforced at multiple levels. Database views can expose only selected columns or rows. Row-level security can restrict records according to user context. Stored procedures can centralise sensitive operations. Application checks remain important, but relying exclusively on application checks is unsafe because administrators, alternate applications or direct connections may bypass them. Example: Access policyA university database contains student records. Academic advisers may view students assigned to their programme but should not view bank details. Finance officers may view billing data but not counselling notes. A robust design might combine role permissions, views that omit sensitive columns, row-level policies based on programme assignment, and audit records for exceptional access. 3. Encryption, Masking and Data ProtectionEncryption transforms readable plaintext into ciphertext using a cryptographic key. Decryption reverses the transformation for an authorised party. Encryption is valuable both in transit and at rest. - Encryption in transit protects connections between clients, applications and database servers, commonly through TLS.
- Encryption at rest protects database files, backups and storage media if they are obtained by an unauthorised party.
- Column or field encryption protects especially sensitive attributes, such as identity numbers, although it can restrict searching, indexing and analytics.
Encryption is not equivalent to access control. A database service that can decrypt every field may still disclose data to an attacker who compromises that service. Key management is therefore central. Keys should be generated securely, stored separately from protected data where practical, rotated according to policy, access-controlled, backed up safely and retired when no longer required. Hardware security modules or cloud key-management services can support these functions. Tokenisation replaces a sensitive value with a surrogate token. The mapping is stored separately in a protected vault. Tokenisation is useful for payment workflows because many applications can operate on tokens without handling the original number. Masking hides part of a value, such as displaying only the last four digits of an account number. Dynamic masking changes what a user sees at query time; static masking creates a transformed copy, often for development or testing. Masking is not always anonymisation. If a person can be identified by combining masked data with other information, privacy risk remains. Anonymisation aims to make re-identification reasonably unlikely under a defined threat model, while pseudonymisation replaces identifiers but preserves the possibility of re-linking under controlled conditions. 4. Auditing, Monitoring and Incident ResponseAn audit trail records relevant events such as successful and failed logins, privilege changes, data exports, administrative actions and access to sensitive records. A useful audit record identifies the actor, time, action, object, outcome and, where appropriate, originating system. Audit logs must themselves be protected. Users should not be able to erase their own evidence. Controls may include append-only storage, restricted write and read permissions, time synchronisation, integrity checks, central collection and retention rules. Excessive logging can create privacy and storage problems, while insufficient logging prevents investigation. Monitoring turns records into action. Alerts may identify repeated failed logins, unusual export volume, access outside normal duties or privilege escalation. Detection rules should be tested because simplistic thresholds generate false positives and alert fatigue. An incident-response process generally includes preparation, detection and analysis, containment, eradication, recovery and lessons learned. Database-specific preparation includes tested backups, inventories of sensitive data, emergency contacts, forensic logging and documented recovery procedures. Recovery should restore not only availability but also integrity; a compromised database must not simply be brought online without validation. 5. Injection Prevention and Secure Database DevelopmentInjection occurs when untrusted input changes the meaning of a command. SQL injection is a major example. Consider an unsafe construction: ```text query = "SELECT * FROM users WHERE name = '" + input + "'"; ``` If input contains quotation marks and SQL syntax, the resulting command may retrieve or alter unintended data. The principal defence is a parameterised query, in which SQL structure is compiled separately from values: ```text SELECT * FROM users WHERE name = ?; ``` The application then binds the input as a value. Prepared statements should be the default. Stored procedures can help when they themselves use parameters and avoid unsafe dynamic SQL. Input validation should enforce expected type, length and format, but validation is a supplementary defence rather than a substitute for parameterisation. Other practices include using separate database accounts for applications, granting only required permissions, escaping output where relevant, avoiding detailed error messages in production, keeping database software patched and testing for injection using code review and security testing. Object names such as table or column names cannot normally be bound as ordinary parameters; if dynamic identifiers are required, use a strict allow-list rather than accepting arbitrary input. 6. Privacy and the Data Life CyclePrivacy begins before data enters a database. Organisations should identify a legitimate purpose, collect only necessary data, communicate practices clearly and avoid retaining information indefinitely. A life-cycle approach includes collection, classification, storage, use, sharing, archival and disposal. Important privacy principles include: - Purpose limitation: use data for specified and legitimate purposes.
- Data minimisation: collect and process no more than necessary.
- Accuracy: provide mechanisms to correct significant errors.
- Storage limitation: retain data only as long as justified.
- Transparency: explain collection and use in understandable language.
- Individual rights: depending on jurisdiction, these may include access, correction, deletion, portability or objection.
- Security and confidentiality: protect data using appropriate controls.
Privacy impact assessments are useful when processing is likely to create substantial risk, such as biometric identification, large-scale profiling or combining datasets. They document the purpose, data flows, risks, affected individuals, safeguards and residual risk. Retention schedules should specify categories, retention periods, legal holds and disposal methods. Retention is not simply a technical deletion command: replicas, backups, exports, caches and audit records may also contain the data. Secure disposal may involve cryptographic erasure, controlled media destruction or verified deletion from systems where deletion is technically supported. Privacy-preserving analytics may use aggregation, suppression, perturbation, differential privacy or secure computation. Each involves trade-offs. Aggregation can still disclose small groups; perturbation can reduce analytical accuracy; differential privacy provides a formal privacy guarantee under defined assumptions but requires careful management of its privacy budget and query mechanisms. 7. Ethics and Responsible Data UseLegal compliance is a minimum requirement, not a complete ethical standard. Ethical data practice asks whether people are treated fairly, whether they understand important uses, whether harms are distributed unequally and whether an organisation would defend its practice publicly. Key ethical concerns include: - Fairness and discrimination: historical data may encode unequal treatment, and apparently neutral variables may act as proxies for protected characteristics.
- Consent and autonomy: consent should be informed, specific where appropriate and not obtained through deceptive interfaces.
- Power imbalance: individuals may have little practical ability to refuse data collection by employers, schools or essential services.
- Secondary use: data collected for one purpose may later be reused in ways that people did not reasonably expect.
- Surveillance: extensive tracking can chill behaviour and undermine dignity.
- Accuracy and contestability: people should have ways to challenge consequential records or automated decisions.
In AI and machine learning, database governance affects training-data quality, representativeness, provenance and evaluation. A model may be technically accurate yet harmful if its training data excludes a population or if predictions are used beyond the context in which they were validated. Data documentation, dataset versioning, bias assessment and human oversight are therefore governance activities, not optional paperwork. 8. Data Quality, Lineage and StewardshipData quality is multidimensional. Common dimensions are accuracy, completeness, consistency, timeliness, validity, uniqueness and fitness for purpose. Quality rules should be operationalised. Examples include a non-null identifier, a date within an allowed range, a foreign key referencing an existing entity and a unique student number. Data lineage describes where data originated, how it was transformed and where it is consumed. It supports impact analysis, regulatory responses, debugging and trust in analytics. Lineage may be captured from source systems through extraction, transformation, data warehouses, dashboards and machine-learning features. A data owner is accountable for decisions about a data domain, such as access and retention. A data steward manages definitions, quality rules, metadata and day-to-day coordination. A custodian operates technical infrastructure and implements controls. These roles may be held by different people; confusing them creates gaps in accountability. A data catalogue can record definitions, classifications, owners, lineage, quality indicators and permitted uses. A business glossary distinguishes terms that otherwise cause inconsistent reporting. For example, “active customer” must have a documented definition rather than being independently interpreted by each department. 9. Governance Frameworks and ComplianceData governance is the system of authority, policies, processes, standards and measures through which an organisation manages data. It answers questions such as: Who may approve access? Who owns a dataset? Which quality level is required? How are conflicts resolved? What evidence demonstrates compliance? A practical governance framework commonly includes: 1. Principles and policy: define acceptable use, classification, privacy, security and retention. 2. Decision rights: assign owners, stewards, custodians and escalation paths. 3. Standards: specify naming, metadata, access review, encryption, logging and quality requirements. 4. Processes: implement onboarding, access requests, incident response, data sharing, change control and disposal. 5. Measurement: track findings, remediation, quality, access reviews, incidents and training. 6. Assurance: conduct internal audits, independent reviews and continual improvement. Frameworks such as ISO/IEC 27001, the NIST Cybersecurity Framework and COBIT provide structured approaches to security and governance. Privacy laws differ by jurisdiction. The European Union General Data Protection Regulation, for example, establishes principles and rights concerning personal data and imposes obligations that may apply to organisations outside the EU in specified circumstances. Sectoral regimes such as health or payment regulations impose additional requirements. Organisations must consult applicable legal and regulatory professionals; a framework is not a substitute for legal advice. Compliance evidence should be designed into operations. Examples include access approval records, training logs, encryption configuration, retention schedules, incident reports, data-processing inventories, vendor assessments and audit results. “Compliant” is not a permanent technical state; it requires ongoing review as systems, threats, purposes and laws change. 10. Illustrative Case: University Health and Student Support PlatformBackgroundA university integrates admissions, learning, payment and counselling systems to provide early support to students. The platform combines academic performance, attendance, financial status and wellbeing information. ProblemA data analyst requests broad access to build a machine-learning model predicting withdrawal risk. A development database is copied from production without masking. Several staff members use shared accounts, and the organisation has no documented retention period for exported reports. The proposed model could expose sensitive characteristics and influence staff decisions unfairly. AnalysisThe project involves high-sensitivity personal data, secondary use, access control, data minimisation, model fairness and retention risks. A broad extract violates least privilege and increases the impact of a breach. Shared accounts undermine accountability. Unmasked development data creates unnecessary exposure. A prediction used without explanation may stigmatise students or direct support unevenly. Approach and solutionThe university establishes a governance review led by the data owners, privacy officer, security team, student-support representatives and machine-learning specialists. The team: - defines the legitimate purpose and limits the model to early support rather than disciplinary action;
- documents data lineage and excludes attributes not necessary for the stated purpose;
- creates a pseudonymised analytical dataset with controlled re-identification;
- uses role-based and row-level access, separate service identities and multi-factor authentication;
- masks or synthetically generates development data;
- records data access and model-building activities in protected audit logs;
- establishes retention and deletion rules for extracts, features and predictions;
- tests performance across relevant student groups and reviews false positives and false negatives;
- provides human review, an appeal route and clear communication to students;
- conducts periodic access and quality reviews.
OutcomeThe resulting system provides analysts with sufficient information while reducing unnecessary exposure. The model becomes one input to a trained adviser rather than an automatic decision-maker. Governance documentation enables review of data sources, model versions and interventions. Some proposed features are rejected because their benefits are uncertain and their privacy or fairness risks are high. Learning pointsSecurity controls, privacy analysis, ethical review and data quality cannot be added independently at the end of an AI project. They must shape the data architecture, access design, model purpose and operational workflow from the beginning. 11. Challenges, Limitations and Best PracticesSecurity controls create trade-offs. Strong encryption can complicate search and recovery. Detailed auditing increases storage and may itself capture sensitive information. Fine-grained access rules improve confidentiality but are difficult to maintain. Anonymisation is vulnerable to linkage attacks when external datasets are available. Compliance checklists may encourage superficial evidence rather than genuine risk reduction. Legacy systems often lack modern identity integration, reliable logging or clear ownership. Cloud services introduce shared-responsibility issues: the provider may secure infrastructure while the customer remains responsible for identities, configurations, data and applications. Third-party vendors may copy data into support systems or subprocessors, making lineage and deletion difficult. Recommended practices include: - classify data and identify owners before granting access;
- use central identity management and multi-factor authentication;
- apply least privilege, separation of duties and periodic access recertification;
- parameterise queries and test applications for injection;
- encrypt sensitive data in transit and at rest, with disciplined key management;
- mask or synthesise data used in development and testing;
- maintain protected, monitored audit trails;
- test backups and recovery, including integrity verification;
- document lineage, definitions, retention and permitted uses;
- assess privacy and fairness before high-risk projects;
- review vendors, interfaces and machine-learning datasets;
- train staff and measure whether controls work in practice.
Contemporary DevelopmentsZero-trust architectures increasingly require continuous verification rather than assuming that users inside a network are trustworthy. Confidential computing seeks to protect data while it is being processed in hardware-supported trusted environments. Data clean rooms allow organisations to analyse selected data without directly exchanging raw records, although their privacy properties depend on implementation and governance. Privacy-enhancing technologies, automated lineage tools and policy-as-code are also developing rapidly. Generative AI introduces additional database concerns: sensitive records may be sent to external models, generated outputs may contain fabricated or confidential information, and prompts and responses may become new data stores. Organisations should define approved tools, prevent inappropriate disclosure, retain relevant evidence, evaluate outputs and ensure that human accountability remains clear. Chapter SummaryDatabase security protects confidentiality, integrity and availability through layered controls. Authentication establishes identity, while authorisation determines permitted actions. RBAC, ABAC, least privilege and separation of duties provide structured access control. Encryption, tokenisation and masking reduce exposure, but depend on sound key management and do not replace authorisation. Auditing and monitoring support accountability and incident response. Parameterised queries are the primary defence against SQL injection. Privacy requires purpose limitation, minimisation, transparency, accuracy, appropriate retention and protection throughout the data life cycle. Ethical governance additionally considers fairness, autonomy, secondary use, surveillance and contestability. Data quality, lineage and stewardship make information trustworthy and assign responsibility. Governance frameworks connect policy, decision rights, standards, processes, measurement and assurance. Effective governance is continuous and must address cloud services, vendors, AI systems, legal duties and changing risks. Key TermsAuthentication: Verification of an identity. Authorisation: Determination of what an authenticated identity may do. Least privilege: Granting only the access necessary for an approved task. Role-based access control: Assigning permissions to roles and roles to users. Attribute-based access control: Making access decisions using attributes and context. Encryption: Cryptographic transformation of plaintext into ciphertext. Tokenisation: Replacement of sensitive data with a protected surrogate token. Masking: Hiding all or part of a data value from a viewer. Audit trail: Protected record of relevant system and data events. SQL injection: Attack that changes a database command through unsafe input handling. Privacy: Appropriate and justified handling of information about identifiable people. Data minimisation: Limiting collection and processing to what is necessary. Data lineage: Record of data origins, transformations and destinations. Data quality: Fitness of data for a defined purpose across dimensions such as accuracy and completeness. Data steward: Person responsible for day-to-day management of definitions, quality and use. Data custodian: Technical operator responsible for implementing and maintaining controls. Pseudonymisation: Replacing identifiers while retaining controlled re-identification capability. Separation of duties: Division of sensitive responsibilities among different individuals. Data governance: Authority, policies, processes and standards for managing data. Review QuestionsShort Answer Questions1. Distinguish authentication from authorisation. 2. What is the purpose of least privilege? 3. Why is masking not necessarily anonymisation? 4. State two important dimensions of data quality. 5. What information should an audit record normally contain? Long Answer Questions1. Explain how RBAC, ABAC, separation of duties and privileged access management can be combined in a database security architecture. 2. Discuss encryption at rest, encryption in transit, tokenisation and masking, including their limitations. 3. Explain the relationship among privacy, data retention, data lineage and stewardship. 4. Describe how a governance framework converts principles into operational accountability and compliance evidence. 5. Analyse the ethical risks of using student or patient data to train a predictive machine-learning model. Analytical / Application Questions1. A retail application builds SQL statements by concatenating customer input and connects using an administrator account. Identify the risks and propose a prioritised remediation plan. 2. Design an access-control and audit policy for a hospital database used by clinicians, receptionists, billing staff and researchers. 3. An organisation wants to retain every customer record and all backups indefinitely “for analytics.” Evaluate this proposal using privacy, security, governance and business considerations. Multiple Choice Questions with AnswersQuestion 1Which control primarily determines what an authenticated user is allowed to do? A. Authentication B. Authorisation C. Encryption D. Hashing Correct Answer: B. Authorisation Question 2What is the principal defence against SQL injection in application queries? A. Longer table names B. Parameterised queries C. Database compression D. More indexes Correct Answer: B. Parameterised queries Question 3Which principle requires granting only the permissions necessary for a task? A. Data portability B. Least privilege C. Availability D. Purpose expansion Correct Answer: B. Least privilege Question 4What is the main purpose of encryption in transit? A. To protect data moving across a network B. To remove duplicate records C. To define user roles D. To improve query indexing Correct Answer: A. To protect data moving across a network Question 5Which statement about tokenisation is correct? A. It always destroys the original data permanently B. It replaces sensitive data with a surrogate value C. It is identical to password hashing D. It guarantees that re-identification is impossible Correct Answer: B. It replaces sensitive data with a surrogate value Question 6Which privacy principle limits collection to data necessary for a stated purpose? A. Data minimisation B. Separation of duties C. Non-repudiation D. Load balancing Correct Answer: A. Data minimisation Question 7Which role usually manages metadata, definitions and day-to-day data quality? A. Data steward B. Network attacker C. End-user customer D. External auditor only Correct Answer: A. Data steward Question 8Why should audit logs be protected from ordinary users? A. To make queries execute faster B. To prevent alteration or deletion of evidence C. To encrypt all backups automatically D. To eliminate the need for access control Correct Answer: B. To prevent alteration or deletion of evidence Question 9A development team copies production records containing names and health information. What is the most appropriate immediate control? A. Increase the production database size B. Use masked, synthetic or appropriately pseudonymised data C. Give developers administrator access D. Disable all database indexes Correct Answer: B. Use masked, synthetic or appropriately pseudonymised data Question 10Which governance activity best supports understanding how a machine-learning feature was produced? A. Data lineage documentation B. Password reuse C. Unrestricted data export D. Removing data definitions Correct Answer: A. Data lineage documentation
|