Vehicles Collection #44

Closed
opened 2025-10-22 14:21:02 +00:00 by GFMpt13 · 1 comment
GFMpt13 commented 2025-10-22 14:21:02 +00:00 (Migrated from github.com)

This task involves designing the MongoDB collection to store vehicle information, as part of requirement RF01.

Each vehicle document will be directly linked to a document in the clients collection, establishing the one-to-many relationship (one client can own multiple vehicles).

Tasks

  • Define the schema for the vehicles collection (fields: licensePlate, brand,model, vin (nr chassis), lastKms).
  • Implement the relationship by adding a clientId field (using ObjectId) that references the _id in the clients collection.
  • Identify necessary indexes for fast lookups (e.g., a unique index on vehicles.licensePlate to prevent duplicates and an index on clientId to quickly find all vehicles for a specific client).
  • Document that the _id of a vehicle will be used as a reference (vehicleId) in the workOrders collection.
This task involves designing the MongoDB collection to store vehicle information, as part of requirement **RF01**. Each vehicle document will be directly linked to a document in the `clients` collection, establishing the one-to-many relationship (one client can own multiple vehicles). ### Tasks - [x] Define the schema for the `vehicles` collection (fields: `licensePlate`, `brand`,`model`, `vin` (nr chassis), `lastKms`). - [x] Implement the relationship by adding a `clientId` field (using `ObjectId`) that references the `_id` in the `clients` collection. - [x] Identify necessary indexes for fast lookups (e.g., a **unique index** on `vehicles.licensePlate` to prevent duplicates and an index on `clientId` to quickly find all vehicles for a specific client). - [x] Document that the `_id` of a vehicle will be used as a reference (`vehicleId`) in the `workOrders` collection.
GFMpt13 commented 2025-10-22 18:31:25 +00:00 (Migrated from github.com)

This is the collection for vehicles that I came up with, if you have any sugestions or want to change anything please respond here. @miguelmiranda20

Image

The three essential queries we need to optimize:

"Does this vehicle already exist?" (by registration) -> Unique Index

"What vehicles does this customer own?" -> Simple Index

"Does this chassis (VIN) already exist?" -> Unique Partial Index

This is the collection for vehicles that I came up with, if you have any sugestions or want to change anything please respond here. @miguelmiranda20 <img width="367" height="261" alt="Image" src="https://github.com/user-attachments/assets/953a067f-5f60-432e-8678-0f981d3122e2" /> The three essential queries we need to optimize: "Does this vehicle already exist?" (by registration) -> Unique Index "What vehicles does this customer own?" -> Simple Index "Does this chassis (VIN) already exist?" -> Unique Partial Index
Sign in to join this conversation.
No description provided.