Skip to content
Chethan Yadav_
Database Management Systems

DBMS/Lesson 1 of 9/4 min read

Introduction to DBMS

What a DBMS is, file system vs DBMS, data models, three-schema architecture, data independence, SQL language categories, and DBMS architectures.


On this page

What is a Database and a DBMS

A database is an organized collection of related data. A Database Management System (DBMS) is software that stores, retrieves, updates and manages that data while providing concurrency, security and recovery. Examples: PostgreSQL, MySQL, Oracle, SQL Server, MongoDB.

A database system = database + DBMS + applications.

File System vs DBMS

Before databases, applications stored data in flat files. Problems that DBMS solves:

Problem with filesHow a DBMS solves it
Data redundancy and inconsistencyCentral storage, normalization
Difficult data access (new query = new program)Declarative query language (SQL)
Data isolation (many formats)Single data model
Integrity problems (rules buried in code)Constraints: keys, checks, foreign keys
Atomicity problems (crash mid-update)Transactions with ACID
Concurrent access anomaliesConcurrency control and locking
Security problemsUsers, roles, privileges

DBMS downsides: cost, complexity, overhead for very simple apps.

Data Model

A data model is a set of concepts to describe data, relationships, semantics and constraints.

  • Hierarchical: tree of records (IBM IMS).
  • Network: graph of records (CODASYL).
  • Relational: tables of rows and columns (Codd, 1970). Dominant model.
  • Entity-Relationship: conceptual design model (see ER model).
  • Object-oriented / object-relational: objects with methods; PostgreSQL is object-relational.
  • Document, key-value, column-family, graph: NoSQL models (see NoSQL).

Schema and Instance

  • Schema: the design or structure of the database (table definitions, types, constraints). Changes rarely. Like a class definition.
  • Instance: the data in the database at a particular moment. Changes constantly. Like an object's current state.

Three-Schema Architecture

ANSI/SPARC architecture separates user views from physical storage:

 External level   (views for each user / application)
        |  external/conceptual mapping
 Conceptual level (logical schema: tables, relationships, constraints)
        |  conceptual/internal mapping
 Internal level   (physical schema: files, indexes, storage layout)
  • External (view) level: what a particular user sees; hides other data.
  • Conceptual (logical) level: what data is stored and the relationships, for the whole database.
  • Internal (physical) level: how data is stored: file organization, indexes, compression.

Data Independence

The ability to change the schema at one level without changing the level above.

  • Physical data independence: change internal storage (add an index, move to SSD, change file organization) without changing the conceptual schema or applications. Easy to achieve.
  • Logical data independence: change the conceptual schema (add a column, split a table) without changing external views or applications. Harder to achieve.

Database languages

DDL

Data Definition Language defines structure: CREATE, ALTER, DROP, TRUNCATE, RENAME.

DML

Data Manipulation Language works with data: SELECT, INSERT, UPDATE, DELETE. Some books put SELECT in a separate DQL (Data Query Language).

DCL

Data Control Language manages permissions: GRANT, REVOKE.

TCL

Transaction Control Language manages transactions: COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION.

Classic question: DELETE vs TRUNCATE vs DROP. DELETE is DML, removes chosen rows, can be rolled back and fires triggers. TRUNCATE is DDL, removes all rows quickly, resets storage, usually cannot be rolled back (in some databases it can, inside a transaction) and does not fire row triggers. DROP removes the table structure itself.

DBMS architecture

  • 1-tier: user works directly on the database (a DBA at a console, SQLite in an app).
  • 2-tier: client application talks directly to the database server (desktop apps with ODBC/JDBC).
  • 3-tier: client, application server, database server. The app server holds business logic; the client never touches the database directly. Standard for web apps and more secure and scalable.

Components of a DBMS

  • Query processor: parser, optimizer (chooses the cheapest execution plan), executor.
  • Storage manager: buffer manager, file manager, transaction manager, lock manager.
  • Recovery manager: logging and crash recovery.
  • Catalog (data dictionary): metadata about tables, columns, indexes, users.

Database users

  • DBA (Database Administrator): schema definition, storage, security, backups, tuning.
  • Application programmers: write programs that use the database.
  • End users: casual (ad hoc queries), naive (use forms and apps), sophisticated (analysts).

Quick revision

  • DBMS fixes redundancy, integrity, atomicity, concurrency and security problems of files.
  • Three levels: external, conceptual, internal.
  • Physical independence is easy, logical independence is hard.
  • DDL structure, DML data, DCL permissions, TCL transactions.