What is a database?

Database vs file systems, redundancy, integrity, confidentiality, and what a DBMS does.

Beginner 28 min read SQLDatabaseDBMS
Lesson 1 / 7 0%
View path

SQL intro — before the first query

Before we write a single SQL statement, a few basics must be clear. If the difference between Data, Database, DBMS, and SQL is solid from the start, the rest of SQL gets much easier.

Every example in this lesson uses a fictional university.

1. What is the difference between data and information?

Data

Data is a raw fact.

For example:

text
Sara
09121234567
Tehran
18.5

On their own, these are only data.

But if we say:

text
نام دانشجو: Sara
شماره تلفن: 09121234567
شهر: Tehran
معدل: 18.5

The data now has meaning.

Information

Information is data that has meaning in a specific context and can be used.

Simply:

Data = a raw fact
Information = data that has gained meaning
2. What is a database?

The more common computer-science term for Database is “database” (پایگاه داده in Persian).

Some Persian sources also say “بانک اطلاعاتی”, but this lesson uses پایگاه داده.

Simple definition

A database is an organized collection of related data, kept so we can store, manage, and retrieve information.

A university might keep:

  • students
  • teachers
  • courses
  • enrollments
  • grades

These facts are related. For example:

text
دانشجو ← یک درس را انتخاب می‌کند
درس ← توسط یک استاد ارائه می‌شود
دانشجو ← برای آن درس نمره می‌گیرد

That related set of data can live in one database.

3. Table, row, and column

In SQL we usually work with a relational database.

Related data is typically stored in a table.

For example, a students table:

text
students

id | name | city
-----------------
1  | Sara | Tehran
2  | Ali  | Shiraz
3  | Reza | Tabriz

Three important terms:

Table

The whole structure above is a table. For example:

text
students

Row

Each row usually represents one entity or record. For example:

text
1 | Sara | Tehran

That row is one student.

Another common word: record.

Column

Each column holds one attribute. For example:

text
name
city

So:

text
Table  → students
Row    → یک دانشجو
Column → یک ویژگی دانشجو
4. Is a database only one table?

No. This is an important mistake.

A database is not a table.

One database may contain hundreds of tables.

For example, a university database:

text
university_database

students
teachers
courses
enrollments
grades
departments

So:

A table is part of a database.

For example:

text
Database
   │
   ├── students
   ├── teachers
   ├── courses
   └── grades
5. How was information stored before databases?

Imagine the university has no database. The education office has a file:

text
students.xlsx

Inside it:

text
Sara | 0912... | Tehran
Ali  | 0913... | Shiraz

The exams office has its own file:

text
grades.xlsx

And student details are written again:

text
Sara | 0912... | Tehran | Database | 18

Finance has another file:

text
payments.xlsx

And again:

text
Sara | 0912... | Tehran | Paid

Sara’s information now exists in three places.

This approach is usually called a file-based system.

6. What do “banking” and “non-banking” systems mean?

Some notes may say:

text
سیستم بانکی
سیستم غیر بانکی

They usually mean:

Non-banking system

That is a file-based system.

Data lives in separate files. For example:

text
آموزش        → students.xlsx
امتحانات     → grades.xlsx
امور مالی    → payments.xlsx

Banking system

The more precise term is a database system.

Data is managed in one database.

text
              Database
                 ▲
                 │
        ┌────────┼────────┐
        │        │        │
      آموزش    امتحانات   مالی

Applications do not each manage their own separate file.

7. What is the problem with a file system?

Suppose Sara’s city is stored in three files:

text
students.xlsx  → Tehran

grades.xlsx    → Tehran

payments.xlsx  → Tehran

Sara moves from Tehran to Isfahan. Education updates its file:

text
students.xlsx → Isfahan

But exams forgets:

text
grades.xlsx → Tehran

Now the system has two answers about one student:

text
آموزش: اصفهان

امتحانات: تهران

This is one of the most important file-system problems.

8. What is redundancy?

English term: redundancy.

It means:

The same fact is stored more than once, without needing to be.

For example:

text
Sara | Tehran

stored in three different files. That is redundancy.

The main problem is not only extra space. The copies can drift apart.

9. What is data inconsistency?

