3.0
3.0
TECHNOLOGIES
Rohan Raj Poudel
Precap: Week 3
Planned Sessions:
◦ Types of Databases
• General Definition:
• Raw facts, figures, or details collected from observations or measurements.
• Example: Names, numbers, measurements, words, observations.
• In IT (Information Technology):
• Information stored electronically in a format that a computer can process.
• Example: Text files, images, videos, sensor readings, user activity logs.
Data and Storage
Types of Data
• Structured Data:
• Organized in a defined manner, usually in tables (rows and columns).
• Example: Databases like MySQL, Oracle.
• Semi-structured Data:
• Partially organized data, not strictly in tables, but still structured through tags or markers.
• Example: XML, JSON files.
• Unstructured Data:
• No specific format or structure.
• Example: Images, videos, PDFs, emails.
Data and Storage
Importance of Data
• The method of saving data in physical or cloud mediums for future access and use.
Storage Mediums
• Cloud Storage:
• Remote servers accessed via internet (e.g., Google Drive, AWS S3).
Data and Storage
What is Data Backup?
• Support ACID transactions like SQL, but scale horizontally like NoSQL.
• Examples:
• Google Spanner, CockroachDB, VoltDB
• Columns:
• Define the type of data stored (fields or attributes).
• Example: Student Name, Roll Number, Class.
• Rows: Roll Number Student Name Class
• Each record or data entry in the table.
• Example: 1 Rohan Raj 10
Key Concepts
What are Primary Keys and Foreign Keys?
• Primary Key:
• A unique identifier for each row in a table.
• No two rows can have the same primary key value.
• Example: Roll Number in a Students table.
• Foreign Key:
• A field in a table that links to the primary key in another table.
• Used to establish relationships between tables.
• Example: Student ID in a Fees table links to Roll Number in the Students table.
Key Concepts
Concept of Relationships
• One-to-One (1:1):
• One record in a table matches one record in another table.
• Example: Each student has one ID card.
• One-to-Many (1:N):
• One record in a table can match multiple records in another table.
• Example: One teacher teaches many students.
• Many-to-Many (M:N):
• Many records in one table relate to many records in another.
• Requires a junction table (linking table).
• Example: Students enrolled in multiple courses, and courses having multiple students.
DB Architecture
• 1-Tier Architecture:
• Database and user interface are on the same machine.
• Example: MS Access running on a single computer.
• 2-Tier Architecture:
• Client-server model.
• The client (frontend) directly talks to the database server.
• Example: A desktop app connected to a MySQL database server.
• 3-Tier Architecture:
• Frontend (client), Backend (application server), and Database server are separated.
• Most modern apps use this model.
File Server Stores and shares files Google Drive, Windows File Server
Modern DB
Cloud Databases
• Databases that instantly update for all users whenever data changes.
• Important for:
• Chat apps
• Online games
• Collaborative tools (like Google Docs)
• Example:
• Firebase Realtime Database
◦ Modern systems often combine cloud, real-time, and distributed databases for speed, scalability, and user
experience.
SQL Basics and Database Security
◦ Basic Operations: CRUD
What is SQL?
• SQL stands for Structured Query Language. ◦ CRUD = Create, Read, Update, Delete
(These are the four basic functions of databases.)
• It is the language used to interact with relational
databases. Operation SQL Command Example
• Tasks done with SQL: Create INSERT Insert a new student's data
• Creating tables Read SELECT View students in a class
• Inserting data Update UPDATE Change a student's address
• Reading data Delete DELETE Remove a student's record
• Updating records
• Deleting records
• SQL Injection is a type of cyber attack where a hacker inserts malicious SQL code into a
query.
• The hacker tricks the database into executing unintended commands.
◦ Think of it like giving secret, hidden commands to the database through normal input
fields like login forms.
SQL Basics and Database Security
How Does SQL Injection Happen?
• Happens when user input is directly used in SQL queries without proper checks.
• Example:
If a hacker enters:
' OR '1'='1
Authorization Defining what someone can do (e.g., only view data, not
delete)
Encryption Scrambling data so even if stolen, it is unreadable
• Data breach!
• Risks:
• Identity theft
• Financial fraud
• Loss of company reputation
• Companies can also face heavy fines and legal action.
Discussions:
How does data travel from user to database and back? (Simple flow)
Optimized for transactions, searches, data Just saves data, no smart operations
consistency
Examples: MySQL Server, PostgreSQL Server Examples: Google Drive, Dropbox, OneDrive
Database servers "understand" the data, while storage servers simply "hold" the data.