Overview
The Categories module enables you to organize products into logical groups for better inventory management, reporting, and navigation. Each product in the system can be assigned to a category for classification.Category Entity
Categories are stored in thecategoria table with the following properties:
Unique identifier for the category (auto-incremented primary key)
Category code (max 20 characters). Must be unique across all categories.
Category name (max 150 characters)
Detailed description of the category (max 300 characters)
Indicates whether the category is active (defaults to
true)Timestamp when the category was created (defaults to current date/time)
Database Schema
Indexes
The categories table includes optimized indexes for performance:- IDX_categoria_codigo: Unique index on
codigofield for fast lookups and duplicate prevention - IDX_categoria_nombre: Index on
nombrefor efficient name-based searches - IDX_categoria_estado: Index on
estadoto quickly filter active/inactive categories
Category-Product Relationship
Categories have a one-to-many relationship with products:One-to-Many
A single category can contain multiple products. Products reference categories via the
codCategoria foreign key.Optional Assignment
Products can exist without a category assignment (
codCategoria is nullable in the products table).Category Operations
Creating Categories
When creating a new category:Add Description
Optionally provide a
Descripcion to give more context about what products fit this categoryCategory Code Examples
Enabling/Disabling Categories
Categories can be deactivated without deletion:- Active (
Estado = 1): Category appears in product selection and reports - Inactive (
Estado = 0): Category is hidden but existing product associations remain
Disabling a category does not affect existing products assigned to it. Products retain their category assignment even when the category is inactive.
Deleting Categories
Model Reference
The C# model for Category (TechCore.Models.Categorium) includes:
The model uses the singular form
Categorium following Entity Framework’s naming conventions for the plural table name categoria.Querying Categories
Get All Active Categories
Get Categories with Product Count
Find Categories Without Products
Reporting and Analytics
Inventory by Category
Inventory by Category
Generate reports showing stock levels, total value, and product counts grouped by category for inventory analysis.
Sales Performance by Category
Sales Performance by Category
Track which categories generate the most revenue by joining sales data with product categories.
Category Profitability
Category Profitability
Calculate profit margins by comparing purchase prices (
precioCompra) and sale prices (precioVenta) within each category.Low Stock Alerts by Category
Low Stock Alerts by Category
Monitor products that fall below minimum stock levels (
stockMinimo) organized by category.Integration with Products
Products reference categories through thecodCategoria foreign key:
Best Practices
Logical Grouping
Create categories that reflect how your business naturally organizes products. Avoid creating too many narrow categories.
Code Consistency
Establish and follow a consistent format for category codes (e.g., CAT-XXX or CTG-XXXX).
Clear Descriptions
Write clear descriptions to help users understand what products belong in each category.
Regular Cleanup
Periodically review categories to merge duplicates or remove unused ones.
Category Management Tips
Categories help with:
- Faster product searches and filtering
- Organized inventory reports
- Better analytics and sales insights
- Simplified product management
- Enhanced user navigation