Loading notes...
Loading notes...
Class 12 • Chapter 8
Databases (RDBMS) organize data into tables, using unique Keys to ensure data integrity and define relationships between records.
A database is a structured collection of data that can be easily accessed, managed, and updated. Before databases, data was stored in individual 'Flat Files,' which often led to data redundancy (the same data being repeated in different files) and data inconsistency (the same data being different in different places). A **DBMS (Database Management System)** is the software that acts as an interface between the user and the data, providing a secure and efficient way to handle large datasets. By centralizing data, databases eliminate repetition and ensure that information remains accurate across all parts of an organization, from student records in a school to financial transactions in a global bank.
The most common way to organize a database is the **Relational Model**, where data is stored in 'Tables' (also called 'Relations'). Each table is a grid made of rows and columns. A **Row (Tuple)** represents a single, complete record (e.g., all data for one student), while a **Column (Attribute)** represent a specific data field (e.g., just the students' names). The number of attributes is called the **Degree**, and the number of tuples is called the **Cardinality**. In a Relational Database (RDBMS), these tables are linked through shared values, allowing for complex queries across multiple related datasets.
Keys are the fundamental tools used to uniquely identify records and establish relationships between tables. A **Primary Key** is a unique attribute (or set of attributes) that identifies each row in a table— it cannot be null and cannot be repeated. A **Candidate Key** is any attribute that has the potential to be a primary key because every value is unique. An **Alternate Key** is a candidate key that was not chosen as the primary key. Finally, the **Foreign Key** is an attribute in one table that refers to the primary key of another table, creating a bridge (or relationship) between them that maintains 'Referential Integrity'.
Referential integrity is a strict rule that ensures the relationship between tables remains consistent. It dictates that every value in a Foreign Key column must have a matching value in the Primary Key column of the related table (or be null if permitted). This prevents 'orphaned' records—for example, it prevents you from adding a student to a class ID that doesn't exist, or from deleting a teacher if they are still assigned to active modules. This layer of protection is what makes relational databases significantly more powerful and reliable than simple flat-file storage.