Backend Flashcards

(19 cards)

1
Q

What is a path parameter in a backend API?

A

A path parameter is a variable part of a URL that is used to identify a specific resource within a RESTful API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: Path parameters are always optional in API endpoints.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill in the blank: In a URL like ‘/users/{userId}’, ‘{userId}’ is an example of a __________.

A

path parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following is a correct way to define a path parameter in a RESTful API? (A) /products/{productId} (B) /products?productId={productId} (C) /products/productId/{productId}

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the primary purpose of using path parameters in API design?

A

To uniquely identify resources and provide a clear structure for accessing them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What type of database is Redis?

A

Redis is an in-memory key-value store.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False: Redis supports data persistence.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Fill in the blank: Redis is often used for ___.

A

caching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What data structure does Redis primarily use?

A

Key-value pairs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which command is used to set a value for a key in Redis?

A

SET.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the maximum size of a Redis string?

A

512 megabytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following is NOT a data type supported by Redis? a) List b) Set c) Table

A

c) Table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does Redis achieve high performance?

A

By storing data in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

True or False: Redis supports transactions.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

For what “Redis” stands?

A

Remote Dictionary Server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are microservices?

A

Microservices are small, independent applications that perform specific tasks, allowing for flexible deployment and scaling. This modular approach to software design loosens the coupling between components, enhancing flexibility and manageability throughout development.

17
Q

What is the N+1 query problem?

A

It’s a situation where an application executes 1 query to fetch a list of records (N records), and then for each of those N records executes a separate query—resulting in N+1 queries total. This causes many database calls and significantly reduces performance.

18
Q

How can you recognize the N+1 query problem in your code? (3)

A

You see a loop where a database query is executed each iteration.

SQL logs show many similar SELECT queries with different IDs.

The app runs fine with a small number of records but slows drastically as the number increases.

Profiling tools show query count growing linearly with the number of objects.

19
Q

How can you solve the N+1 query problem?

A

Use a single query with JOINs to fetch data all at once. Then, organize associations in application memory (e.g., group comments by post_id).

SELECT posts.id, posts.title, comments.body
FROM posts
LEFT JOIN comments ON comments.post_id = posts.id;

grouped = group_by(comments, key=lambda c: c.post_id)
for post in posts:
post.comments = grouped.get(post.id, [])