Skip to content

Identifying Collection Resources and Documenting Filters

This guide helps you identify resources from your ER diagram and document filtering operations for your REST API design.


List all tables from your ER diagram with your field counts:

Table NameNumber of Fields
(table 1)?
(table 2)?

Requirement: Each table must have at least 5 fields.


Reorder your tables from highest to lowest number of fields:

RankTable NameNumber of Fields
1
2
3
4

Step 3: Select Tables for Collection Resources

Section titled “Step 3: Select Tables for Collection Resources”
  • Team of 3: Select the top 3 tables
  • Team of 4: Select the top 4 tables

These become your primary collection resources.


Step 4: Convert Tables to PARENT Collection Resources

Section titled “Step 4: Convert Tables to PARENT Collection Resources”

IMPORTANT: You must identify parent (top-level) collections FIRST before identifying sub-collections. Sub-collections are derived from the relationships between parent collections.

For each selected table, create a parent collection resource using plural nouns:

Table Name (Singular)Collection Resource URI
Mission/missions
Astronaut/astronauts
Planet/planets
Spacecraft/spacecraft

Naming Rules:

  • Use lowercase
  • Use plural nouns (e.g., missionmissions)
  • Use hyphens for multi-word names (e.g., launch-sites)

Step 5: Assign Collections to Team Members

Section titled “Step 5: Assign Collections to Team Members”
Team MemberAssigned Collection Resource
Member 1/collection1
Member 2/collection2
Member 3/collection3
Member 4*/collection4

*If team of 4

NOTE: If there are not enough parent collection resources for all team members, a team member may select a sub-collection instead, provided that the sub-collection has more than 5 fields.

Example: If your team has 4 members but only 3 parent collections, one member can take a sub-collection like /missions/{missionId}/crew if the crew table has at least 5 fields.


Step 6: Identify Sub-Collections (Nested Resources)

Section titled “Step 6: Identify Sub-Collections (Nested Resources)”

IMPORTANT: This step can ONLY be done AFTER you have identified all parent collections in Steps 3-5. Sub-collections are based on the relationships (foreign keys) between your parent collections.

Why this order matters:

  • You cannot define /missions/{missionId}/crew without first knowing that missions is a parent collection
  • Sub-collections represent how parent resources relate to each other
  • The foreign keys in your ER diagram tell you which resources can be nested under others

Sub-collections represent relationships between resources. Look at your ER diagram for:

  • One-to-One relationships
  • One-to-Many relationships
  • Many-to-Many relationships (via junction tables)

A one-to-one relationship links a single parent resource to a single child resource.

Pattern:

/parent-collection/{parentId}/child-singleton

Examples:

RelationshipURI PatternDescription
Mission has one Commander/missions/{missionId}/commanderEach mission has exactly one commander
Astronaut has one MedicalRecord/astronauts/{astronautId}/medical-recordEach astronaut has one medical record
Spacecraft has one Manifest/spacecraft/{spacecraftId}/manifestEach spacecraft has one cargo manifest
Planet has one Atmosphere/planets/{planetId}/atmosphereEach planet has one atmosphere profile

Note: For one-to-one, the nested resource is a singleton (singular noun), not a collection.


One-to-Many Relationships (Sub-Collections)

Section titled “One-to-Many Relationships (Sub-Collections)”

A one-to-many relationship links a single parent to multiple children.

Pattern:

/parent-collection/{parentId}/child-collection

Examples:

RelationshipSub-Collection URI
Mission has many Crew Members/missions/{missionId}/crew
Planet has many Moons/planets/{planetId}/moons
Spacecraft has many Components/spacecraft/{spacecraftId}/components
Astronaut has many Missions/astronauts/{astronautId}/missions

Many-to-many relationships are typically represented through a junction/associative table. You can expose them from either side.

Pattern:

/resource-a/{aId}/resource-b
/resource-b/{bId}/resource-a

Examples:

RelationshipURI Patterns
Astronauts ↔ Missions/astronauts/{astronautId}/missions and /missions/{missionId}/crew
Planets ↔ Missions/planets/{planetId}/missions and /missions/{missionId}/planets
Spacecraft ↔ Components/spacecraft/{spacecraftId}/components and /components/{componentId}/spacecraft

