Unit 5: Security, Authorization, and Advanced Topics




Database Security, Authorization & Advanced Topics

Database Security

Database Security means protecting data from unauthorized access, misuse, or corruption.
Just like you lock your house to prevent thieves, databases also need digital locks.

Main Goals of Database Security

  1. Confidentiality – Only authorized users can access data.
  2. Integrity – Data should remain accurate and consistent.
  3. Availability – Authorized users can access data when needed.

Key Security Components

ConceptMeaningExample
AuthenticationVerifying the identity of a userUsername & password
AuthorizationGiving specific rights to usersAdmin can modify, user can only view
PrivilegesPermissions to perform actionsSELECT, INSERT, DELETE privileges

SQL Example:

CREATE USER jay IDENTIFIED BY '12345'; GRANT SELECT, INSERT ON Employee TO jay;

Common Security Threats

ThreatDescription
SQL InjectionHacker inserts malicious SQL code
Unauthorized AccessAccess without permission
Data Theft or LeakageStealing confidential information
Virus or MalwareDamaging database files
Human ErrorAccidental data deletion or update

Auditing, Access Controls, and Violation Handling

Auditing

Auditing means tracking and recording all database activities — who accessed what, when, and how.
It helps in detecting misuse or data breaches.

Think of it as a CCTV camera for your database.

Example:

  • Who deleted a record?
  • Who changed salary data last night?


Access Control

Access control defines who can do what in a database.

TypeDescriptionExample
Discretionary Access Control (DAC)Access given by the data ownerHR allows only Managers to view payroll
Mandatory Access Control (MAC)Access based on security levelConfidential vs. Public data
Role-Based Access Control (RBAC)Access based on user’s job roleAdmin, Accountant, Employee

Violation Handling

When unauthorized access or suspicious activity is detected, the system:

  1. Logs the event
  2. Alerts the admin
  3. May temporarily lock the user or session

Data Integrity and Constraints

Data Integrity means maintaining accuracy, consistency, and reliability of data.
The system should never store wrong, duplicate, or incomplete data.

Types of Integrity:

TypeMeaningExample
Entity IntegrityEach record must have a unique IDPrimary Key: EmpID
Referential IntegrityForeign key must match existing recordEvery DeptID must exist in Department table
Domain IntegrityValues must be valid and within rangeSalary cannot be negative
User-defined IntegrityBusiness rules appliedEmployee age ≥ 18

Constraints Used:

ConstraintDescription
PRIMARY KEY – unique & not nullEmpID INT PRIMARY KEY
FOREIGN KEY – links tablesDeptID INT REFERENCES Department(DeptID)
NOT NULL – no empty valueName VARCHAR(50) NOT NULL
CHECK – condition must be trueCHECK (Salary > 10000)
UNIQUE – no duplicate valuesEmail UNIQUE

Distributed Databases and Client-Server Architecture

Distributed Database

A distributed database is stored across multiple computers or locations, but acts as one single database. Example: A bank has branches in many cities. Each branch stores local customer data but can still access data from other branches when needed.

Advantages:

  • Faster local access
  • Data sharing across locations
  • Improved reliability (if one server fails, others continue)

Challenges:

  • Synchronizing data between servers
  • Handling network failures

Client-Server Architecture

This model divides work between:

  1. Client (Front-end) → User interface or application
  2. Server (Back-end) → Database and processing

Example:

  • You open a banking app (client)
  • App requests account details from the bank database (server)

Benefits:

  • Centralized control
  • Easier management
  • Supports multiple users at once

Introduction to Data Warehousing, OLAP, OLTP & Data Mining

Data Warehousing

A data warehouse is a large, centralized storage system used for storing historical data from different sources.
It helps in business analysis and decision-making.

FeatureDescription
PurposeLong-term storage for analysis
Data TypeHistorical, summarized
UsersManagers, analysts
ExampleSales data of last 10 years

OLAP (Online Analytical Processing)

OLAP systems are used for analyzing large amounts of data from the data warehouse.

FeatureDescription
FocusData analysis & reporting
OperationsRoll-up, drill-down, slice, dice
Example“Show total sales by region and year.”

Used in business intelligence dashboards and decision support systems.

OLTP (Online Transaction Processing)

