DEV Community

Cover image for Day 62 of My Data Analytics Journey !
Ramya .C
Ramya .C

Posted on

Day 62 of My Data Analytics Journey !

SQL Mock Interview Experience

Today, I attended a mock interview focused on SQL. It was a great experience that tested both my theoretical understanding and practical skills.
Here are the questions I faced and how I answered them πŸ‘‡


πŸ’¬ 1. Self Introduction

I introduced myself as Ramya, a budding Data Analyst, currently learning SQL, Python, and visualization tools. I mentioned my goal β€” to become a professional Data Analyst and share my daily learning journey online.


πŸ—‚οΈ 2. What databases have you used?

βœ… I have worked with:

  • MySQL – for structured data and query practice.
  • PostgreSQL – for advanced queries and joins.
  • SQLite – for small projects and data analysis tasks.

πŸ”— 3. What are Joins in SQL?

Joins combine data from two or more tables based on a related column.

Type Description
INNER JOIN Returns only matching rows between both tables.
LEFT JOIN Returns all rows from the left table and matched rows from the right.
RIGHT JOIN Returns all rows from the right table and matched rows from the left.
FULL JOIN Returns all rows when there’s a match in either table.

🧩 Example:

SELECT students.name, departments.dept_name
FROM students
INNER JOIN departments
ON students.dept_id = departments.dept_id;
Enter fullscreen mode Exit fullscreen mode

πŸͺŸ 4. What is a Window Function?

A window function performs calculations across a set of rows related to the current row β€” like ranking or cumulative totals.

Example:

SELECT student_name, department,
       RANK() OVER (PARTITION BY department ORDER BY marks DESC) AS rank
FROM students;
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ This gives the rank of each student within their department.


βš™οΈ 5. What is a Stored Procedure?

A stored procedure is a pre-written SQL code that can be saved and reused.

Example:

CREATE PROCEDURE GetStudents()
BEGIN
   SELECT * FROM students;
END;
Enter fullscreen mode Exit fullscreen mode

Then we can call it using:

CALL GetStudents();
Enter fullscreen mode Exit fullscreen mode

πŸ‘©β€πŸŽ“ 6. Find how many students in each department

Query:

SELECT department, COUNT(student_id) AS total_students
FROM students
GROUP BY department;
Enter fullscreen mode Exit fullscreen mode

🧠 This query uses the GROUP BY clause to count students department-wise.


πŸ“ˆ 7. What is Indexing?

An index speeds up data retrieval from a database table.
It works like a book index β€” helps find information faster.

Example:

CREATE INDEX idx_student_name ON students(student_name);
Enter fullscreen mode Exit fullscreen mode

🧩 8. What is Partitioning?

Partitioning divides a large table into smaller, manageable pieces while keeping them as one logical table.
It improves performance and maintenance.

Example:

CREATE TABLE sales (
  id INT,
  amount DECIMAL(10,2),
  sale_date DATE
)
PARTITION BY RANGE (YEAR(sale_date)) (
  PARTITION p2024 VALUES LESS THAN (2025),
  PARTITION p2025 VALUES LESS THAN (2026)
);
Enter fullscreen mode Exit fullscreen mode

πŸ”‘ 9. Difference between Primary Key and Foreign Key

Key Type Description Example
Primary Key Uniquely identifies each record in a table. student_id in students table
Foreign Key Refers to the primary key of another table. dept_id in students referring to departments

🌱 My Takeaway

The interview gave me confidence and helped me realize areas I can improve β€” especially in explaining SQL logic more clearly.


#Day62 #RamyaAnalyticsJourney #DataAnalytics #SQL #MockInterview #LearningInPublic #Database #Joins #WindowFunctions #StoredProcedure #Indexing #PrimaryKey #ForeignKey #Partitioning

Top comments (0)