Term: data inconsistency.

For example:

text
File A → Sara → Tehran
File B → Sara → Isfahan

Both talk about the same person, but the facts differ.

So we have an important relationship:

text
Redundancy
     ↓
احتمال ایجاد
     ↓
Data Inconsistency

That is: redundancy can cause data inconsistency.

10. Does a database remove redundancy completely?

No. Learn this sentence carefully:

A database system usually controls and reduces unnecessary redundancy. It does not delete every repeated value in every case.

Sometimes data is repeated on purpose for technical reasons.

So do not say a database has no duplicate data. Say it helps control unnecessary redundancy.

11. What is data integrity?

Term: data integrity.

Data in the system must be valid, follow the rules, and keep logical relationships.

The university says:

text
0 <= grade <= 20

So:

text
grade = 18

is valid. But:

text
grade = 150

is not valid.

Integrity examples

Example 1

text
age = -25

That is illogical.

Example 2

A student tries to enroll in a course that does not exist:

text
course_id = 900

But course 900 is not in the course table. That value must be rejected.

Example 3

A national ID must be unique. We do not want:

text
Sara → 0012345678

Ali → 0012345678

A DBMS can prevent this.

12. Important kinds of integrity

We will learn these more precisely in SQL. For now, just know the names.

Domain integrity

A column value must stay in a valid range. For example:

text
grade between 0 and 20

Entity integrity

Every record must be identifiable. Each student has a unique id.

text
id = 1 → Sara
id = 2 → Ali

Referential integrity

Links between tables must be valid. If we say:

text
student_id = 25

a student with id=25 must actually exist.

13. What is confidentiality?

Term: confidentiality.

It means:

Information is available only to people who are allowed to see it.

At a university a student may see:

text
نمرات خودش

but must not see:

text
نمرات تمام دانشجویان

An education clerk may see:

text
اطلاعات ثبت‌نام

but should not necessarily see:

text
حقوق استادان
14. Confidentiality is not the same as integrity

Do not mix these two.

Integrity

The question is:

Is the data correct and valid?

For example:

text
grade = 150

has an integrity problem.

Confidentiality

The question is:

Who is allowed to see the data?

A student who sees another student’s grades has a confidentiality problem.

So:

text
Integrity
→ درست بودن داده

Confidentiality
→ مجاز بودن دسترسی
15. Now the DBMS enters

Term: Database Management System (DBMS).

A DBMS is software that manages the database.

A simple picture:

text
User / Application
        │
        ▼
      DBMS
        │
        ▼
    Database

The application usually talks to the data through the DBMS.

16. Database and DBMS are not the same

This is one of the most important points.

Database

The data itself.

DBMS

The software that manages that data.

An analogy:

text
Database = کتاب‌های کتابخانه

DBMS = کتابدار

The books hold the information. The librarian decides where a book is, who may take it, who may access it, and how it is recorded.

17. What does a DBMS do?

The main jobs:

1. Storage

Store data

2. Retrieval

Fetch data. For example:

text
دانشجویان تهران را نشان بده.

3. Insert

Add data

4. Update

Change data

5. Delete

Remove data

6. Integrity

Enforce validity rules

7. Security / access control

Control who can do what

8. Concurrency control

Handle many users at once

9. Backup & recovery

Back up and restore data

18. What is concurrency?

Term: concurrency.

Many users work with the system at almost the same time.

Imagine course registration. A thousand students are in the system at once.

text
Student A → انتخاب درس
Student B → انتخاب درس
Student C → حذف درس
...

The DBMS must keep these operations from corrupting the data.

19. Well-known DBMS products

You will see these names often:

text
MySQL
PostgreSQL
Microsoft SQL Server
Oracle Database
SQLite

These are database management systems.

More precisely, most of them are relational database management systems (RDBMS).

20. What is an RDBMS?

RDBMS means Relational Database Management System.

It manages relational data, usually as tables and the links between them. For example:

text
students
courses
enrollments

and they are related.

21. So what is SQL?

SQL means Structured Query Language.

SQL is neither a database nor a DBMS. It is a language.

We use SQL to tell the DBMS what to do. For example:

sql
SELECT * FROM students;

In plain words:

