Lesson 6 of 60 – Database Concepts
10%

Database Concepts

A database is an organized collection of data that allows information to be stored, managed, searched, updated, and retrieved efficiently. Databases are used in websites, mobile applications, banking systems, schools, hospitals, businesses, and many other applications.

Note: SQL is commonly used to communicate with relational databases and perform operations on the data stored inside them.

1. What is a Database?

A database is an organized collection of information stored electronically so that it can be easily accessed and managed.

For example, a school database may contain information about:

  • Students
  • Teachers
  • Courses
  • Attendance
  • Examinations
  • Fees

Instead of maintaining this information in separate paper files, a database can store it in a structured form.

2. Why Do We Need Databases?

Applications can contain thousands or millions of records. Managing such information manually becomes difficult.

Databases help us to:

  • Store large amounts of data
  • Search data quickly
  • Update existing information
  • Delete unwanted information
  • Organize related data
  • Control access to information
  • Generate reports

3. Example of a Student Database

Suppose a coaching institute wants to store student information. A database may contain a table called students.

ID Name Course Mobile
101 Rahul Python 9876543210
102 Priya SQL 9876543211
103 Amit Java 9876543212

This table contains structured student information that can be searched and managed using SQL.

4. Database Table

A relational database stores information in tables. A table consists of rows and columns.

For example:

students
--------------------------------
id | name  | course | age
--------------------------------
1  | Rahul | Python | 21
2  | Priya | SQL    | 22
3  | Amit  | Java   | 20

Here, students is the table name.

5. Row

A row represents one complete record in a table.

For example:

1 | Rahul | Python | 21

The above line represents one student's record.

Rows are also commonly called records.

6. Column

A column represents a particular type of information stored for each record.

For example, the following are columns:

  • id
  • name
  • course
  • age

Columns are also called fields in many database contexts.

7. Database Record

A record is a collection of related values representing one entity or item.

Example:

ID: 101
Name: Rahul
Course: Python
Age: 21

All these values together represent one student record.

8. Database Schema

A database schema describes the structure of a database. It can include tables, columns, relationships, constraints, and other database objects.

For example, a college database may contain:

  • students
  • teachers
  • courses
  • fees
  • attendance

The design and relationships among these objects form part of the database schema.

9. Database Management System

A Database Management System (DBMS) is software used to create, store, organize, retrieve, and manage data in databases.

Examples include:

  • MySQL
  • PostgreSQL
  • Oracle Database
  • Microsoft SQL Server
  • SQLite

10. Relational Database

A relational database organizes data into tables and allows relationships to be established between related tables.

For example, an application may have:

  • students table
  • courses table
  • payments table

These tables can be related using common columns and keys.

11. Primary Key

A primary key uniquely identifies each record in a table.

For example, the id column can be used as a primary key in a students table.

id | name
---|------
1  | Rahul
2  | Priya
3  | Amit

Each student can have a unique ID.

12. Foreign Key

A foreign key is used to create a relationship between tables by referring to a key in another table.

For example, a payments table can contain a student_id that refers to the ID of a student.

students
id | name

payments
id | student_id | amount

This allows payment records to be associated with students.

13. Database Relationships

Relationships define how data in different tables is connected.

Common relationship types include:

  • One-to-One
  • One-to-Many
  • Many-to-Many

Relationships help organize related information and reduce unnecessary duplication.

14. One-to-One Relationship

In a one-to-one relationship, one record in one table is associated with one record in another table.

For example, one employee may have one employee profile record in another table.

15. One-to-Many Relationship

In a one-to-many relationship, one record can be associated with many records in another table.

For example, one customer can place many orders.

Customer
   |
   |---- Order 1
   |---- Order 2
   |---- Order 3

16. Many-to-Many Relationship

In a many-to-many relationship, many records in one table can be related to many records in another table.

For example, students can enroll in multiple courses, and each course can have multiple students.

A separate junction or linking table is commonly used to represent this relationship.

17. Database Query

A query is a request made to a database to retrieve or manipulate information.

Example:

SELECT * FROM students;

This query requests all columns and rows from the students table.

18. CRUD Operations

CRUD represents four basic operations commonly performed on stored data.

Operation Meaning SQL Example
Create Add new data INSERT
Read Retrieve data SELECT
Update Modify data UPDATE
Delete Remove data DELETE

19. Database Security

Database security protects stored information from unauthorized access, modification, or deletion.

Common security practices include:

  • Strong authentication
  • User permissions
  • Access control
  • Regular backups
  • Secure connections
  • Parameterized queries

20. Database Backup

A database backup is a copy of database information that can be used to restore data if the original data is lost or damaged.

Regular backups are important for applications containing valuable information such as customer records, payments, and business data.

21. Database Normalization

Normalization is a database design technique used to organize data and reduce unnecessary duplication.

Instead of storing the same information repeatedly, related information can be separated into appropriate tables and connected using keys.

Common normal forms include:

  • First Normal Form (1NF)
  • Second Normal Form (2NF)
  • Third Normal Form (3NF)

22. Database Index

An index is a database object that can help the database find rows more efficiently for suitable queries.

Indexes can improve query performance, but they also require additional storage and can add overhead to data modification operations.

23. Database Transaction

A transaction is a sequence of database operations that are treated as a logical unit of work.

For example, a banking transaction may involve multiple related database operations that should be completed consistently.

Common transaction commands include:

  • COMMIT
  • ROLLBACK

24. Database and Application

A typical application works with a database through a backend program.

User
  ↓
Frontend
  ↓
Backend
  ↓
SQL Query
  ↓
Database
  ↓
Result
  ↓
Backend
  ↓
Frontend

This basic flow is used in many data-driven applications.

25. Important Database Terms

Term Meaning
Database Organized collection of data
Table Structure used to store related data
Row One record in a table
Column A field representing a type of data
Primary Key Uniquely identifies a record
Foreign Key Connects related tables
Query Request sent to a database
Schema Structure of a database
DBMS Software used to manage databases

📌 Key Points

  • A database is an organized collection of data.
  • Relational databases store data mainly in tables.
  • A table contains rows and columns.
  • A row represents a record.
  • A column represents a field or attribute.
  • Primary keys uniquely identify records.
  • Foreign keys help establish relationships between tables.
  • SQL queries are used to retrieve and manipulate database data.
  • CRUD stands for Create, Read, Update, and Delete.
  • Database security and backups are important for protecting data.

🧠 Quick Quiz

Question: What is a row in a relational database table?