BlogData Analytics BasicsChapter 5
BASICS · CHAPTER 5Beginner

Introduction to Databases for Data Analysts

What a database is, how tables, rows, columns, and keys work, the difference between relational and NoSQL databases, and how SQL connects to all of it — explained from scratch before you write a single query.

DATA ANALYTICS SERIES:← Ch 4: Key MetricsCh 5: Intro to Databases ←Ch 6: SQL Complete Guide →

Why Data Analysts Need to Understand Databases

In most companies, the data you need as an analyst does not live in a spreadsheet. It lives in a database. Customer records, orders, payments, inventory, user events — all of this is stored in structured database systems that have been running continuously for years. Your job as an analyst is to query that data, extract what you need, and turn it into insight.

You do not need to build or administer databases. But you need to understand how they work well enough to read a database diagram, write SQL that joins tables correctly, and understand why certain data looks the way it does.

🏢
Business data lives here
Every transaction, every customer, every event is in a database — not a spreadsheet.
🔗
Multiple tables are joined
Data is split across many tables. You need to understand keys to join them correctly.
SQL is the access language
SQL is how you talk to relational databases — Chapter 6 is dedicated to it.
📊
Scale matters
A database handles millions of rows efficiently. Excel does not.

What Is a Database?

A database is an organised collection of data stored on a server, designed to be searched, retrieved, and updated efficiently. Unlike a spreadsheet that lives as a file on someone's computer, a database runs as a continuous service on a server — available 24/7 to applications, analysts, and automated processes simultaneously.

SPREADSHEET vs DATABASE — SIDE BY SIDE
FeatureSpreadsheet (Excel)Relational Database (MySQL)
Row limit~1 million rowsBillions of rows
Multi-userConflicts if multiple people editHandles thousands of simultaneous users
Data integrityNo enforcement — anyone can type anythingEnforces rules: data types, NOT NULL, foreign keys
Performance on large dataSlow — loads everything into RAMFast — indexes allow querying specific rows only
Access languagePoint-and-click, formulasSQL (structured queries)
RelationshipsVLOOKUP / XLOOKUP between sheetsFormal JOIN via primary/foreign keys
Where it livesFile on a computerServer (on-premise or cloud)
Common Indian use caseSmall team reports, ad-hoc analysisERP systems, e-commerce platforms, banking core

Tables, Rows, and Columns

A relational database organises data into tables. A table is similar to a spreadsheet tab — it has rows and columns. But unlike a spreadsheet, each table represents one specific type of thing (customers, orders, products), and the structure is fixed.

Table

Stores data about one type of entity. A database has many tables — one for customers, one for orders, one for products.

Column (Field)

Defines what piece of information is stored — customer_id, name, city, email. Each column has a data type: INT, VARCHAR, DATE, DECIMAL.

Row (Record)

One individual instance — one customer, one order, one product. A table with 10,000 customers has 10,000 rows.

Cell

The intersection of one row and one column — the actual value. Customer ID 101, city "Noida", order amount ₹2,500.

customers TABLE — 5 example rows4 columns shown
customer_id (PK)namecitysignup_date
101Aarav SharmaNoida2024-01-15
102Priya NairMumbai2024-02-08
103Rohit GuptaDelhi2024-02-20
104Sneha IyerBengaluru2024-03-05
105Karan MehtaHyderabad2024-03-12

customer_id is the primary key — it uniquely identifies each customer. No two customers share the same ID.

Primary Keys and Foreign Keys

Keys are how tables connect to each other. Understanding them is essential for writing correct JOINs in SQL.

Primary Key (PK)

Uniquely identifies each row in a table. No duplicates. No NULLs allowed.

EXAMPLE
customers.customer_id = 101, 102, 103…
orders.order_id = 5001, 5002, 5003…
  • One primary key per table
  • Often auto-generated by the database (auto-increment)
  • The database enforces uniqueness automatically
Foreign Key (FK)

A column in one table that refers to the primary key of another table. It creates the link between tables.