OLTP systems are used for day-to-day transactions like inserting, updating, or deleting data.

FeatureDescription
FocusReal-time transactions
Data TypeCurrent, detailed
ExampleATM withdrawals, online bookings, sales billing

Difference between OLTP and OLAP

BasisOLTPOLAP
PurposeDaily operationsData analysis
DataReal-timeHistorical
UsersClerks, employeesManagers, analysts
ExampleBank transactionYearly profit report
Query TypeSimple, frequentComplex, summary-based

Data Mining

Data Mining means extracting useful patterns, trends, or insights from large datasets.

Example:

  • Predicting which product customers will buy next
  • Identifying fraudulent credit card transactions
  • Customer segmentation based on buying behavior

Common Data Mining Techniques

TechniquePurpose
ClassificationCategorize data (e.g., high or low risk)
ClusteringGroup similar data (e.g., customer groups)
AssociationFind relationships (e.g., “People who buy bread also buy butter”)
RegressionPredict future values (e.g., sales forecast)

Summary Table

TopicKey IdeaExample
AuthenticationVerifies user identityLogin credentials
AuthorizationGrants user rightsAdmin vs. user access
PrivilegesDatabase permissionsSELECT, UPDATE
AuditingTracks user activityWho updated records
Access ControlRestricts user actionsRole-based permissions
Data IntegrityEnsures data correctnessPrimary key, foreign key
Distributed DBData across many serversBanking system
Client-ServerFront-end + back-end modelApp and database
Data WarehouseHistorical data storage10 years sales data
OLTPReal-time transaction systemATM withdrawal
OLAPAnalytical systemRegional sales analysis
Data MiningFinding patterns & insightsCustomer purchase trends

In Simple Words:

  • Security keeps data safe
  • Authorization controls access
  • Integrity keeps data accurate
  • Distributed DB shares data across servers
  • OLTP runs daily business, OLAP analyzes it, and Data Mining learns from it

Practical Applications & Case Studies of DBMS

Use of Commercial and Open-Source DBMS

A Database Management System (DBMS) is software that helps store, organize, and manage data efficiently.
There are two main types based on cost and ownership:

TypeDescriptionExamplesFeatures
Commercial DBMSPaid, enterprise-level databases used by large organizationsOracle, Microsoft SQL Server, IBM DB2High performance, strong security, technical support
Open-Source DBMSFree to use and modify by anyoneMySQL, PostgreSQL, MariaDB, SQLiteCost-effective, community support, easy to learn

Commonly Used DBMS in Industry

DBMSTypeUsed ByHighlights
MySQLOpen-sourceWeb developers, startupsLightweight, fast, widely used with PHP websites
Oracle DatabaseCommercialBanking, insurance, ERPVery secure, supports large data
SQL ServerCommercialCorporates, IT firmsIntegrates with Microsoft products
PostgreSQLOpen-sourceResearch, analyticsAdvanced queries, data integrity
MongoDBOpen-source (NoSQL)E-commerce, appsStores data in JSON format, flexible

Real-Life Case Studies by Business Sector

Let’s look at how DBMS is practically used in different management areas like Finance, Marketing, HR, Retail, and E-Commerce 

A. Finance Sector (Banking & Investment)

AspectExampleDBMS Use
Customer Data ManagementBanks like HDFC, SBIStore account info, transactions, KYC data
Transaction RecordsATMs, NEFT, UPI systemsReal-time debit/credit entries using OLTP
Fraud DetectionCredit card companiesData mining helps find suspicious patterns
Report GenerationFinancial analystsSQL queries generate monthly reports

Example Case: HDFC Bank uses Oracle Database for managing millions of customer transactions daily. It ensures ACID properties — accuracy, consistency, isolation, and durability — in all operations.

B. Marketing Sector

AspectExampleDBMS Use
Customer SegmentationCRM systems like SalesforceStore and categorize customer demographics
Campaign ManagementEmail & digital marketing toolsTrack campaign responses and leads
Market ResearchSQL + Excel + TableauAnalyze buying patterns and preferences
Data MiningPredictive marketingSuggest products or promotions

Example Case: Amazon Marketing Cloud uses databases to track user behavior — what customers search, view, and buy — to send personalized recommendations.

C. Human Resource (HR) Sector