Relationship TypeParent CollectionChild ResourceFull URI Pattern
One-to-One/parents/child (singular)/parents/{parentId}/child
One-to-Many/parents/children (plural)/parents/{parentId}/children
Many-to-Many/parents/others (plural)/parents/{parentId}/others

Step 7: Create Filter Tables (5 Fields Per Collection)

Section titled “Step 7: Create Filter Tables (5 Fields Per Collection)”

Each team member creates a filter table for their assigned collection with 5 filterable fields.

Collection: /your-collection

#Field NameData TypeFilter ParameterExample Query
1
2
3
4
5

Collection: /missions

#Field NameData TypeFilter ParameterExample Query
1statusString?status=activeGET /missions?status=active
2launchDateDate?launch_date_after=2024-01-01GET /missions?launch_date_after=2024-01-01
3durationInteger?duration_min=30&duration_max=365GET /missions?duration_min=30&duration_max=365
4destinationString?destination=MarsGET /missions?destination=Mars
5crewedBoolean?crewed=trueGET /missions?crewed=true

Step 8: Document Filter Types by Data Type

Section titled “Step 8: Document Filter Types by Data Type”

Use appropriate filter operators based on data type:

Data TypeRecommended Filter OperatorsExample
Stringexact match, contains, startsWith?name=Apollo, ?name_contains=Mars
Numberequals, min, max, range?crewSize=6, ?duration_min=30&duration_max=365
Datebefore, after, between?launch_date_after=2024-01-01
Booleanequals?crewed=true
Enumequals, in (multiple values)?status=active, ?status=planned,launched

For each collection, define sortable fields:

Collection: /your-collection

Sortable FieldSort Parameter Example
name?sort=name or ?sort=-name (desc)
launchDate?sort=launchDate
duration?sort=-duration (longest first)

Standard pagination parameters for all collections:

ParameterDescriptionExample
pagePage number (starts at 1)?page=2
limitItems per page?limit=20
offsetSkip N items (alternative)?offset=20

Combined Example:

GET /missions?status=active&destination=Mars&sort=-launchDate&page=1&limit=10

Step 11: Map HTTP Status Codes to Operations (Team Task)

Section titled “Step 11: Map HTTP Status Codes to Operations (Team Task)”

This section must be completed by ALL team members together.

HTTP status codes indicate the result of an HTTP request. Your API must return appropriate status codes for each operation.


Status CodeNameWhen to Use
200OKSuccessful GET, PUT, PATCH requests that return data
201CreatedSuccessful POST request that creates a new resource
204No ContentSuccessful DELETE request (no response body)

Status CodeNameWhen to Use
400Bad RequestInvalid request syntax, malformed JSON, validation errors
401UnauthorizedMissing or invalid authentication credentials
403ForbiddenValid credentials but insufficient permissions
404Not FoundResource does not exist at the given URI
405Method Not AllowedHTTP method not supported for this endpoint
409ConflictRequest conflicts with current state (e.g., duplicate entry)
422Unprocessable EntityValid syntax but semantic errors (e.g., invalid field values)

Status CodeNameWhen to Use
500Internal Server ErrorUnexpected server-side error
503Service UnavailableServer temporarily unavailable (maintenance, overload)

For each team member’s collection, ensure you have:

  • Collection resource URI (plural noun)
  • Sub-collections identified (if relationships exist)
  • Filter table with 5 fields
  • Sorting parameters defined
  • Pagination parameters defined
  • Example queries documented

1. Collection URI: /collection-name

2. Singleton URI: /collection-name/{id}

3. Sub-Collections:

Sub-CollectionURI Pattern

4. Filter Table (5 Fields):

#FieldTypeParameterExample
1
2
3
4
5

5. Sorting:

  • ?sort=field1
  • ?sort=-field2 (descending)

6. Pagination:

  • ?page=1&limit=10

Resource TypeURI PatternExample
Collection/resources/missions
Singleton/resources/{id}/missions/123
Sub-collection/resources/{id}/subresources/missions/123/crew
Sub-singleton/resources/{id}/subresources/{subId}/missions/123/crew/456
Nested singleton/resources/{id}/subresource/missions/123/commander
Filtered/resources?param=value/astronauts?nationality=Canadian
Sorted/resources?sort=field/missions?sort=launchDate
Paginated/resources?page=N&limit=M/planets?page=1&limit=20