Skip to main content

Database Schema

Alfa Commerce uses 60+ MySQL tables, all prefixed #__alfa_. This page is the map — the entities, how they relate, and the special mechanisms. For the exhaustive column-level definition, the source of truth is the install file:

📄 Full DDL: administrator/sql/install.mysql.utf8.sql

Translatable fields live elsewhere

Columns like name, alias, descriptions and meta are not on the tables below — they live in per-language auxiliary tables #__alfa_<entity>_<langtag>. See Multilingual & Translations.

Core relationships

Catalogitems is the hub; categories and manufacturers attach via M:N join tables:

Orders — an order owns several child records (all linked by id_order):

Each order also references the customer (id_user), currency, status, and the chosen method records (id_payment_method#__alfa_payments, id_shipment_method#__alfa_shipments); order_items snapshot the items (id_item) they came from.

Catalog

TablePurpose
#__alfa_itemsProduct master (SKU, stock, dimensions, weight)
#__alfa_categoriesHierarchical categories
#__alfa_items_categoriesItems ↔ categories (M:N)
#__alfa_manufacturersBrands / manufacturers
#__alfa_items_pricesPrices by currency / user group / location / quantity tier
#__alfa_items_price_indexDenormalized price index for fast filtering (see below)

Pricing rules

TablePurpose
#__alfa_discounts (+ _categories / _usergroups / _places)Discount rules + their category / group / location scope
#__alfa_taxes (+ _categories / _usergroups / _places)Tax rates + their scope
#__alfa_coupons (+ _usergroups / _users)Coupon codes + visibility / assignment

Cart & checkout

TablePurpose
#__alfa_cartCart header (user, selected payment / shipment)
#__alfa_cart_itemsCart lines (item, quantity)
#__alfa_user_infoDelivery & invoice addresses

Orders

TablePurpose
#__alfa_ordersOrder header (customer, status, methods — totals are computed, not stored)
#__alfa_order_itemsLine items with a pricing snapshot
#__alfa_order_paymentsPayment records (status, gateway data, refunds)
#__alfa_order_shipmentsShipment records (status, tracking)
#__alfa_order_detail_taxPer-item tax breakdown
#__alfa_order_cart_ruleApplied discounts / coupons per order
#__alfa_order_activity_logUnified audit log (status changes, actions)
#__alfa_order_slip (+ _detail)Invoice / packing-slip snapshots
#__alfa_orders_statusesOrder status definitions
#__alfa_orderstatus_recipientsAdmin recipients for status emails

Configuration

TablePurpose
#__alfa_paymentsPayment method records (each points at a plugin)
#__alfa_shipmentsShipping method records
#__alfa_currenciesCurrencies (200+ pre-loaded)
#__alfa_placesCountries / locations
#__alfa_form_fields (+ _form_field_groups / _form_fields_usergroups / _form_fields_users)Form-field definitions + scope
#__alfa_customsForm-field entries (submitted values)

Users

TablePurpose
#__alfa_usersCustomer profiles (with B2B fields)
#__alfa_usergroupsCustomer segments (per-group price visibility = JSON in prices_display)
#__alfa_categories_usergroups / _usersCategory visibility per group / per user

System

TablePurpose
#__alfa_mediaProduct / category / manufacturer images (path, dominant colour)
#__alfa_notificationsBackend notification centre store
#__alfa_<plugin>_logsPer-plugin log tables (auto-created from each plugin's logs.xml)

Price index

#__alfa_items_price_index is a denormalized index maintained by PriceIndexSyncService — it pre-computes prices for every (currency, location, user group) combination so the catalog can filter by price in SQL. Columns: base_price, discount_amount, base_price_with_discounts, tax_amount, base_price_with_tax (the "was" price), final_price (the primary filter column), discount_percent. Synced on item save and discount/tax change — see Pricing.

Migrations

Schema migrations live in administrator/sql/updates/mysql/, named by version (e.g. 1.0.9.sql). On update, Joomla runs every file newer than the installed schema automatically.

Removing obsolete files

SQL migrations only add or alter tables — files a release no longer ships are removed by a parallel, version-keyed mechanism. List the old paths in administrator/files/removed/<version>.json:

{
"files": ["/components/com_alfa/old-controller.php"],
"folders": ["/media/com_alfa/js/legacy"]
}

Paths are relative to the Joomla root. On update, script.php applies every list newer than the installed version (so a site that skipped releases is still fully cleaned up). Joomla never removes files dropped between versions on its own, so add this list whenever you delete or rename a shipped file.