Module 1 -- Database Management Systems


Index

  1. File Systems vs DBMS
  2. 2-tier Architecture vs 3-tier architecture
  3. What is Schema?
  4. Three Levels of Abstraction / Three types of Schema
  5. Data Definition Language (DDL)
  6. .Data Manipulation Language (DML)
  7. Data Independence
  8. Integrity Constraints
  9. Entity Relationship Model
  10. Types of attributes in ER model
  11. Types of Keys in relational database
  12. Types of relationships in ER Model (not the ones you're thinking of)
  13. 3. Implementing One-to-One Relationships in the Relational Model
  14. One to Many Relationship
  15. Many-to-Many relationship
  16. Data Models

File Systems vs DBMS

1. Historical Context and Basic Definitions

2. Data Access and Retrieval Efficiency

3. Abstraction from Physical Data Storage

4. Concurrency and Multi-user Environment

5. Security and Role-Based Access Control

6. Data Redundancy and Integrity

7. Overall Conclusion and Real-World Applications


2-tier Architecture vs 3-tier architecture

https://www.youtube.com/watch?v=VyvTabQHevw&list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y&index=4

2-Tier Architecture

Pasted image 20250306185155.png

Definition

How it Works

Real-Life Examples

Advantages & Disadvantages of 2-Tier Architecture

3-Tier Architecture

Pasted image 20250306185217.png

Definition

How It Works

Advantages of 3-Tier Architecture

  1. Scalability – The business layer handles user requests, reducing the direct load on the database.
  2. Security – The client does not interact directly with the database, preventing unauthorized access.
  3. Comparison with Cloud Computing – Similar to cloud systems like Gmail, where users don’t know where the data is stored but can access it seamlessly.
  4. Faster Data Processing – The business layer prepares optimized queries, so the database server only handles precise, filtered requests.

Conclusion


Schema and it's architectures

What is Schema?

1. Definition and Concept


2. Illustration with Entities


3. Three-Schema Architecture Context


4. Implementation Using SQL


5. Summary


Three Levels of Abstraction / Three types of Schema

https://www.youtube.com/watch?v=5fs1ldO6B5c&list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y&index=6

Pasted image 20250307022923.png

The three-schema architecture in a Database Management System (DBMS) is a conceptual framework that separates how data is viewed by users, logically organized, and physically stored. This separation not only simplifies design and maintenance but also provides data independence—changes in one layer do not necessarily affect the others. Here’s a detailed breakdown:


1. External Schema (View Level)


2. Conceptual Schema (Logical Level)


3. Internal Schema (Physical Level)


Data Independence and the Role of Mapping


Conclusion

The three-schema architecture is fundamental to modern database systems because it cleanly separates user interaction, logical design, and physical storage. This layered approach:


Data Independence

1. What Is Data Independence?


2. The Three Levels of Schema Architecture

Recall that the three-schema architecture separates the database system into three distinct layers:


3. Types of Data Independence


4. Why Is Data Independence Important?


Integrity Constraints

1. Purpose of Integrity Constraints


2. Domain Constraints


3. Primary Key Constraints


4. Referential Integrity Constraints


5. Overall Importance of Integrity Constraints


Types of Keys in relational database

https://www.geeksforgeeks.org/types-of-keys-in-relational-model-candidate-super-primary-alternate-and-foreign/

Pasted image 20250307030734.png

  1. Super Key
  2. Candidate Key
  3. Primary Key
  4. Foreign Key
  5. Super Key

1. Super Key

The set of one or more attributes (columns) that can uniquely identify a tuple (record) is known as Super Key. For Example, STUD_NO, (STUD_NO, STUD_NAME), etc.

Example table:

STUD_NO SNAME ADDRESS PHONE
1 Shyam Delhi 123456789
2 Rakesh Kolkata 223365796
3 Suraj Delhi 175468965
Consider the table shown above.  
STUD_NO+PHONE is a super key.

2. Candidate Key

The minimal set of attributes that can uniquely identify a tuple is known as a candidate key. For Example, STUD_NO in STUDENT relation.

Example : STUD_NO is the candidate key for relation STUDENT.


3. Primary Key

There can be more than one candidate key in relation out of which one can be chosen as the primary key. For Example, STUD_NO, as well as STUD_PHONE, are candidate keys for relation STUDENT but STUD_NO can be chosen as the primary key (only one out of many candidate keys).


4. Foreign Key

foreign key is an attribute in one table that refers to the primary key in another table. The table that contains the foreign key is called the referencing table, and the table that is referenced is called the referenced table.

1. Introduction to Foreign Keys


2. The Role of Foreign Keys in Maintaining Integrity


3. Operations and Their Impact on Referential Integrity (Important)

A. Operations on the Referenced (Base) Table

B. Operations on the Referencing Table


4. Summary of Key Points


Data Definition Language (DDL)

1 Role of DDL

2 Common DDL Commands

  1. CREATE

    • Usage: Create a new table, view, index, or other object.
    • Syntax (Table):
  CREATE TABLE students (
student_id INT PRIMARY KEY,
name       VARCHAR(50) NOT NULL,
major      VARCHAR(50),
dob        DATE,
CONSTRAINT chk_major CHECK (major <> '')
);
  1. ALTER

    • Usage: Modify the structure of an existing table or other objects.

    • Syntax:

      ALTER TABLE students   ADD COLUMN email VARCHAR(100) UNIQUE;
      
    • Possible Actions: Add/drop columns, rename columns, change data types, add constraints.

  2. DROP

    • Usage: Delete a table, view, or other object from the database.

    • Syntax:

      DROP TABLE students;
      
  3. TRUNCATE

    • Usage: Quickly remove all rows from a table, resetting it to empty without logging each row deletion.

    • Syntax:

      TRUNCATE TABLE students;
      
    • Note: TRUNCATE is typically faster than DELETE without a WHERE clause.

  4. RENAME (DBMS-dependent)

    • Usage: Rename database objects.

    • Syntax (Oracle example):

      RENAME students TO student_info;
      

3.3 Constraints in DDL


.Data Manipulation Language (DML)

1. Role of DML

2. Common DML Commands

  1. SELECT

    • Usage: Retrieve data from tables/views.

    • Key Clauses:

      • WHERE (filtering)
      • GROUP BY (aggregation)
      • HAVING (filtering aggregated results)
      • ORDER BY (sorting)
      • JOIN (combining rows from multiple tables)
    • Example:

      SELECT s.student_id, s.name, c.course_name
      FROM students s
      JOIN enrollment e ON s.student_id = e.student_id
      JOIN courses c    ON e.course_id = c.course_id
      WHERE s.major = 'Computer Science';
      
      
  2. INSERT

    • Usage: Add new rows to a table.

    • Example:

      INSERT INTO students (student_id, name, major, dob)
      VALUES (101, 'Alice', 'Computer Science', '2002-05-14');
      
      
  3. UPDATE

    • Usage: Modify existing rows.

    • Example:

      UPDATE students
      SET major = 'Information Technology'
      WHERE student_id = 101;
      
      
    • Caution: Without a WHERE clause, all rows in the table are updated.

  4. DELETE

    • Usage: Remove rows from a table.

    • Example:

      DELETE FROM students WHERE student_id = 101;
      

3. Transaction Control (Often Considered Part of DML)

Key Insight:


Data Models

Entity Relationship Model

https://www.youtube.com/watch?v=gbVev8RuZLg&list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y&index=15

1. Purpose of the ER Model


2. Key Components of the ER Model


3. Diagrammatic Representation

Pasted image 20250307190119.png

Pasted image 20250307190140.png


4. The Process of Translating Requirements into the ER Model


5. Advantages of Using the ER Model


Types of attributes in ER model

https://www.geeksforgeeks.org/types-of-attributes-in-er-model/

https://www.youtube.com/watch?v=WEo3g6Ir-vA&list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y&index=16

1. Single-Valued vs. Multi-Valued Attributes


2. Simple vs. Composite Attributes


3. Stored vs. Derived Attributes


4. Key Attributes vs. Non-Key Attributes


5. Required vs. Optional Attributes


6. Complex Attributes


Types of relationships in ER Model (not the ones you're thinking of)

1. Understanding Relationships in ER Models


2. Focusing on One-to-One Relationships


3. Implementing One-to-One Relationships in the Relational Model

Pasted image 20250307193537.png


4. Merging Tables in One-to-One Relationships


One to Many Relationship

https://www.youtube.com/watch?v=rZxETdO_KUQ&list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y&index=18

Pasted image 20250307194152.png


Many-to-Many relationship

https://www.youtube.com/watch?v=onR_sLhbZ4w&list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y&index=19

Pasted image 20250307195150.png


1. Overview of Data Models

Data models provide the structure for storing, organizing, and manipulating data. They define how data is connected, how it is stored, and how it can be accessed. There are several types of data models, but today we’ll focus on three key ones:

Each of these models addresses the representation and handling of data differently.


2. Network Data Model

https://www.geeksforgeeks.org/network-model-in-dbms/

Pasted image 20250307195709.png

2.1 Key Characteristics

2.2 Advantages

2.3 Drawbacks

2.4 Example

Imagine a telecommunications network:


3. Relational Data Model

https://www.geeksforgeeks.org/relational-model-in-dbms/

Pasted image 20250307201317.png

3.1 Key Characteristics

3.2 Advantages

3.3 Drawbacks

3.4 Example

Consider a university database:


4. Object-Oriented Data Model

https://www.geeksforgeeks.org/basic-object-oriented-data-model/

Pasted image 20250307201358.png

4.1 Key Characteristics

4.2 Advantages

4.3 Drawbacks

4.4 Example

Imagine a multimedia library system: