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;
πͺ 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;
π 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;
Then we can call it using:
CALL GetStudents();
π©βπ 6. Find how many students in each department
Query:
SELECT department, COUNT(student_id) AS total_students
FROM students
GROUP BY department;
π§ 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);
π§© 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)
);
π 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)