Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Candidate Name - Harsh Singh

Solution

A. List all the tables that we have to create

1. User Table:
- Columns:
- ID (Primary key)
- Name

2. Concern Table:
- Columns:
- ID (Primary key)
- Name

3. User_Concern Table (Join Table):


- Columns:
- User_ID (Foreign key referencing the User Table's ID)
- Concern_ID (Foreign key referencing the Concern Table's ID)

4. Content Table:
- Columns:
- ID (Primary key)
- Concern_ID (Foreign key referencing the Concern Table's ID)
- Content details (e.g., text, image URL, etc.)

B. List all the necessary APIs that we have to build

1. GET /users:

Description: Retrieve the list of users.


Response: Return a JSON array containing user objects with their IDs
and names.

2. GET /users/{user_id}/concerns:
Description: Retrieve the list of concerns for a specific user.
Backend logic: Query the User_Concern table to fetch all concern records
associated with the given user ID.
Response: Return a JSON array containing concern objects with their IDs
and names.

3. GET /concerns:

Description: Retrieve the list of all concerns.


Backend logic: Query the Concern table to fetch all concern records.
Response: Return a JSON array containing concern objects with their IDs
and names.

4. GET /concerns/{concern_id}/content:

Description: Retrieve the content for a specific concern.


Backend logic: Query the Content table to fetch all content records
associated with the given concern ID.
Response: Return a JSON array containing content objects with their
details (e.g., text, image URL, etc.).

5. POST /users/{user_id}/concerns:

Description: Create a new concern for a specific user.


Request payload: Include the concern details (e.g., name) in the request
body.
Response: Return a JSON object confirming the successful creation of
the concern.

6. POST /users/{user_id}/concerns/{concern_id}/content:

Description: Create new content for a specific concern.


Request payload: Include the content details (e.g., text, image URL, etc.)
in the request body.
Response: Return a JSON object confirming the successful creation of
the content.

You might also like