Free Study Material

Database Concepts & The Need for DBMS

Introduction

This unit moves from Python into a different way of working with data — one built specifically to store, organise, and retrieve large amounts of it reliably. That's what a database is for.

Concept

A database is an organised collection of related data, stored so it can be efficiently accessed, managed, and updated. A Database Management System (DBMS) is the software that actually creates, maintains, and controls access to a database.

Storing data in plain files (like a spreadsheet per class) instead of a real database creates real problems at scale:

  • Data Redundancy — the same data repeated in multiple places, wasting space and risking inconsistency.
  • Data Inconsistency — the same fact stored in two places disagreeing after only one copy gets updated.
  • Difficulty in Data Access — no organised way to search or filter large amounts of data quickly.
  • Lack of Data Integrity & Security — no built-in way to enforce rules on data, or control who can access it.

A DBMS exists specifically to solve all four.

Explanation

Redundancy and inconsistency are closely linked, not two unrelated problems: redundancy (the same fact stored twice) is exactly what makes inconsistency possible in the first place — if a student's address is stored in only one place, it can never disagree with itself; stored in three separate files, updating only one of them creates exactly that disagreement.

Note: A DBMS doesn't just store data — it actively manages it: enforcing rules, controlling access, and keeping data consistent, none of which a plain file on its own does automatically.

Summary

A database is an organised collection of related data; a DBMS is the software managing it. Storing data in plain files instead risks redundancy, inconsistency, difficult access, and weak integrity/security — the exact four problems a DBMS is built to solve.

1. Introduction to Databases

A Database is an organized, structured collection of data. In the modern world, every "smart" action—from booking a flight to checking your Instagram feed—involves interacting with a database. Unlike a simple document, a database is designed to handle thousands of users and millions of records simultaneously.

Key Characteristics:

  • Persistence: Data remains in the system even after the power is turned off.
  • Self-Describing: A database contains both the data and the Metadata (definitions of the data).
  • Multi-user Access: Many people can read or write data at the same time without causing errors.

Why we moved away from File Systems

In the early days of computing, data was stored in simple flat files (like Text or CSV files). However, as data grew, several major problems emerged. These problems are exactly what a Database solves.

Problem Type Description & Real-world Impact
Data Redundancy Duplicate data is stored in multiple files.
Example: A student's address is stored in the "Library File" and the "Fees File" separately. This wastes disk space.
Data Inconsistency When redundant data is updated in one place but not the other.
Example: A student changes their phone number in the Library, but the Fees department still has the old number.
Data Isolation Data is trapped in different formats. It is very difficult to write a program to extract data from multiple files at once.
Security Issues In a file system, you can either access the whole file or nothing. You cannot restrict a user to only seeing certain rows or certain columns.

What is a DBMS?

A Database Management System (DBMS) is the software "Gatekeeper." It sits between the user and the raw data stored on the disk.

Think of it this way: If the Database is the Library, the DBMS is the Librarian who helps you find, add, or remove books securely.

Key Functions of a DBMS:

Data Dictionary: Stores definitions of data elements and their relationships.
Concurrency Control: Prevents two people from changing the same record at the exact same millisecond.
Recovery: Ensures data is not lost if the power fails or the system crashes.
Integrity: Enforces rules (e.g., "Salary cannot be negative").

Introduction

The most widely used way to organise a database is the relational model — the one this entire unit's SQL chapter is built on. This topic names its core vocabulary.

Concept

