Item Category & SKU Structuring confusion

I’m creating a marketplace app, and am having confusion regarding the item category hierarchy and SKU optimization. To keep it simple, let’s say it is a boutique store website with mostly clothing items, and some beauty & skincare products.

Item Category problems:

How do I implement a proper category structure?

Currently, I’m manually storing Categories like this, and nesting categories together:

Is this a scalable way? As in day-to-day use cases, often new parent categories and sub-categories pop up that are hard to cope with sometimes. If there is an alternative way around, I’d love to know your suggestions.

SKU Optimization

We’re talking mostly about clothing and beauty items. The normal way for a single type of product could be sorted with:

  • SKU
    • ID
    • Size
    • Quantity
    • Material/Sewing/etc.

But here, product types are more than one, probably in the hundreds. One can be varied by colors, and the other may not have color variation (it has only one color), but it may have many different sewing options to choose from. So, one size fits all here doesn’t seem to be working.

How do I structure the variation/attributes of items?
Do I structure the Attributes by SKU or anything else?

For your marketplace database structure, here’s a practical approach:

Category Hierarchy:

Create two data types:

  • Category: fields include Name, Parent Category (type Category, optional), Image, Description

  • Product: fields include Name, Category (type Category), SKU, Description, Base Price, Images

For parent/child categories, use the self-referencing Parent Category field. When a category has no parent, it’s a top-level category. This lets you nest categories infinitely without manually hardcoding relationships.

To display nested categories, create a repeating group that searches for Categories where Parent Category is empty (shows top level). Then inside each category, add another repeating group for Categories where Parent Category = current category. This scales automatically when you add new categories.

Product Variations/Attributes:

Create these data types:

  • Attribute: Name (text, like “Color”, “Size”, “Material”)

  • AttributeValue: Attribute (type Attribute), Value (text, like “Red”, “Large”, “Cotton”)

  • ProductVariant: Product (type Product), Attributes (list of AttributeValue), SKU, Price, Quantity, Images

Each Product has a base definition, and ProductVariant holds the actual sellable items with specific combinations of attributes and their own inventory tracking.

For a blue shirt in size M:

  • Product: “Cotton T-Shirt”, Category: “Clothing > Shirts”

  • ProductVariant: SKU “SHIRT-BLUE-M”, Attributes: [Color:Blue, Size:M], Quantity: 50

This way you don’t hardcode attribute types, and can add new attributes for different product categories without changing your database structure.