Free Study Material
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.
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:
A DBMS exists specifically to solve all four.
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.
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.
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.
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.
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.
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.
In the Relational Model, data is organised into tables (also called relations). CBSE's precise terminology:
STUDENT table).Name, Marks).Marks column's domain might be whole numbers from 0 to 100).A STUDENT table:
| RollNo | Name | Marks |
|---|---|---|
| 1 | Aisha | 91 |
| 2 | Rahul | 78 |
| 3 | Meera | 85 |
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.
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.
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.
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.
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.
While we commonly use terms like "Rows" and "Columns," the technical relational model uses specific scientific terms that appear in exams:
Consider a table with Admn_No, Name, Age, Class.
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.
NULL (empty), and its value must never repeat.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.
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.
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.
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.
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.
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.
Imagine a Student table with these columns: [Admn_No, Roll_No, Name, Email, Phone]