What is a database?
Database vs file systems, redundancy, integrity, confidentiality, and what a DBMS does.
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:
Sara
09121234567
Tehran
18.5On their own, these are only data.
But if we say:
نام دانشجو: Sara
شماره تلفن: 09121234567
شهر: Tehran
معدل: 18.5The 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:
دانشجو ← یک درس را انتخاب میکند
درس ← توسط یک استاد ارائه میشود
دانشجو ← برای آن درس نمره میگیرد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:
students
id | name | city
-----------------
1 | Sara | Tehran
2 | Ali | Shiraz
3 | Reza | TabrizThree important terms:
Table
The whole structure above is a table. For example:
studentsRow
Each row usually represents one entity or record. For example:
1 | Sara | TehranThat row is one student.
Another common word: record.
Column
Each column holds one attribute. For example:
name
citySo:
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:
university_database
students
teachers
courses
enrollments
grades
departmentsSo:
A table is part of a database.
For example:
Database
│
├── students
├── teachers
├── courses
└── grades5. How was information stored before databases?
Imagine the university has no database. The education office has a file:
students.xlsxInside it:
Sara | 0912... | Tehran
Ali | 0913... | ShirazThe exams office has its own file:
grades.xlsxAnd student details are written again:
Sara | 0912... | Tehran | Database | 18Finance has another file:
payments.xlsxAnd again:
Sara | 0912... | Tehran | PaidSara’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:
سیستم بانکی
سیستم غیر بانکیThey usually mean:
Non-banking system
That is a file-based system.
Data lives in separate files. For example:
آموزش → students.xlsx
امتحانات → grades.xlsx
امور مالی → payments.xlsxBanking system
The more precise term is a database system.
Data is managed in one database.
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:
students.xlsx → Tehran
grades.xlsx → Tehran
payments.xlsx → TehranSara moves from Tehran to Isfahan. Education updates its file:
students.xlsx → IsfahanBut exams forgets:
grades.xlsx → TehranNow the system has two answers about one student:
آموزش: اصفهان
امتحانات: تهران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:
Sara | Tehranstored 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:
File A → Sara → Tehran
File B → Sara → IsfahanBoth talk about the same person, but the facts differ.
So we have an important relationship:
Redundancy
↓
احتمال ایجاد
↓
Data InconsistencyThat 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:
0 <= grade <= 20So:
grade = 18is valid. But:
grade = 150is not valid.
Integrity examples
Example 1
age = -25That is illogical.
Example 2
A student tries to enroll in a course that does not exist:
course_id = 900But 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:
Sara → 0012345678
Ali → 0012345678A 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:
grade between 0 and 20Entity integrity
Every record must be identifiable. Each student has a unique id.
id = 1 → Sara
id = 2 → AliReferential integrity
Links between tables must be valid. If we say:
student_id = 25a 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:
نمرات خودشbut must not see:
نمرات تمام دانشجویانAn education clerk may see:
اطلاعات ثبتنامbut should not necessarily see:
حقوق استادان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:
grade = 150has 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:
Integrity
→ درست بودن داده
Confidentiality
→ مجاز بودن دسترسی15. Now the DBMS enters
Term: Database Management System (DBMS).
A DBMS is software that manages the database.
A simple picture:
User / Application
│
▼
DBMS
│
▼
DatabaseThe 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:
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:
دانشجویان تهران را نشان بده.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.
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:
MySQL
PostgreSQL
Microsoft SQL Server
Oracle Database
SQLiteThese 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:
students
courses
enrollmentsand 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:
SELECT * FROM students;In plain words:
Show me all students.
22. How SQL, DBMS, and database relate
Keep this picture in mind:
SQL
│
▼
User → DBMS → DatabaseYou write:
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:
students
id | name | city
------------------
1 | Sara | Tehran
2 | Ali | Shiraz
3 | Reza | TehranYou tell the DBMS:
SELECT *
FROM students
WHERE city = 'Tehran';The DBMS checks the data and returns:
1 | Sara | Tehran
3 | Reza | TehranSo:
Database
→ دادهها را دارد
DBMS
→ دادهها را مدیریت میکند
SQL
→ زبانی است که با DBMS صحبت میکنیم24. Never mix these four terms
| Term | Simple meaning |
|---|---|
| Data | raw fact |
| Database | organized collection of data |
| DBMS | software that manages the database |
| SQL | language for talking to a relational DBMS |
Example:
Sara, Tehran
↓
Data
students table
↓
Database
PostgreSQL
↓
DBMS
SELECT ...
↓
SQL25. 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:
Data
│
▼
Database
│
│ managed by
▼
DBMS
▲
│
SQL
▲
│
User / ApplicationAnd from the other side:
File-Based System
│
├── Redundancy
├── Inconsistency
├── Integrity Problems
└── Access Problems
↓
Database System
+
DBMS27. University example, summarized
Suppose we have:
Student:
Sara
Student ID: 1001
City: TehranIf Sara’s data is stored in five separate files:
students.xlsx
grades.xlsx
payments.xlsx
library.xlsx
dormitory.xlsxFirst problem: redundancy — the data is repeated.
If one file changes and the others do not: inconsistency.
If someone enters:
grade = 150Problem: 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:
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:
PostgreSQL → RDBMS
university database → Database
students → Table
SELECT * FROM students; → SQLAlmost every later SQL lesson is built on this foundation.