Skip to main content

Introduction to DBMS

A database is an organised collection of data; a database management system (DBMS) is the software that stores, retrieves and protects it.

Why not plain files?​

File systemDBMS
Redundant, inconsistent copiesControlled redundancy
Hard to queryDeclarative queries (SQL)
No built-in concurrency controlTransactions and locking
Manual securityFine-grained access control
Manual backupBackup, recovery, logging

Three-schema architecture​

  1. External (views): what each user sees.
  2. Conceptual (logical): entities, relationships and constraints.
  3. Internal (physical): files, indexes, storage structures.

Data independence means a change at one level does not force changes at the next.

Entity-relationship (ER) model​

ConceptMeaningExample
EntityA real-world objectStudent
AttributeA propertyname, roll_no
RelationshipAssociation between entitiesStudent enrolls in Course
Cardinality1:1, 1:N, M:NOne teacher teaches many courses

A many-to-many relationship becomes its own table in the relational model:

enrollment.sql
CREATE TABLE enrollment (
student_id INT REFERENCES student(id),
course_id INT REFERENCES course(id),
grade CHAR(2),
PRIMARY KEY (student_id, course_id)
);

Types of databases​

  • Relational (PostgreSQL, MySQL): tables and SQL.
  • Document (MongoDB), key-value (Redis), wide-column (Cassandra), graph (Neo4j).