1. What Is SQL and Why Analysts Need It
1.3 Tables, Rows, Columns and Keys Explained for Beginners
Why. Wrong grain (what one row means) breaks every total later.
What. A table has columns (fields) and rows (records). A primary key uniquely names a row. A foreign key points to a key in another table.
How. In raja_coffee: customers.customer_id is a key. orders.customer_id points to it.
Steps
- Open customers — one row per person.
- Open orders — one row per order.
- Notice orders.customer_id links to customers.
Examples
Example 1 · dataset: raja_coffee
SELECT customer_id, name, city FROM customers ORDER BY customer_id LIMIT 4;Output
| customer_id | name | city |
|---|---|---|
| 1 | Asha Patil | Pune |
| 2 | Omar Khan | Mumbai |
| 3 | Sofia Mendes | Goa |
| 4 | James Okonkwo | Pune |
Meaning. Each customer_id appears once — that is the key idea.
Ravindra Bagale's Tip
Before writing SQL, say out loud: One row in this table means ___.
Ravindra Bagale's Tip – मराठी
SQL लिहिण्याआधी म्हणा: या टेबलमधील एक रो म्हणजे ___.
Ravindra Bagale's Tip – हिंदी
SQL लिखने से पहले ज़ोर से कहें: इस टेबल की एक पंक्ति का मतलब ___ है।