TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst · 76.7K subscribers
Post #2704 2.24K
A database can contain hundreds or thousands of tables.

6️⃣ What is a Row?

A row represents one record. 1 | Rahul | IT | 80000 = 1 row = 1 record.

7️⃣ What is a Column?

A column represents an attribute or field.

Row → Record

Column → Attribute.

8️⃣ What is a Primary Key?

A Primary Key uniquely identifies each row in a table. e.g., employee_id = 101 cannot repeat.

Properties:

✅ Must be unique

✅ Cannot normally be NULL

✅ Identifies a specific record

9️⃣ What is a Foreign Key?

A Foreign Key creates a relationship between tables. orders.customer_id is a Foreign Key referring to customers.customer_id.

🔟 Primary Key vs Foreign Key

PRIMARY KEY → Uniquely identifies a record

FOREIGN KEY → Connects one table to another

1️⃣1️⃣ What is NULL?

NULL means the value is missing, unknown, or not available. It does NOT mean 0, empty string, or "NULL" text.

Correct query: SELECT * FROM employees WHERE manager_id IS NULL;

Wrong: WHERE manager_id = NULL;

1️⃣2️⃣ What are Data Types?

INT → 101

DECIMAL(10,2) → 85000.50

VARCHAR(100) → 'Rahul Sharma'

DATE → 2026-08-25

TIMESTAMP → 2026-08-25 10:30:00

1️⃣3️⃣ One Database Can Have Multiple Tables

DATABASE → Customers, Products, Employees → Orders → Payments

The power of SQL comes from being able to analyze these related tables together.

1️⃣4️⃣ Example: E-Commerce Database

customers, products, orders, order_items — Now business can ask: Which city generated highest revenue? Who are top 10 customers? Which products sell the most?

🧠 Your First SQL Query

SELECT * FROM customers;

SELECT → Retrieve data, * → All columns, FROM → From this table

SELECT customer_id, customer_name, city FROM customers;

💡 Q: What is difference between a Primary Key and a Foreign Key?

A: A Primary Key uniquely identifies each record within its own table, while a Foreign Key is used to reference a key in another table and establish a relationship between tables.

If you understand how data is structured and how tables relate to each other, learning JOIN, GROUP BY, CTE, and Window Functions becomes much easier.

Double Tap ❤️ For Part-2
  • ❤ 14
More from @sqlanalyst
  1. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  2. Oct 7, 2026SQL Interview Series — Part 4 📌 Question 4: Find the Highest Salary in Each Department Su…
  3. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  4. Sep 29, 2026SQL Interview Series — Part 2 📌 Question 2: Find Duplicate Records Suppose you have an Em…
  5. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  6. Sep 29, 2026SQL Interview Series — Part 1 Hi guys, let's start a SQL interview series covering frequen…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →