Skip to content

Entity: CartItem

Represents a product entry in a cart with its quantity.

Fields

FieldTypeNullableDefaultDescription
idserialnoautoPrimary key
cart_idintegernoFK to cart.id
product_idintegernoFK to product.id
quantityintegernoNumber of units (min 1)

Standard columns (created_at, updated_at, deleted_at) are inherited per ADR-007 and should not be listed here.

Relations

RelationTypeTarget entityFKOn delete
cartmany-to-oneCartcart_item.cart_idcascade
productmany-to-oneProductcart_item.product_idrestrict

Business rules

  • quantity must be at least 1.
  • A product can appear only once per cart. Adding the same product again updates the quantity by summing the values.