1. Introduction to DBMS
Definition: Database Management System (DBMS) is software that manages data, databases, and provides
users with the tools to store, manipulate, and retrieve data efficiently.
Types of DBMS: - Hierarchical DBMS - Network DBMS - Relational DBMS (RDBMS) - NoSQL DBMS
Advantages: - Reduced data redundancy - Data consistency - Data security - Multiple user access - Easy
data retrieval
2. Database Models
ER Model: - Entities: Real-world objects (Student, Course) - Attributes: Properties of entities (StudentName,
RollNo) - Relationships: Links between entities (Enrolls)
ER Diagram Example:
Student --< Enrolls >-- Course
ER to Table Conversion: - Entity becomes table - Attributes become columns - Relationships mapped via
foreign keys
3. Relational Model
Tables: Rows (tuples), Columns (attributes)
Keys: - Primary Key (PK) : Unique identifier - Foreign Key (FK) : Links tables
Relationships: - 1:1, 1:M, M:N
4. SQL Basics
Database Creation:
1
, CREATE DATABASE UniversityDB;
USE UniversityDB;
Table Creation:
CREATE TABLE Student (
RollNo INT PRIMARY KEY,
StudentName VARCHAR(50),
Age INT
);
Insert Data:
INSERT INTO Student VALUES (1, 'Alice', 20);
INSERT INTO Student VALUES (2, 'Bob', 21);
Select Data:
SELECT * FROM Student;
SELECT StudentName FROM Student WHERE Age > 20;
Update Data:
UPDATE Student SET Age = 22 WHERE RollNo = 2;
Delete Data:
DELETE FROM Student WHERE RollNo = 1;
5. Advanced SQL
JOINs:
-- INNER JOIN
SELECT Student.StudentName, Course.CourseName
2