Show me all students.
22. How SQL, DBMS, and database relate

Keep this picture in mind:

text
          SQL
           │
           ▼
User → DBMS → Database

You write:

sql
SELECT * FROM students;

The DBMS receives the command, looks in the database, and returns the result.

23. A complete example

Suppose our database has this table:

text
students

id | name | city
------------------
1  | Sara | Tehran
2  | Ali  | Shiraz
3  | Reza | Tehran

You tell the DBMS:

sql
SELECT *
FROM students
WHERE city = 'Tehran';

The DBMS checks the data and returns:

text
1 | Sara | Tehran
3 | Reza | Tehran

So:

text
Database
→ داده‌ها را دارد

DBMS
→ داده‌ها را مدیریت می‌کند

SQL
→ زبانی است که با DBMS صحبت می‌کنیم
24. Never mix these four terms
TermSimple meaning
Dataraw fact
Databaseorganized collection of data
DBMSsoftware that manages the database
SQLlanguage for talking to a relational DBMS

Example:

text
Sara, Tehran
      ↓
     Data

students table
      ↓
   Database

PostgreSQL
      ↓
     DBMS

SELECT ...
      ↓
      SQL
25. File-based system problems

Now we can say more clearly why databases were created.

A file system can have problems like:

  • Data redundancy
  • Data inconsistency
  • Difficult data sharing
  • Weak integrity control
  • Weak access control
  • Concurrency problems
  • Difficult backup and recovery

A DBMS was built to manage these issues better.

26. Mental map of the whole lesson

Learn this part well:

text
Data
 │
 ▼
Database
 │
 │ managed by
 ▼
DBMS
 ▲
 │
SQL
 ▲
 │
User / Application

And from the other side:

text
File-Based System
        │
        ├── Redundancy
        ├── Inconsistency
        ├── Integrity Problems
        └── Access Problems

                ↓

        Database System
                +
              DBMS
27. University example, summarized

Suppose we have:

text
Student:
Sara
Student ID: 1001
City: Tehran

If Sara’s data is stored in five separate files:

text
students.xlsx
grades.xlsx
payments.xlsx
library.xlsx
dormitory.xlsx

First problem: redundancy — the data is repeated.

If one file changes and the others do not: inconsistency.

If someone enters:

text
grade = 150

Problem: integrity.

If a student can see everyone’s grades: confidentiality / access control.

We use a DBMS to manage this better, and SQL to talk to a relational DBMS.

28. Important terms from this lesson

Learn these words in both Persian and English:

text
Data
داده

Information
اطلاعات

Database
پایگاه داده

Table
جدول

Row
سطر / رکورد

Column
ستون

File-Based System
سیستم مبتنی بر فایل

Database System
سیستم پایگاه داده

Redundancy
افزونگی

Data Inconsistency
ناسازگاری داده

Integrity
جامعیت داده

Confidentiality
محرمانگی

Access Control
کنترل دسترسی

Concurrency
هم‌زمانی

DBMS
سیستم مدیریت پایگاه داده

RDBMS
سیستم مدیریت پایگاه داده رابطه‌ای

SQL
زبان پرس‌وجوی ساخت‌یافته
29. A few questions to check you learned it

Question 1

A student’s data is stored in three different files. What is the problem?

A) Integrity
B) Redundancy
C) Confidentiality

Answer: B — Redundancy

Question 2

One file says the city is Tehran and another says Isfahan. What is the problem?

Data inconsistency

Question 3

A student has grade 125 but grades must be between 0 and 20. What is the problem?

Integrity

Question 4

Ali can see Sara’s grade without permission. What is the problem?

Confidentiality / access control

Question 5

What is PostgreSQL?

A) Database
B) DBMS
C) SQL

Answer: B

Question 6

What is SQL?

A language for working with relational database management systems.

30. The most important takeaway

If you fully understand these four lines, you have the lesson:

Database is where data is kept in an organized way.
DBMS is the software that manages the database.
SQL is the language we use to ask the DBMS to do work.
RDBMS is a kind of DBMS that manages relational data and tables.

For example:

text
PostgreSQL → RDBMS

university database → Database

students → Table

SELECT * FROM students; → SQL

Almost every later SQL lesson is built on this foundation.