0

Description:

I'm working on a MongoDB schema design for a flower shop application where flowers are managed at both the company (flower type) and branch (flower) levels. Each flower type is defined at the company level, while individual flowers are managed at the branch level. However, I'm facing challenges with handling customizations made at the branch level without affecting the original flower types. (I am creating python fastapi app with mongodb)

Details:

  • Collections:

    • FlowerType:
      • id: UUID
      • company_id: UUID
      • name: String
      • description: String
      • consumables: List
    • Flower:
      • flower_type_id: UUID
      • branch_id: UUID
      • quantity: Int
      • price: Float
  • Each branch can have only one flower for each flower type.

  • When a branch wants to customize a flower type (e.g., by changing consumables), I need to handle it without affecting the original flower type.

  • Changing flower_type_id in the Flower collection will disconnect the flower from the original flower type.

Goals:

  1. Allow branches to customize flower types without affecting the original flower types.
  2. Maintain a reference to the original flower type for each flower at the branch level.
  3. Ensure that changes made at the branch level do not affect other branches or the original flower types.

Challenges:

  • How to handle customizations at the branch level while maintaining a connection to the original flower types?
  • What MongoDB schema design approach should I use to achieve the desired functionality?
  • How can I structure the data to allow for efficient querying and updating?

Request:

I'm looking for suggestions on how to design my MongoDB schema to address the challenges mentioned above. Any insights, examples, or best practices would be greatly appreciated. Thank you!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.