EXAMPLE
orders.customer_id = 101
→ refers to customers.customer_id = 101
  • The FK value must exist in the referenced table (referential integrity)
  • You cannot insert an order for customer_id = 999 if customer 999 does not exist
  • This is the column you JOIN on in SQL
orders TABLE — customer_id is a Foreign Key linking to customers
order_id (PK)customer_id (FK)order_dateamount_inrstatus
50011012025-08-01₹1,850delivered
50021032025-08-01₹4,200delivered
50031012025-08-03₹760returned
50041022025-08-05₹3,100delivered
50051042025-08-06₹920shipped
KEY INSIGHT: Customer 101 (Aarav Sharma) appears in orders 5001 and 5003. To see all orders WITH customer names, you JOIN these two tables on orders.customer_id = customers.customer_id. This is exactly how SQL JOINs work.

Common Database Data Types

Every column in a database has a data type — this tells the database what kind of value it holds and how to store it. Understanding data types matters because it affects what SQL operations you can perform and why some calculations fail.

Data TypeWhat It StoresIndian ExampleSQL Gotcha
INT / BIGINTWhole numberscustomer_id, quantity, pincodeCannot store decimals. 1/2 = 0 in integer division.
DECIMAL(10,2)Exact decimal numbersorder_amount ₹2500.75, price, GST amountUse DECIMAL for money — FLOAT has rounding errors.
VARCHAR(255)Variable-length textcustomer_name, city, email, product_nameCannot do arithmetic. "1"+"2"="12" not 3.
DATECalendar date (no time)order_date, dob, last_login_dateCan filter with BETWEEN; subtract to get days difference.
DATETIME / TIMESTAMPDate + timecreated_at, updated_at, event_timestampTime zone issues if system is not configured correctly.
BOOLEAN / TINYINT(1)True/Falseis_returned, is_active, is_premium_memberOften stored as 1/0 in MySQL — use CASE WHEN = 1 THEN…
NULLMissing / unknown valuedelivery_date when order not yet deliveredNULL ≠ 0 and NULL ≠ "". SUM(NULL) = NULL. Use IS NULL to check.

Types of Databases — Relational vs NoSQL

Two major families of databases exist. As a data analyst, you will work with relational databases far more often — but knowing the difference helps you understand why data is sometimes in unexpected formats.

Relational Databases (SQL)
The primary tool for data analysts
HOW DATA IS STORED

In tables with rows and columns. Every table has a defined schema (fixed columns and data types). Tables are related to each other via primary/foreign keys.

COMMON SYSTEMS
MySQLPostgreSQLSQL ServerOracleBigQuery
INDIAN USE CASES
  • E-commerce orders, inventory, customers
  • Banking core systems (account, transaction)
  • ERP systems (SAP, Oracle ERP)
  • HR & payroll systems
  • Hospital management (EMR / HIS)
NoSQL Databases
Specialist tools for specific data patterns
HOW DATA IS STORED

In formats other than tables — documents (JSON), key-value pairs, wide columns, or graphs. Schema can be flexible — different records can have different fields.

COMMON SYSTEMS BY TYPE
Document: MongoDB (app data, product catalogues)
Key-Value: Redis (sessions, caching, real-time)
Wide Column: Cassandra (telemetry, time-series at scale)
Graph: Neo4j (social networks, fraud detection)
WHEN YOU WILL SEE THIS AS AN ANALYST
  • App event logs (user behaviour, clickstreams)
  • Product catalogue with variable attributes
  • Real-time dashboards (via Redis)
  • Fraud network analysis (graph)

How SQL Connects to a Database

SQL (Structured Query Language) is the language used to communicate with relational databases. When you write a SQL query, you are giving instructions to the database engine: which table to look in, which rows to filter, which columns to return, and how to combine tables together.