AspectExampleDBMS Use
Employee RecordsHRMS softwareStore employee data, attendance, payroll
Recruitment DatabaseJob portals like NaukriManage resumes, candidate data
Performance ManagementOracle HR SuiteTrack KPIs and appraisal records
Training & DevelopmentLMS systemsTrack course progress and certifications

Example Case: Infosys HR Department uses SQL Server to maintain employee attendance, salary, and leave records, ensuring easy retrieval and analysis.

D. Retail Sector

AspectExampleDBMS Use
Inventory ManagementBig Bazaar, D-MartTrack stock levels, purchase orders
Billing SystemPOS (Point of Sale)Update stock after every sale
Supplier DataVendor databaseMaintain supplier details and transactions
Sales AnalysisReporting dashboardsIdentify best-selling items

Example Case: D-Mart uses MySQL + SAP ERP to automatically update inventory when a customer purchases an item — ensuring no stockouts or overstock.

E. E-Commerce Sector

AspectExampleDBMS Use
Customer AccountsFlipkart, AmazonStore login details, orders, payments
Product DatabaseProduct catalogDetails like name, price, stock, images
Order ProcessingTransactional databaseEnsures each order and payment is recorded
Recommendation SystemAI + DBMSSuggest similar products using user history

Example Case: Flipkart uses MongoDB and MySQL to manage product listings, user accounts, and order histories efficiently.
The system supports millions of concurrent users and maintains real-time inventory synchronization.

Designing a Relational Database for a Business Use Case

Let’s design a simple relational database example for better understanding.


Use Case: Online Bookstore

Objective: Store customer orders, books, and payment details efficiently.

Step 1: Identify Entities (Tables)

Table NameDescription
CustomersCustomer details
BooksBook information
OrdersPurchase details
PaymentsPayment information

Step 2: Define Attributes

TableAttributes
CustomersCustomerID (PK), Name, Email, Phone
BooksBookID (PK), Title, Author, Price, StockQty
OrdersOrderID (PK), CustomerID (FK), BookID (FK), OrderDate, Quantity
PaymentsPaymentID (PK), OrderID (FK), PaymentMode, Status

Step 3: Relationships

RelationshipDescription
Customer ↔ OrdersOne customer can make many orders (1:M)
Orders ↔ BooksMany orders can include many books (M:N)
Orders ↔ PaymentsOne order has one payment (1:1)

Step 4: Sample SQL Commands

CREATE TABLE Customers ( CustomerID INT PRIMARY KEY, Name VARCHAR(50), Email VARCHAR(50), Phone VARCHAR(15) ); CREATE TABLE Books ( BookID INT PRIMARY KEY, Title VARCHAR(100), Author VARCHAR(50), Price DECIMAL(10,2), StockQty INT ); CREATE TABLE Orders ( OrderID INT PRIMARY KEY, CustomerID INT, BookID INT, OrderDate DATE, Quantity INT, FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID), FOREIGN KEY (BookID) REFERENCES Books(BookID) ); CREATE TABLE Payments ( PaymentID INT PRIMARY KEY, OrderID INT, PaymentMode VARCHAR(20), Status VARCHAR(20), FOREIGN KEY (OrderID) REFERENCES Orders(OrderID) );

Step 5: Output Example

CustomerBookQuantityPayment ModeStatus
Jay SinghData Analytics 1012UPISuccessful
Aman GuptaMarketing Basics1Credit CardPending

Benefits of this DB Design:

  • Avoids data duplication (Normalization)
  • Ensures accuracy (Data Integrity)
  • Easy to generate reports — sales, payments, customer orders

Summary Table

ConceptDescriptionExample
Commercial DBMSPaid databases for large firmsOracle, SQL Server
Open-source DBMSFree, customizableMySQL, PostgreSQL
Finance UseManages transactionsBanking systems
Marketing UseStores campaign and lead dataCRM systems
HR UseEmployee managementHRMS
Retail UseInventory and billingPOS system
E-Commerce UseOrders and paymentsFlipkart, Amazon
Relational DB ExampleTables with keys and relationshipsOnline Bookstore

In Simple Words

A DBMS is the brain behind every business operation —
from your online shopping cart to your bank account balance and employee database  all rely on databases to store, secure, and analyze information