Computer Databases

A database is an organized collection of data stored so that programs can find, add, change, and remove information quickly. School records, bank accounts, online shopping catalogs, and social media profiles all live in databases. A paper filing cabinet offers a good comparison. A database works like a super-fast filing cabinet that locates any folder in a fraction of a second.

Why Not Use a Simple File?

A plain text file works for a short list. Problems arrive as data grows. Searching becomes slow, duplicate entries multiply, and two people editing at the same time overwrite each other. A database solves these problems with structure, rules, and speed.

Tables, Rows, and Columns

Relational databases store data in tables. A table looks like a spreadsheet grid. Each column describes one property, called a field. Each row holds one complete record.

Table: Students

StudentID | Name     | Class | City
----------+----------+-------+---------
101       | Aman     | 8     | Delhi
102       | Sara     | 9     | Mumbai
103       | Ravi     | 8     | Pune

Primary Key

A primary key is a field that identifies each row uniquely. StudentID works as a primary key because no two students share the same number. Two students can share the same name, so the name makes a poor key.

Relationships Between Tables

Good databases split data into several tables and link them. This approach avoids repeating information. A foreign key in one table points to the primary key in another table.

Students                      Marks
StudentID (PK)  Name          MarkID  StudentID (FK)  Subject  Score
101             Aman          1       101             Math     88
102             Sara          2       102             Math     92
                              3       101             Science  79

Marks.StudentID ───────► Students.StudentID

Aman's name appears once in the Students table. The Marks table refers to him by number. A name correction then happens in one place only.

What Is a DBMS

A Database Management System (DBMS) is the software that creates, stores, and controls databases. MySQL, PostgreSQL, SQLite, Oracle Database, and Microsoft SQL Server are well-known examples. Applications talk to the DBMS, and the DBMS talks to the stored data.

User → Application → DBMS → Database files on disk
                       ↑
          Security, speed, backup, and rules

The Four Basic Operations

Almost every database task falls into one of four actions, known as CRUD.

C  Create   Add a new record
R  Read     Find and view records
U  Update   Change an existing record
D  Delete   Remove a record

SQL: The Language of Databases

Structured Query Language (SQL) lets people give instructions to relational databases. The commands read almost like English.

SELECT Name FROM Students WHERE Class = 8;
→ Aman
→ Ravi

INSERT INTO Students VALUES (104, 'Meera', 9, 'Jaipur');

UPDATE Students SET City = 'Pune' WHERE StudentID = 102;

DELETE FROM Students WHERE StudentID = 103;

Types of Databases

  • Relational: Tables linked by keys. Banks and schools use them for accurate records.
  • NoSQL: Flexible stores for documents, key-value pairs, or graphs. Social media and large web services use them for huge, changing data.
  • Cloud databases: Hosted on remote servers that the provider maintains.
  • In-memory databases: Keep data in RAM for extremely fast access.

Key Features of a Good Database

  • Accuracy: Rules reject wrong or duplicate data.
  • Speed: Indexes work like a book index and find records without scanning every row.
  • Security: Passwords and permissions decide who reads or changes data.
  • Backup: Regular copies protect against loss.
  • Multi-user access: Many people work at the same moment without conflicts.

Everyday Examples

Online store   → Products, customers, orders
Hospital       → Patients, doctors, appointments
School         → Students, teachers, marks
Streaming app  → Users, videos, watch history

Normalization in Simple Words

Designers split data into tables to avoid repetition. This process, called normalization, stores each fact once. A customer address typed into fifty order rows invites errors, because one row may receive the update while forty-nine keep the old address. Storing the address once in a customer table solves the problem. Clean design keeps data accurate and the database small.

Transactions

A transaction groups several steps into one unit that either completes fully or does not happen at all. A bank transfer subtracts money from one account and adds it to another. The database applies both steps together, or it applies neither. This rule protects the data from half-finished actions.

Key Takeaways

  • A database stores organized data for fast, safe access.
  • Tables hold rows and columns, and keys link the tables.
  • A DBMS manages the data, and SQL gives it instructions.
  • Relational and NoSQL types serve different needs.