01 - Introduction to Databases
What is a Database?
At its core, a database is an organized collection of data that can be easily accessed, managed, and updated. Think of it as a digital filing system that's smarter, faster, and more reliable than storing data in files.
Why Not Just Use Files?
Python
# Without database - storing in files
# Problems:
# 1. Data duplication (John's email in 10 places)
# 2. No concurrent access (two people can't write simultaneously)
# 3. Searching is slow (read entire file)
# 4. No data validation (can insert "invalid" data)
# 5. No relationships between data
users.txt:
---
id|name|email|department_id
1|John|john@email.com|1
2|Jane|jane@email.com|2
3|Bob|bob@email.com|1
# To find John's department name:
# 1. Read users.txt to get department_id=1
# 2. Read departments.txt to find id=1
# 3. This is slow and error-prone