SarthiQ

SarthiQ

Interview Preparation Guide

SQL & Databases
Questions & Answers

A comprehensive, expert-curated list of real interview questions to help you prepare effectively and land your dream job.

Document Details

Topic / Subject
SQL & Databases
Content Length
20 Curated Q&A
Generated On
October 4, 2026
Provided By
SarthiQ.com
Want to explore more questions & mock interviews? Click on 👉www.sarthiq.com
© 2026 SarthiQ Platform. All rights reserved.
www.sarthiq.com
Resume Upload Get Job in 90 Days Resume Builder AI Interview Coach Interview Questions Placement Committee Self Assessment Get Internship

Need Help?

[email protected]

Top SQL & Databases Interview Questions

NETFLIX
ORACLE
Adobe
NVIDIA
meta
IBM
wipro
TCS
cisco
intel
SAP
Uber

SQL & Databases Interview Questions

Practice with real SQL & Databases interview questions

01
A Software Engineer was asked
SarthiQ SQL & Databases
Medium
Asked in 2024
Q. What are the different types of keys in a database, and how do primary, foreign, and unique keys differ?
Ans. In a database, keys are used to uniquely identify records and establish relationships between tables. The three main types of keys are: 1. Primary Key: A unique identifier for a record in a table. No two rows can have the same primary key value, and it cannot be null. - Example: In a users table, user_id can be a primary key. 2. Foreign Key: A field (or collection of fields) in one table that uniquely identifies a row of another table. This establishes a relationship between the two tables. - Example: In an orders table, user_id can be a foreign key referencing the user_id in the users table. 3. Unique Key: Ensures that all values in a column are different. Unlike primary keys, unique keys can accept null values. - Example: In a users table, email can be a unique key. Here’s a simple SQL example to illustrate these keys:
sql
CREATE TABLE users (
    user_id INT PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    name VARCHAR(100)
);

CREATE TABLE orders (
    order_id INT PRIMARY KEY,
    user_id INT,
    FOREIGN KEY (user_id) REFERENCES users(user_id)
);
In this SQL code, user_id is a primary key in the users table, while it serves as a foreign key in the orders table, linking orders to users. The email field is a unique key, ensuring no two users can have the same email address.
Software EngineerCore Concept
02
A Software Engineer was asked
SarthiQ SQL & Databases
Medium
Asked in 2024
Q. Can you explain the basic operations of arrays and strings in programming, and give an example of how to reverse a string using an array?
Ans. Arrays and strings are fundamental data structures in programming. An array is a collection of items stored at contiguous memory locations, while a string is an array of characters terminated by a null character. Key Operations: - Accessing: You can access elements using an index. - Inserting: Inserting new elements requires shifting elements if the array is full. - Deleting: This also requires shifting elements to maintain order. - Searching: You can search for elements using algorithms like linear or binary search. Here’s a simple example of reversing a string using an array in Python:
python
**def reverse_string(s):**
    # Convert string to list (array)
    arr = list(s)
    left, right = 0, len(arr) - 1
**    while left < right:**
        # Swap elements
        arr[left], arr[right] = arr[right], arr[left]
        left += 1
        right -= 1
    return ''.join(arr)

**Test the function**
input_string = "Hello, World!"
reversed_string = reverse_string(input_string)
print(reversed_string)  # Output: !dlroW ,olleH
This code defines a function that reverses an input string by utilizing an array-like approach, demonstrating basic array operations such as indexing and swapping.
Software EngineerCore Concept
03
Software Engineer
SarthiQ SQL & Databases
Hard

Question:

How would you design a scalable system for XYZ...

04
Software Engineer
SarthiQ SQL & Databases
Hard

Question:

How would you design a scalable system for XYZ...