In the Relational Model, data is organised into tables (also called relations). CBSE's precise terminology:

  • Table (Relation) — a two-dimensional grid of rows and columns holding one kind of data (e.g., a STUDENT table).
  • Row (Tuple) — one single record — one student's complete set of data.
  • Column (Attribute / Field) — one specific property shared by every row (e.g., Name, Marks).
  • Domain — the set of all valid values a specific column is allowed to hold (a Marks column's domain might be whole numbers from 0 to 100).
  • Degree — the number of columns (attributes) in a table.
  • Cardinality — the number of rows (tuples) in a table.

Worked Example

A STUDENT table:

RollNoNameMarks
1Aisha91
2Rahul78
3Meera85

This table has a Degree of 3 (three columns: RollNo, Name, Marks) and a Cardinality of 3 (three rows). Each row is one Tuple — Aisha's entire record is one Tuple. Name is one Attribute.

Note: CBSE exams frequently ask for Degree and Cardinality directly from a shown table — Degree counts columns, Cardinality counts rows. Mixing the two up is a common, easily-avoided mistake.

Explanation

Every one of these terms has an everyday synonym (Table/Relation, Row/Tuple, Column/Attribute) — CBSE uses both interchangeably, so recognise either name for the same thing, since a question may use either term for the same concept.

Summary

The Relational Model organises data into Tables (Relations), made of Rows (Tuples) and Columns (Attributes/Fields). A column's Domain is its set of valid values; a table's Degree is its column count, and its Cardinality is its row count.

2. The Relational Data Model

In a Relational Model, data is organized into two-dimensional tables called Relations. Each relation consists of rows and columns. This structure is preferred because it is intuitive, easy to manage, and allows for complex querying using SQL.

Concept of a Table (Relation):

A table represents an Entity (like a Student, Product, or Employee). Each column represents a Property of that entity, and each row represents a Specific Instance of that entity.

The Anatomy of a Relation

While we commonly use terms like "Rows" and "Columns," the technical relational model uses specific scientific terms that appear in exams:

Term Detailed Definition Common Name
Tuple A single horizontal entry in a table representing a unique record. Row / Record
Attribute A vertical heading in a table representing a specific characteristic. Column / Field
Domain The set of all permissible atomic values that an attribute can take.
Example: If 'Gender' can only be 'M' or 'F', then {'M', 'F'} is the Domain.
Value Set
Degree The total number of Attributes (columns) in the relation. Column Count
Cardinality The total number of Tuples (rows) in the relation. Row Count

Example Analysis: The "Student" Table

Consider a table with Admn_No, Name, Age, Class.

Degree Check:
Since there are 4 columns (Admn_No, Name, Age, Class), the Degree is 4.
Domain Check:
If the 'Age' column only accepts numbers between 5 and 18, that range is its Domain.

Introduction

The STUDENT table from the last topic needs a reliable way to identify one exact row out of many. This topic covers the keys that do that.

Concept

  • Candidate Key — any column (or minimal combination of columns) that can, on its own, uniquely identify every row in a table. A table can have more than one Candidate Key.
  • Primary Key — the one Candidate Key actually chosen to uniquely identify rows in practice. It can never be NULL (empty), and its value must never repeat.
  • Alternate Key — every Candidate Key that was not chosen as the Primary Key.

Worked Example

In the STUDENT table (RollNo, Name, Marks), suppose both RollNo and an Email column (not shown above, but imagine it added) could each uniquely identify a student. Both RollNo and Email are Candidate Keys. If RollNo is chosen to actually enforce uniqueness, it becomes the Primary Key, and Email — still a valid Candidate Key, just not the chosen one — becomes an Alternate Key.

Note: Every Primary Key is also a Candidate Key (it was chosen from the candidates) — but not every Candidate Key is a Primary Key, since only one candidate can be chosen.

Explanation

The relationship between these three terms is really about narrowing down: Candidate Key is the broad category of "anything that could uniquely identify a row"; Primary Key is the one specific choice actually enforced; Alternate Key is simply "candidate, but not the chosen one" — three labels for three positions in the same one decision, not three unrelated concepts.

Summary

A Candidate Key is any column (or combination) that could uniquely identify a row; the Primary Key is the one Candidate Key actually chosen, and can never be NULL or repeat; every other Candidate Key becomes an Alternate Key.

3. Understanding Database Keys

In a table with thousands of records, we need a way to distinguish one row from another. A Key is an attribute (column) or a group of attributes that uniquely identifies a tuple (row) in a relation. Keys ensure that no two rows are identical, maintaining Data Integrity.

The Problem: Duplicate Names

In a 'Customer' table, two people might be named "Rajesh Sharma". If we want to update the balance for only one of them, we cannot use the name as a filter. We need a unique Customer_ID. This ID acts as the Key.

Types of Relational Keys

There is a specific relationship between Candidate, Primary, and Alternate keys. Think of it as a selection process for a sports team: many are eligible, but only one is chosen as the captain.

Key Type Technical Definition & Exam Rules
Candidate Key Any attribute or set of attributes that can uniquely identify a tuple.
Rule: A table can have multiple candidate keys.
Example: Admission_No, Aadhaar_Card, and Roll_No.
Primary Key The specific Candidate Key selected by the designer to uniquely identify rows.
Rule 1: It cannot be NULL.
Rule 2: It must be unique for every row.
Rule 3: There can be only ONE Primary Key per table.
Alternate Key A Candidate Key that was not chosen as the Primary Key.
Logic: Alternate Key = Candidate Keys - Primary Key

Case Study: Logical Selection

Imagine a Student table with these columns: [Admn_No, Roll_No, Name, Email, Phone]

Step 1: Identify Candidates
Admn_No, Roll_No, Email, and Phone are all unique. They are all Candidate Keys.
Step 2: Choose Primary
The school chooses Admn_No as the Primary Key because it never changes.
Step 3: Define Alternates
The remaining unique columns (Roll_No, Email, Phone) are now the Alternate Keys.

Want the full course?

Unlock all chapters, video lectures, and SQL practice exercises.

Get Full Access