Module-1: Database System Architecture and Data Model
1. Database System Architecture
It consists of 3 levels:
- Physical Level: Describes how data is actually stored.
- Logical Level: Describes what data is stored and the relationships among the data.
- View Level: Describes only part of the entire database to the users.
Data Abstraction helps simplify user interaction with data by hiding complexity.
2. Data Independence
- Logical Data Independence: Changes in logical schema do not affect external views.
- Physical Data Independence: Changes in physical schema do not affect logical schema.
3. Data Definition Language (DDL)
DDL commands define the structure of the database.
Example:
CREATE TABLE Students (
id INT PRIMARY KEY,
name VARCHAR(50),
age INT
);
4. Data Manipulation Language (DML)
DML is used for accessing and manipulating data:
- SELECT
- INSERT
- UPDATE
- DELETE
Example:
INSERT INTO Students VALUES (1, 'Anish', 21);
SELECT * FROM Students;
5. Data Models
- Entity-Relationship Model: Uses entities and relationships. Visualized using ER Diagrams.
- Network Model: Uses records and sets with links (pointers).
- Relational Model: Data represented in tables with rows and columns.
- Object-Oriented Model: Uses classes, objects, inheritance like in programming.
6. Integrity Constraints and Data Operations
- PRIMARY KEY: Unique value for each record.
- FOREIGN KEY: Reference to a primary key in another table.
- NOT NULL: Attribute must have a value.
- CHECK: Constraint to ensure value meets a condition.
Example:
CREATE TABLE Enrollments (
student_id INT,
course_id INT,
FOREIGN KEY (student_id) REFERENCES Students(id)
);