Database Transactions, MIS, DSS, and SQL Optimization for Business Intelligence & Analytics - CSU2101 | Shoolini University

Database Transactions, MIS, DSS, and SQL Optimization for Business Intelligence & Analytics

This document provides an in-depth explanation of the topics covered in our class of February 24, 2025 and February 25, 2025. This guide is designed to be your go-to reference as you continue to build your knowledge and skills.

1. Databases: The Foundation of Structured Data

What Is a Database?

Concept: A database is a blueprint for storing structured data. It is designed to organize, manage, and facilitate efficient retrieval of information.

DBMS: An application used to create and manage databases is called a Database Management System (DBMS). While the term “database” refers to the concept, products such as MySQL are implementations of that concept.

Real-World Example: Consider a library catalog system. Just as every book is assigned a unique identifier and placed in a specific section, a database organizes data into tables, rows, and columns so that every piece of information can be easily located and referenced.

2. SQL: Structured Query Language

Definition: SQL is a standardized language (certified by ISO/ANSI) used to create, maintain, and manipulate databases. It is supported by all database products.

Categories of SQL

Each category serves a specific purpose and includes commands that help users interact with databases effectively. Let’s explore each category in detail.

2.1 DDL (Data Definition Language)

Purpose

Used to create, alter, or destroy the structure of database objects (e.g., tables, views, indexes).

Commands & Examples
  • CREATE – Establish new database objects.
    CREATE TABLE Employees (
        EmployeeID INT PRIMARY KEY,
        FirstName VARCHAR(50),
        LastName VARCHAR(50)
    );
  • ALTER – Modify the structure; it includes combinations such as:
    • ALTER ADD – Add new columns.
      ALTER TABLE Employees ADD DateOfBirth DATE;
    • ALTER UPDATE – Change existing column definitions.
      ALTER TABLE Employees ALTER COLUMN LastName VARCHAR(100);
    • ALTER DROP – Remove a column.
      ALTER TABLE Employees DROP COLUMN DateOfBirth;
  • DROP – Remove entire objects from the database.
    DROP TABLE Employees;
  • TRUNCATE – Remove all records from a table while retaining its structure. It can be seen as a combination of DROP and CREATE in that it clears data but preserves the table schema.
    TRUNCATE TABLE Employees;

2.2 DML (Data Manipulation Language)

Purpose

Handles transactions and data changes within the database.

Commands & Examples
  • INSERT – Add new records.
    INSERT INTO Employees (EmployeeID, FirstName, LastName) VALUES (1, 'John', 'Doe');
  • UPDATE – Modify existing records.
    UPDATE Employees SET LastName = 'Smith' WHERE EmployeeID = 1;
  • DELETE – Remove records.
    DELETE FROM Employees WHERE EmployeeID = 1;
  • MERGE – Combine insertion and updating operations based on specified conditions.
    MERGE INTO Employees AS Target
    USING NewEmployees AS Source
    ON Target.EmployeeID = Source.EmployeeID
    WHEN MATCHED THEN
        UPDATE SET Target.FirstName = Source.FirstName, Target.LastName = Source.LastName
    WHEN NOT MATCHED THEN
        INSERT (EmployeeID, FirstName, LastName)
        VALUES (Source.EmployeeID, Source.FirstName, Source.LastName);

2.3 DCL (Data Control Language)

Purpose

Manages permissions and access controls to data, ensuring that only authorized users can perform certain actions.

Commands & Examples
  • GRANT – Gives a user permission to perform certain actions on database objects.
    GRANT SELECT, INSERT ON Employees TO UserA;
  • REVOKE – Removes permissions previously granted to a user.
    REVOKE INSERT ON Employees FROM UserA;

    Explanation: This command removes the INSERT permission from UserA for the Employees table.

2.4 DQL (Data Query Language)

Purpose

Focuses on querying the data to retrieve specific information.

Commands & Examples
  • SELECT – Retrieves data based on specified criteria.
    SELECT * FROM Employees WHERE LastName = 'Smith';
  • Enhancements – The = operator is used to fetch rows that exactly match the specified value, while the LIKE operator is used for pattern searching.

    Example: % represents any number of characters and _ represents a single character.

    SELECT * FROM Employees WHERE FirstName LIKE 'Jo%';

    Explanation: This query fetches all employees whose first name starts with "Jo".

2.5 TCL (Transaction Control Language)

Purpose

Controls and manages transactions to ensure data integrity.

Commands & Examples
  • COMMIT – Saves all changes made in the current transaction.
    COMMIT;
  • ROLLBACK – Undoes changes made in the current transaction.
    ROLLBACK;
  • SAVEPOINT – Sets a point within a transaction to which you can later roll back if needed.
    SAVEPOINT Savepoint1;
    -- Some DML operations here
    ROLLBACK TO Savepoint1;

