Overview
The customers and suppliers tables manage business relationships with external parties. Theclientes table tracks customer information for sales transactions, while the proveedores table maintains supplier data for purchase operations.
Clientes Table
Theclientes table stores customer information including contact details and status.
SQL Schema
Columns
Primary key. Customer code/identifier. This is a business-defined code that uniquely identifies each customer.
Customer name or business name. Required field.
Contact phone number. Optional field.
Customer’s email address. Optional but indexed for quick searches.
Physical address or delivery location. Optional field with extended length for complete addresses.
Customer status flag. Defaults to 1 (active). Set to 0 to deactivate customer without deleting historical data.
Timestamp when the customer record was created. Defaults to current date/time (GETDATE()).
Constraints
- Primary Key:
codclien
Indexes
- IDX_clientes_nombre: Index on
nombrefor efficient customer name searches - IDX_clientes_estado: Index on
estadofor filtering active/inactive customers - IDX_clientes_email: Index on
emailfor email-based lookups
C# Model
Relationships
- One-to-Many with ventas: One customer can have multiple sales transactions
Proveedores Table
Theproveedores table stores supplier/vendor information for procurement operations.
SQL Schema
Columns
Primary key. Supplier code/identifier. This is a business-defined code that uniquely identifies each supplier.
Supplier name or business name. Required field.
Contact phone number. Optional field.
Supplier’s email address. Optional field.
Physical address or business location. Optional field with extended length for complete addresses.
Supplier status flag. Defaults to 1 (active). Set to 0 to deactivate supplier without deleting historical data.Note: Uses INT type instead of BIT (unlike clientes table), allowing for potential future expansion of status codes.
Timestamp when the supplier record was created. Defaults to current date/time (GETDATE()).
Constraints
- Primary Key:
codprovee
Indexes
- IDX_proveedores_nombre: Index on
nombrefor efficient supplier name searches - IDX_proveedores_estado: Index on
estadofor filtering active/inactive suppliers
C# Model
Relationships
- One-to-Many with compras: One supplier can be associated with multiple purchase orders
Entity Relationships
Schema Similarities and Differences
Both tables share a similar structure with these common fields:- Business code as primary key (VARCHAR(50))
- nombre, telefono, email, direccion for contact information
- estado for active/inactive status
- created_date for audit tracking
clientes.estadois BIT (boolean)proveedores.estadois INT (integer)
Usage Notes
- Both tables use business-defined codes as primary keys rather than auto-increment IDs
- The
estadofield enables soft-deletion to preserve historical transaction integrity - Email and name fields are indexed for performance in search operations
- The extended
direccionfield (300 characters) accommodates complete address information - Customer and supplier records should not be deleted if they have associated transactions (ventas/compras)