YOUR FIRST QUERY — reading from the customers table
SELECT customer_id, name, city     -- Which columns do you want?
FROM   customers                   -- Which table?
WHERE  city = 'Noida'              -- Which rows to include?
ORDER BY signup_date DESC;         -- In what order?
JOIN QUERY — connecting customers and orders via FK
SELECT
    c.name,
    c.city,
    COUNT(o.order_id)     AS total_orders,
    SUM(o.amount_inr)     AS total_spent_inr
FROM customers c
JOIN orders o ON o.customer_id = c.customer_id  -- FK = PK
WHERE o.status = 'delivered'
GROUP BY c.customer_id, c.name, c.city
ORDER BY total_spent_inr DESC;

What happened: The JOIN matched every order's customer_id to the corresponding customer's record. The result shows each customer's name, city, how many delivered orders they have placed, and how much they have spent in total. This single query draws from two tables simultaneously using the FK-PK link.

Continue the Series
← Ch 4: Key MetricsCh 6: SQL Complete Guide →

Frequently Asked Questions

What is the difference between a database and a spreadsheet?

A spreadsheet (Excel, Google Sheets) is a file on your computer. A database is a system that stores data persistently on a server, allows multiple users to read and write simultaneously, enforces rules about what data is valid, and can handle millions or billions of rows efficiently. The key practical differences: (1) Scale — Excel handles up to about 1 million rows; a database handles billions. (2) Multi-user — if two people open the same Excel file and edit it, you get conflicts. A database handles concurrent edits safely. (3) Integrity — a database prevents you from deleting a customer that still has active orders; Excel has no such protection. (4) Speed — Excel loads everything into RAM; a database queries only the rows you need. As a data analyst, you will start with spreadsheets for small tasks and move to databases when the data is too big, too shared, or too important to risk in a file.

What is a primary key in a database?

A primary key is a column (or combination of columns) that uniquely identifies each row in a table. No two rows can have the same primary key value, and the primary key cannot be NULL. In a customers table, customer_id is the primary key — every customer has a unique ID. In an orders table, order_id is the primary key. Primary keys are essential for joining tables — when you write a JOIN in SQL, you are connecting a foreign key in one table to the primary key in another. A well-designed database always has a primary key on every table. Common patterns in Indian systems: auto-incrementing integers (1, 2, 3…), UUIDs (for distributed systems), or business keys (PAN numbers, GST registration numbers as identifiers in financial systems).

What is the difference between relational and NoSQL databases?

A relational database (MySQL, PostgreSQL, SQL Server, Oracle) stores data in tables with rows and columns. Relationships between tables are defined by keys. The data structure (schema) must be decided in advance. SQL is the language used to query it. A NoSQL database stores data in other formats: documents (MongoDB), key-value pairs (Redis), wide columns (Cassandra), or graphs (Neo4j). The schema can be flexible — different records can have different fields. For data analysts, relational databases are the primary tool — virtually all business transaction data (orders, customers, products, payments, HR records, inventory) lives in relational databases. NoSQL databases appear in specific analytical contexts: MongoDB for JSON-based app data, Cassandra for time-series data at massive scale, Redis for real-time feature stores in ML. In interviews, if asked about database types, knowing MySQL and the concept of relational databases is the priority. NoSQL is secondary.

Does a data analyst need to know how to design databases?

At a junior level, no — a data analyst primarily reads data from existing databases rather than designing them. Database design (normalisation, schema design, indexing strategy) is primarily the responsibility of database administrators and data engineers. What an analyst must understand: how to read an entity-relationship (ER) diagram to understand a database's structure, how primary keys and foreign keys work so they can write correct JOINs, why data is split across multiple tables (normalisation) rather than kept in one big table, and what NULL values mean and how they affect aggregations and JOINs. As you progress to senior analyst or data engineer roles, understanding schema design, indexing, and query optimisation becomes more important.

EVIKA ACADEMY · NOIDA SECTOR 51

Learn to Query Real Databases

Our curriculum includes hands-on SQL practice on real Indian business datasets — e-commerce, banking, FMCG, healthcare — with direct database access, not toy examples.

Book Free Demo Class →
🎓 Free Demo Class — Online & Offline · Noida Sector 51