IT231 Foundation of Information Technology

Foundation of Information TechnologyUnit 810 min read

Database Systems & Management: DBMS, ERD, SQL, Normalization, Security

Unit 8 of Foundation of Information Technology covers database systems, their architecture, Entity-Relationship modeling, Structured Query Language (SQL), normalization techniques, and security measures, with real-world applications in Nepalese and global IT infrastructure.

What is a Database System?

A database system is an organized collection of data stored and accessed electronically. It allows efficient storage, retrieval, and management of data. The core components include:

  • Database: Organized collection of data.
  • DBMS (Database Management System): Software that interacts with the database (e.g., MySQL, Oracle, PostgreSQL).
  • Users: End-users, application programs, or system administrators.
  • Hardware: Storage devices, processors, and memory.

How a Database System Works

A DBMS acts as an intermediary between users and the database. It provides:

  • Data definition language (DDL): Defines the database schema (e.g., CREATE TABLE).
  • Data manipulation language (DML): Manipulates data (e.g., INSERT, UPDATE, DELETE).
  • Data control language (DCL): Manages access (e.g., GRANT, REVOKE).
  • Query processing: Executes user queries efficiently.
flowchart TD
    A["User/Application"] -->|"Query/Command"| B["DBMS"]
    B -->|"Processes Query"| C["Query Optimizer"]
    C -->|"Generates Execution Plan"| D["Storage Engine"]
    D -->|"Retrieves/Stores Data"| E["Database"]
    E -->|"Returns Result"| B
    B -->|"Result"| A

Types of Database Systems

Type Description Example
Relational DBMS Stores data in tables with rows and columns (SQL-based). MySQL, PostgreSQL, Oracle
NoSQL DBMS Stores data in non-tabular formats (e.g., JSON, key-value pairs). MongoDB, Cassandra
Hierarchical DBMS Data organized in a tree-like structure. IBM IMS
Network DBMS Data linked via pointers (more flexible than hierarchical). IDMS
Object-Oriented DBMS Stores data as objects (used in OOP applications). db4o, ObjectDB
MySQLPostgreSQLOracleRelational DBMSMongoDBCassandraRedisNoSQL DBMSIBM IMSIDMSHierarchical/Network DBMSDatabase Systems
Classification of database systems with real-world examples

Entity-Relationship (ER) Modeling

ER modeling is a visual way to represent database structure using entities, attributes, and relationships.

Key Components

  1. Entity: A real-world object (e.g., Student, Course).
  2. Attribute: Properties of an entity (e.g., StudentID, Name).
  3. Relationship: Association between entities (e.g., Enrolls between Student and Course).
  4. Cardinality: Describes how many instances of one entity relate to another (1:1, 1:M, M:N).

ER Diagram Example: University Database

