Magento 2 Database Overview
This documentation provides a comprehensive guide to the Magento 2 database structure, designed to help data analysts and developers understand the relationships between tables and their purposes. Magento 2 uses a complex database schema with over 300 tables organized into different modules.
Database Architecture
Magento 2 uses a modular architecture where each module has its own set of database tables. The database follows these key design patterns:
- EAV (Entity-Attribute-Value) - A flexible schema that allows for dynamic attributes without changing database structure
- Flat Tables - Denormalized tables for performance optimization in catalog and product queries
- Relational Tables - Standard normalized database tables following relational database principles
Key Database Modules
Sales & Orders
sales_*Tables related to orders, invoices, shipments, and payments
Catalog
catalog_*Product, category, and attribute information
Customer
customer_*Customer accounts, addresses, and groups
EAV
eav_*Entity-Attribute-Value core tables
Inventory
inventory_*, cataloginventory_*Stock management and inventory
CMS & Content
cms_*Content management, pages, and blocks
Common ID Patterns
Understanding these common ID patterns will help you navigate the database:
- entity_id - Primary key in most entity tables (products, customers, categories, etc.)
- *_id - Foreign keys referencing other tables (e.g., customer_id,product_id)
- increment_id - Human-readable IDs displayed to users (like order numbers: #000000001)
- store_id - References to specific store views for multi-store setup
- website_id - References to specific websites in multi-website installations
Table Naming Conventions
Magento 2 follows consistent naming patterns:
| Pattern | Description | Example | 
|---|---|---|
| module_entity | Main entity tables | sales_order,catalog_product_entity | 
| entity_type | Related data tables | sales_order_item,sales_order_address | 
| entity_eav_attribute | EAV attribute values | catalog_product_entity_varchar | 
| entity_grid | Admin grid tables (denormalized) | sales_order_grid | 
| entity_entity | Many-to-many relationship tables | catalog_product_website | 
Getting Started
For new data analysts, we recommend starting with these essential tables:
- sales_orderand- sales_order_item- For order and revenue analysis
- customer_entity- For customer demographics and segmentation
- catalog_product_entity- For product catalog analysis
- sales_order_grid- Denormalized view with most order information
Click on any module card above to explore detailed table structures, relationships, and common queries for that module.
Understanding the EAV System
The Entity-Attribute-Value (EAV) model is a key architectural pattern in Magento 2. Unlike traditional table columns, EAV stores attributes as rows, allowing for:
- Dynamic Attributes - Add new product/customer attributes without database schema changes
- Flexibility - Different products can have different sets of attributes
- Scalability - Handle thousands of attributes efficiently
EAV Tables Structure
Each EAV entity type (product, customer, category) has multiple tables:
| Table Type | Purpose | Example | 
|---|---|---|
| *_entity | Main entity data | catalog_product_entity | 
| *_entity_varchar | Text attribute values | catalog_product_entity_varchar | 
| *_entity_int | Integer attribute values | catalog_product_entity_int | 
| *_entity_decimal | Decimal attribute values (prices, weights) | catalog_product_entity_decimal | 
| *_entity_datetime | Date/time attribute values | catalog_product_entity_datetime | 
| *_entity_text | Long text attribute values | catalog_product_entity_text |