---
title: 15 Database Interview Questions You Should Know - HackerRank Blog
description: Database interview questions have been a critical component of tech hiring for decades. In this post, we review the database questions you need to know.
image: https://pages.hackerrank.com/hubfs/Imported_Blog_Media/Featured-Image_Database-Interview-Questions-1.png
---

![](https://pages.hackerrank.com/hs-fs/hubfs/Imported_Blog_Media/Featured-Image_Database-Interview-Questions-1.png?width=2160&height=2160&name=Featured-Image_Database-Interview-Questions-1.png)

# 15 Database Interview Questions You Should Know

![Ryan Loftus](https://7528315.fs1.hubspotusercontent-na1.net/hub/7528315/hubfs/raw_assets/public/mV0_d-cms-elevate-theme_hubspot/elevate/images/avatar-placeholder.jpg?width=48&height=48&name=avatar-placeholder.jpg)

 Ryan Loftus

March 13, 2025

![](https://pages.hackerrank.com/hs-fs/hubfs/Imported_Blog_Media/INBLOG_Database-Interview-Questions-300x113-3.png?width=621&height=234&name=INBLOG_Database-Interview-Questions-300x113-3.png)

Database interview questions have been a critical component of technical hiring for decades. If you’re a [data scientist](https://info.hackerrank.com/Hiring-Guide-Data-Scientists-LP.html), [data engineer](https://www.hackerrank.com/blog/data-engineer-role-overview/), or [software engineer](https://info.hackerrank.com/Hiring_Guide_Software_Engineers.html) on the job market, the ability to demonstrate your skills in a database interview is critical to landing your next role. 

To succeed in a database interview, you’ll need to stay up to date on the latest advancements and prepare for the [styles of problems ](https://www.hackerrank.com/blog/tech-interview-prep-ace-your-interview/)you might encounter. In this post, we’ll review the conceptual, basic, and advanced database interview questions you need to know to land your dream job.

## What a Database Interview Looks Like

A [database](https://www.oracle.com/database/what-is-database/) is an “organized collection of structured information,” typically stored in a database management system (DBMS).

During a database interview, candidates are challenged to complete a series of queries or functions using accompanying sets of data tables, input formats, and output formats.

Database interview questions can cover a wide range of database concepts, including: 

- Queries
- Normalization
- De-normalization
- Transactions
- Subqueries
- Joining
- Ordering
- [OLAP operations](https://www.geeksforgeeks.org/olap-operations-in-dbms/)
- XML queries
- MapReduce

Depending on the format, the interview may also include questions about database technologies, including:

- Database management systems
- Relational databases
- Non-relational databases
- SQL
- NoSQL
- Ruby
- Python

## Multiple Choice Database Questions

[Multiple choice questions](https://www.hackerrank.com/challenges/olap-operation-types-2/problem?isFullScreen=true) will test your basic knowledge of database concepts and functions. It’s worth noting that during an assessment or interview, you may encounter similar questions in an open-ended format, with no answers to choose from.

### Relational Algebra

[**Solve Problem**](https://www.hackerrank.com/challenges/relational-algebra-4/problem?isFullScreen=true)

In precedence of set operators the expression is evaluated from:

- Depends on the expression
- Left to right
- Right to left
- From user specification

### Database Query Languages

[**Solve Problem**](https://www.hackerrank.com/challenges/database-query-languages/problem?isFullScreen=true)

Using which language can a user request information from a database ?

- Query
- Relational
- Structural
- Compiler

### Procedural Language

[**Solve Problem**](https://www.hackerrank.com/challenges/procedural-language/problem?isFullScreen=true)

Which one of the following is a procedural language ?

- Domain relational calculus
- Tuple relational calculus
- Relational algebra
- Query language

### Index Architecture Types

[**Solve Problem**](https://www.hackerrank.com/challenges/indexes-1/problem?isFullScreen=true)

How many index architecture type classifications are there in MS SQL Server?

- 1
- 2
- 3
- 4

### OLAP Operations

[**Solve Problem**](https://www.hackerrank.com/challenges/olap-operations-1/problem?isFullScreen=true)

This OLAP operation involves computing all of the data relationships for one or more dimensions.

- Dice
- Slice
- Pivot
- Roll-up

## Basic Database Coding Questions

Below are five examples of basic problems a data scientist or software engineer might face during a technical interview. These questions are simple in nature, testing only one database concept. They are meant to be solved in a collaborative integrated development environment (IDE).

### Basics of Sets and Relations #1

[**Solve Problem**](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-1/problem?isFullScreen=true)

You are given two sets.

Set A = {1,2,3,4,5,6}

Set B = {2,3,4,5,6,7,8}

How many elements are present in A U B?

Only enter the correct integer in the editor below. Do not include any extra spaces, tabs or newlines.

### Basics of Sets and Relations #3

[**Solve Problem**](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-3/problem?isFullScreen=true)

You are given two sets.

Set A = {1,2,3,4,5,6}

Set B = {2,3,4,5,6,7,8}

How many elements are present in A – B?

Only enter the correct integer in the answering box. Do not include any extra spaces, tabs or newlines.

### Database Normalization #1 – 1NF

[**Solve Problem**](https://www.hackerrank.com/challenges/database-normalization-1-1nf/problem?isFullScreen=true)

The following unnormalized table named PRODUCT is transformed to first normal form (1NF) by splitting it into two tables which have X and Y rows (such that X < Y) respectively. Both the tables have Z columns.

*Product-ID*     *Colors*                   *Price*  
 1                             Red,Green              15.0  
 2                            Blue                         18.0  
 3                            Yellow,Pink             2.5

What are the values of X, Y, Z? Enter these integers, each on a new line, in the text-box below. Do not leave any leading or trailing spaces.

### Database Normalization #4

[**Solve Problem**](https://www.hackerrank.com/challenges/database-normalization-4/problem?isFullScreen=true)

A database, normalized as per 2NF rules, has been split into 10 tables. Each of the tables has exactly two columns: one key attribute and one non-key attribute. What is the minimum number of tables required to express this database in 3NF form? Enter the integer in the text box below. Do not leave any leading or trailing spaces.

### Querying XML Datastores with XPath #1

[**Solve Problem**](https://www.hackerrank.com/challenges/querying-xml-datastores-with-xpath-1/problem?isFullScreen=true)

XPath is a valuable tool often used for querying XML databases. XPath queries (or close variants) are also used in the process of Web Scraping while retrieving data from structured XHTML-compliant web pages, specially those with tabulated data.

(A quick XPath tutorial is available [here](https://edutechwiki.unige.ch/en/XPath_tutorial_-_basics).)

Assume that you have been provided a fragment of XML, which you can [view here](https://www.hackerrank.com/challenges/querying-xml-datastores-with-xpath-1/problem?isFullScreen=true). Your task is to write the XPath selector for listing the titles of the movies in the same order as which they occur in the given XML. The Ruby code for handling input, output, and document construction has already been provided. You only need to fill up the required blanks as indicated in the template code provided. This challenge is agnostic to language-specific knowledge and you do not require to know Ruby – as you only need to complete the XPath selector.

## Advanced Database Coding Questions

Below are five examples of more challenging database problems, with difficulties ranging from medium to advanced. These questions cover more specific concepts and language-specific knowledge, and are also meant to be solved in a collaborative IDE.

### MapReduce Advanced – Relational Join

[**Solve Problem**](https://www.hackerrank.com/challenges/map-reduce-advanced-relational-join/problem?isFullScreen=true)

A SQL join combines records from two or more tables in a relational database. It creates a set that can be saved as a table or used as it is. A JOIN is a means for combining fields from two tables (or more) by using values common to each.

The input is a number of lines with records from two tables Employee and Department. A tuple from the Employee table will look like:

Employee [Person_Name] [SSN]

A tuple from the Department table will look like:

Department [SSN] [Department_Name]

The required output is to print the JOIN of the two tables Employee and Department, in the format shown. The code for the MapReduce class, parts related to IO etc. has already been provided. However, the mapper and reducer functions are incomplete. Your task is to fill up the mapper and reducer functions appropriately, such that the program works, and outputs the JOIN of the two tables, in lexicographical order.

### Database Normalization #3

[**Solve Problem**](https://www.hackerrank.com/challenges/database-normalization-3/problem?isFullScreen=true)

A database used by a college’s application stores the relationship between students and the courses they are enrolled in. We have information for each STUDENT (such as name, date of birth, date of enrollment, student-id) and COURSE (course code, instructor, etc.). In real life, a student takes several courses simultaneously while a subject is studied by several students. We need to capture this many-to-many relationship in our database. From the above information, what is the minimum number of tables required to structure this database in accordance with the rules of 2NF normalization?

### Database Normalization #9

[**Solve Problem**](https://www.hackerrank.com/challenges/database-normalization-9/problem?isFullScreen=true)

Consider the following relation and determinants. The key(s) are bolded.

R(a, b ,c,d,e)

Which of these determinants is a NON-CANDIDATE key? In the text box, only enter the index number (1-3) of the dependency which you have identified as non-key.

1. a,c -> b,d,e
2. a,d -> b
3. a,c,e -> b,d

### Database Keys

[**Solve Problem**](https://www.hackerrank.com/challenges/databases-keys/problem?isFullScreen=true)

A database table with three fields (bookname, author, language) has been created. If the table is as provided below, which of these three fields may be used as the primary key?

bookname-author-language

A Tale of Two Cities, Charles Dickens, English

Oliver Twist, Charles Dickens, English

Godaan, Premchand, Hindi

Chandrakanta, Devaki Nandan Khatri, Hindi

Hamlet, William Shakespeare, English

The Merchant of Venice, William Shakespeare, English

Only fill in the name of the field which may be used as the primary key. Grading is case-sensitive.

### Database Differences

[**Solve Problem**](https://www.hackerrank.com/challenges/databases-differences/problem?isFullScreen=true)

Relation R(A,B,C) has the following tuples:

A B C

1 2 3

4 2 3

4 5 6

2 5 3

1 2 6

Relation S(A,B,C) has the following tuples:

A B C

2 5 3

2 5 4

4 5 6

1 2 3

The difference (R-S) is computed and the following tuple is found to be present in the result. Assume that the schema of the result is (A,B,C).

4, b, c

Find the integers b and c. Fill in the values in the answer box, each on a new line.

## Resources to Improve Database Knowledge

[HackerRank Database Questions](https://www.hackerrank.com/domains/databases)

[HackerRank SQL Questions](https://www.hackerrank.com/domains/sql)

[HackerRank SQL Certification (Basic)](https://www.hackerrank.com/skills-verification/sql_basic)

[HackerRank SQL Certification (Intermediate)](https://www.hackerrank.com/skills-verification/sql_intermediate)

[HackerRank SQL Certification (Advanced)](https://www.hackerrank.com/skills-verification/sql_advanced)

[HackerRank Interview](https://www.hackerrank.com/products/developer-skills-platform/interview-free/)

## Share this post

<https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fpages.hackerrank.com%2Fblog%2Fdatabase-interview-questions-you-should-know><https://twitter.com/intent/tweet?url=https%3A%2F%2Fpages.hackerrank.com%2Fblog%2Fdatabase-interview-questions-you-should-know><https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fpages.hackerrank.com%2Fblog%2Fdatabase-interview-questions-you-should-know><https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fpages.hackerrank.com%2Fblog%2Fdatabase-interview-questions-you-should-know>[mailto:https%3A%2F%2Fpages.hackerrank.com%2Fblog%2Fdatabase-interview-questions-you-should-know](mailto:https%3A%2F%2Fpages.hackerrank.com%2Fblog%2Fdatabase-interview-questions-you-should-know)

## Keep reading

[![](https://pages.hackerrank.com/hs-fs/hubfs/image%20(3)-2.png?width=1184&height=621&name=image%20(3)-2.png)

Data

### Where developers work vs. where they want to work

](https://pages.hackerrank.com/blog/where-developers-work-vs.-where-they-want-to-work)

[![](https://pages.hackerrank.com/hs-fs/hubfs/image%20(3).png?width=1184&height=621&name=image%20(3).png)

Tech Skills

### Top developer skills in 2025: momentum, not mayhem

](https://pages.hackerrank.com/blog/top-developer-skills-2025)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Ryan Loftus",
    "url" : "https://pages.hackerrank.com/blog/author/ryan-loftus"
  },
  "dateModified" : "2025-03-13T15:51:55.685Z",
  "datePublished" : "2025-03-13T15:51:55.000Z",
  "headline" : "15 Database Interview Questions You Should Know - HackerRank Blog",
  "image" : [ "https://pages.hackerrank.com/hubfs/Imported_Blog_Media/Featured-Image_Database-Interview-Questions-1.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://pages.hackerrank.com/blog/database-interview-questions-you-should-know",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://pages.hackerrank.com/hubfs/HR_Logo_Black-Green-Assets.png"
    },
    "name" : "HackerRank"
  }
}
```