erDiagram
    STUDENT ||--o{ ENROLLMENT : enrolls
    ENROLLMENT ||--|| COURSE : takes
    STUDENT {
        int StudentID PK
        string Name
        date DOB
    }
    COURSE {
        int CourseID PK
        string Title
        int Credits
    }
    ENROLLMENT {
        int EnrollmentID PK
        int StudentID FK
        int CourseID FK
        date EnrollmentDate
    }

Structured Query Language (SQL)

SQL is the standard language for interacting with relational databases.

Basic SQL Commands

Category Command Purpose
DDL CREATE, ALTER, DROP Define or modify database structure.
DML INSERT, UPDATE, DELETE Manipulate data.
DQL SELECT Retrieve data.
DCL GRANT, REVOKE Control access to data.

Worked Example: Managing a Daraz Order Queue

Suppose Daraz uses a database to track orders. Here’s how SQL helps:

  1. Create a table for orders:
    CREATE TABLE Orders (
        OrderID INT PRIMARY KEY,
        CustomerID INT,
        ProductID INT,
        OrderDate DATE,
        Status VARCHAR(20)
    );
    
  2. Insert an order:
    INSERT INTO Orders (OrderID, CustomerID, ProductID, OrderDate, Status)
    VALUES (1001, 5001, 2005, '2023-10-15', 'Processing');
    
  3. Update order status:
    UPDATE Orders SET Status = 'Shipped' WHERE OrderID = 1001;
    
  4. Query pending orders:
    SELECT * FROM Orders WHERE Status = 'Pending';
    

Database Normalization

Normalization reduces redundancy and improves data integrity by organizing data into tables.

1NFAtomic values only(no repeating groups)2NFRemoves partialdependencies (composit3NFRemoves transitivedependencies (non-key BCNFStricter 3NF withall determinants as ca
Progression of normalization forms with key rules

Normal Forms

Normal Form Rule Example Violation
1NF Each table cell contains a single value (atomicity). Storing multiple phone numbers in one cell.
2NF Must be in 1NF + no partial dependencies (non-key attributes depend on the whole primary key). A Student table with StudentID (PK) and CourseID, Grade where CourseID is part of a composite key.
3NF Must be in 2NF + no transitive dependencies (non-key attributes depend only on the primary key). A Student table with StudentID (PK), Department, and DepartmentHead (where DepartmentHead depends on Department).

Worked Example: Normalizing a Bank Loan Database

Unnormalized Table:

LoanID CustomerName LoanAmount InterestRate BranchName BranchManager
1 Ram 500000 8% Kathmandu Ramesh
2 Sita 300000 7% Pokhara Suresh

Issues:

  • BranchName and BranchManager are repeated.
  • InterestRate depends on BranchName, not LoanID.

Normalized Tables (3NF):

  1. Loans:

    LoanID CustomerName LoanAmount BranchID (FK)
    1 Ram 500000 1
    2 Sita 300000 2
  2. Branches:

    BranchID BranchName InterestRate BranchManager
    1 Kathmandu 8% Ramesh
    2 Pokhara 7% Suresh

Database Security

Security ensures data integrity, confidentiality, and availability.

Threats and Countermeasures

Threat Countermeasure
Unauthorized Access Authentication (passwords, biometrics), Authorization (role-based access control).
Data Breach Encryption (AES, RSA), Firewalls, Intrusion Detection Systems (IDS).
SQL Injection Use parameterized queries, input validation.
Data Loss Regular backups, RAID storage.

Worked Example: Securing NEPSE’s Database

NEPSE (Nepal Stock Exchange) must protect sensitive financial data:

  1. Encryption: Use AES-256 to encrypt customer transaction records.
  2. Access Control: Grant SELECT permissions only to analysts and INSERT/UPDATE to authorized traders.
  3. Audit Logs: Track all UPDATE operations on stock prices to detect fraud.

In the Real World

  1. eSewa (Nepal):

    • Idea Used: Relational DBMS (MySQL/PostgreSQL) to store user transactions, payment histories, and service requests.
    • How: When you pay your electricity bill via eSewa, the system queries the database to verify your account, deduct the amount, and update the NTC’s records in real-time.
  2. Khalti (Nepal):

    • Idea Used: Normalization and transactions (ACID properties) to ensure money transfers between users are atomic (either fully complete or fully rolled back).
    • How: If you send Rs. 5000 to a friend, Khalti’s database locks both your and your friend’s accounts during the transfer to prevent double-spending.
  3. Google Maps (Global):

    • Idea Used: NoSQL databases (e.g., Bigtable) to store geospatial data and handle massive scale.
    • How: When you search for "restaurants near me," Google’s database retrieves location data, user reviews, and ratings in milliseconds using distributed indexing.

Exam Tip

  1. ER Diagrams: Always label entities, attributes (with primary keys underlined), and relationships with cardinality (e.g., 1:M). Partial credit is given for correct symbols even if labels are missing.
  2. SQL Queries: Practice writing JOIN queries (e.g., INNER JOIN, LEFT JOIN) as they are frequently tested. Example:
    SELECT Students.Name, Courses.Title
    FROM Students
    INNER JOIN Enrollment ON Students.StudentID = Enrollment.StudentID
    INNER JOIN Courses ON Enrollment.CourseID = Courses.CourseID;
    
  3. Normalization: Questions often ask you to convert an unnormalized table to 3NF. Start by identifying partial and transitive dependencies.
  4. Security: Know the difference between authentication (proving identity) and authorization (granting permissions). Example:
    • Authentication: Logging in with a username and password.
    • Authorization: A bank teller can update accounts but not delete customer records.
  5. Real-World Applications: Relate theoretical concepts to Nepalese examples (e.g., how Ncell’s customer database uses normalization to avoid redundancy in phone plans and usage records).

Based on the TU BIM syllabus for Foundation of Information Technology (IT231), unit 8.

Discussion

Loading…