3. Management Information Systems (MIS) and Decision Support Systems (DSS)

Management Information System (MIS)

Definition:

MIS is a system used primarily by the lower levels of management to capture data from the external environment.

Purpose:

It focuses on routine data entry and operational transactions.

Real-World Scenario:

In a retail store, daily sales and inventory updates are entered into the MIS, enabling store managers to monitor stock levels and sales performance in real time.

Decision Support System (DSS)

Definition:

DSS is used by higher-level management to analyze the data compiled by the MIS and support strategic decision-making.

Purpose:

It transforms raw data into meaningful reports and analyses.

Real-World Scenario:

A CEO may use a DSS to evaluate quarterly performance reports generated from MIS data, helping decide whether to launch new products or adjust business strategies.

How MIS and DSS Work Together

Process Flow:
  1. Data Entry: When an MIS entry is made, it represents the fundamental building block of the data system.
  2. Transactions: Every event or operation—such as a sale, update, or deletion—is recorded as a transaction.
  3. Data Analysis: Aggregated transactions form the basis for generating reports.
  4. Decision Making: These reports feed into the DSS, where data analysis supports high-level decision-making.
Real-World Analogy:

Imagine an assembly line in a factory. The MIS collects each step’s data (like components added), while the DSS uses this data to forecast production trends and determine if adjustments are necessary for efficiency.

4. Transactions and Data Manipulation

Transactions in a Database

Data Manipulation Language (DML)

Data Analysis through Reports

5. Client-Server Architecture

Overview of Client-Server Models

Understanding the architecture behind how applications are delivered and executed is essential. Two primary models exist:

Thick Client Architecture
Thin Client Architecture

6. Ideation, Brainstorming, and Norming: Building the Foundation of Data Integrity

Ideation and Brainstorming

Norming

7. Data Integrity Rules

Domain Integrity Rule

Entity Integrity Rule

Referential Integrity Rule

Enterprise Integrity Rule

8. Understanding Keys in Database Systems

Types of Keys and Their Roles

Candidate Keys
Primary Key
Composite Key
Alternate Key
Super Key

9. SQL Clauses: Enhancing the Usability of Commands

This section describes several SQL clauses that refine queries by filtering, grouping, sorting, and limiting results.

WHERE Clause

Purpose:

The WHERE clause filters records based on specified conditions.

Usage Example:
SELECT * FROM Employees
WHERE Department = 'Sales';

GROUP BY Clause

Purpose:

The GROUP BY clause groups rows that share common values so that aggregate functions can be applied to each group.

Usage Example:
SELECT Department, COUNT(*)
FROM Employees
GROUP BY Department;

HAVING Clause

Purpose:

The HAVING clause filters groups created by the GROUP BY clause based on specified conditions.

Usage Example:
SELECT Department, COUNT(*)
FROM Employees
GROUP BY Department
HAVING COUNT(*) > 5;

ORDER BY Clause

Purpose:

The ORDER BY clause sorts the results of a SQL query based on one or more columns. By default, sorting is done in ascending order; you can specify ASC or DESC to control the order.

Usage Examples:

Sorting by Column Name:

SELECT * FROM EMP
ORDER BY SALARY DESC;

Sorting by Column Sequence Number:

SELECT * FROM EMP
ORDER BY 6;

Multi-Level Sorting:

SELECT * FROM EMP
ORDER BY DEPTNO, SAL;

LIMIT/OFFSET Clause

Purpose:

The LIMIT clause restricts the number of records returned by a query, while OFFSET specifies the starting point of the records to return.

Usage Example:
SELECT * FROM EMP
LIMIT 10 OFFSET 5;

Practical Example: Employee Details Query

Problem Statement

Display the details of employees working for department number 10 in ascending order based on their salary.

Step-by-Step Approach
  1. Filtering Data:

    Use a WHERE clause to filter employees belonging to department 10.

  2. Sorting Data:

    Apply the ORDER BY clause to arrange the filtered results in ascending order by salary.

Query Structure

The correct order of clauses is essential: the filtering (WHERE) comes before the sorting (ORDER BY).

Real-World Analogy

Imagine you are in charge of a team and need to list members of a specific department. First, you identify everyone in that department (filtering) and then arrange them by their performance score (sorting) to see who ranks lowest to highest.

Motivation

Your continuous engagement with these concepts will be essential as you work with databases and data systems in more complex environments. Stay curious and keep exploring the dynamic world of data and systems—every piece of information builds toward your expertise and success in this field.