Magento Database Configuration File: Table Components & Systems

Magento Database Configuration File: Table Components & Systems

Are you struggling to understand how your online store's data is organized & managed? The Magento database is the foundation of every Magento-powered ecommerce store. It handles everything from product information to customer orders.

This tutorial will cover the advanced configuration aspects of Magento's database structure.

Best Magento Hosting now

Key Takeaways

  • Configuration steps and best practices for ensuring data integrity.
  • Insights into how the vertical database model handles product, customer, and sales data.
  • Management methods to optimize & understand custom database structure and its role in e-commerce.
  • Key features of adding new database attributes.
  • Tips to better manage your store with the EAV model and database configuration file.
  • Troubleshooting common challenges for configuring and optimizing your database configuration file.

What is the Magento 2 Database Structure?

"The Magento database structure consists of multiple tables. They work together to store and organize your store's data."

Magento database tables are organized based on their functions, such as:

  • Product data
  • Order data
  • Customer information

Core Secondary Table Components of Magento Database Structure

Component Type Tables Purpose Key Features Key Fields
Core Configuration core_config_data, core_store Store system settings and basic configurations - Manages global settings.
- Handles store-specific configurations.
- Controls website behavior.
- config_id
- path
- value
EAV Foundation eav_entity, eav_attribute Implements flexible data storage - Enables dynamic attribute creation.
- Supports multiple data types.
- Facilitates custom field addition.
- attribute_id
- entity_type_id
- attribute_code
Catalog Management catalog_product_entity, catalog_category_product Manages product and category data - Stores product information.
- Handles category relationships.
- Manages inventory data.
- entity_id
- parent_id
- path
- level
Customer Data customer_entity, customer_address_entity Stores customer information - Maintains customer profiles.
- Manages addresses.
- Handles customer groups.
- entity_id
- email
- website_id
- store_id
Sales Processing sales_order, sales_order_item, sales_flat_order Manages order processing - Tracks order status.
- Stores order details.
- Handles invoicing.
- order_id
- status
- total
Index Management catalog_product_index_price, catalog_category_product_index Optimizes performance - Speeds up queries.
- Improves search efficiency.
- Enhances browsing experience.
- entity_id
- customer_group_id
- price
Review System review, rating, review_entity Handles product feedback - Stores customer reviews.
- Manages ratings.
- Tracks feedback metrics.
- review_id
- product_id
- customer_id
Quote Management sales_flat_quote Handles shopping cart data - Records every cart created in the store.
- Tracks both converted and abandoned shopping carts.
- Provides configurable retention period (usually 60 days for unconverted carts).
- Handles carts across different store views.
- Links carts to customer sessions and IDs.
- quote_id
- customer_id
- store_id
Invoice Records sales_flat_invoice Stores invoice information - Supports the creation of multiple invoices per order.
- Stores detailed tax calculations and amounts.
- Records shipping amounts and information.
- Maintains permanent record of processed orders.
- Supports invoice-specific comments through sales_flat_invoice_comment.
- Provides data for admin grid display through sales_flat_invoice_grid.
- Records individual order items through sales_flat_invoice_item.
- Stores payment confirmation and total paid amounts.
- invoice_id
- order_id
- total_paid
Logging System report_event, log_visitor Tracks system activities - Monitors user activity.
- Records system events.
- Stores error logs.
- time
- action_group
- action
- ip_address
- username
- result
- full_action_name
- query_time
- query_type
- logger_alias
- log_all_queries
- call_stack
- log_id
- severity_level
- timestamp
- message
- source
- debug_id
- timestamp
- message
- debug_data
- is_exception
- action_id
- start_time
- description
- status
- details

What Database Does Magento Use?

magento platform integrated with mysql database system

Databases used a rigid structure. Here, product attributes are all contained within a single table. Any changes to a product’s details require modifying the entire table, resulting in a lot of manual work.

Magento uses the MySQL database with an Entity-Attribute-Value (EAV) model. This management system allows for space-efficient data encoding, offering the following benefits:

  • Product variations (like different sizes/colors) share core data, reducing duplicate entries.
  • Only used attributes consume space, unlike traditional tables where empty columns waste space.
  • Data queries can be optimized for specific attributes without loading entire product records.
  • The system scales efficiently as your product catalog grows.

For example, a t-shirt with "5 sizes" and "4 colors "creates "20 variations", but it stores shared data only once. Examples include description, brand, material.

With EAV, Magento can handle complex business models with ease. This model makes code reuse simpler and more efficient. It supports diverse product attributes & combinations efficiently. Create configurable products from simple ones without changing the entire product structure. This flexibility allows you to grow with your business.

The EAV model separates attributes and their values from the main entity. It stores attributes like name, price, & size independently of the product entity itself. You can add, modify, or remove attributes easily. It allows for greater flexibility.

Magento splits product attributes across different tables rather than using a single table. Consider the following:

  • You can add new product attributes without altering the database structure. For example, 'warranty period' or 'material type'.
  • Each product only stores relevant attributes, saving database space.
  • Different product types can have different sets of attributes. For example, shoes need 'size' while digital downloads don't.
  • Updates to attribute values don't require modifying the main product table.

Magento Commerce Database Management Systems Using MySQL

Feature Category MySQL Capabilities Magento Implementation Business Impact
Performance Optimization - InnoDB storage engine
- Query cache management
- Multi-threading support

For example, during a flash sale, the system can handle hundreds of concurrent product page views.
- EAV model utilization
- Custom indexing
- Cache management system
- Faster page loads
- Better customer experience
- Reduced server load
Scalability Features - Handles "50M+" rows
- "8TB" theoretical limit
- Cluster support
- Multi-store capability
- Horizontal scaling
- Distributed database support
- Growth flexibility
- Multiple store management
- Enterprise readiness
Security Implementation - Access privilege system
- Password encryption
- Host-based verification
- Role-based access
- Encrypted customer data
- Secure payment handling
- Data protection
- PCI compliance
- Fraud prevention
High Availability - Master/slave replication
- 24/7 uptime
- Server clustering
- Multiple database instances
- Failover support
- Load balancing
- Business continuity
- Zero downtime updates
- Reliable operations
Transaction Management - ACID compliance
- Row-level locking
- Deadlock identification
- Order processing
- Inventory management
- Payment handling
- Data integrity
- Accurate transactions
- Reliable checkout
Resource Efficiency - Low memory leakage
- Optimized storage
- Fast loading utilities
- Efficient indexing
- Query optimization
- Cache implementation
- Lower hosting costs
- Better resource usage
- Improved ROI
Maintenance Features - Backup utilities
- Recovery tools
- Monitoring systems
- CLI commands
- Admin interface
- Automated maintenance
- Easy management
- Quick troubleshooting
- Reduced downtime
Integration Capabilities - API support
- Third-party compatibility
- Custom plugins
- Extension system
- API endpoints
- Custom module support
- System flexibility
- Easy customization
- Scalable solutions

7 Steps to Configure System Details with Magento db Config File

  1. Use a MySQL client like phpMyAdmin to access your Magento database.
  2. Navigate to app/etc/env.php in your Magento root directory.
  3. Ensure your connection parameters & configuration settings are correctly set up in env.php.
  4. Adjust settings in the database configuration file to optimize performance.

For instance, you can:

  • Adjust the max_connections value based on your traffic needs.
  • Configure innodb_buffer_pool_size for better performance.
  • Set appropriate wait_timeout values.

Note: This setting determines the maximum number of simultaneous connections to the database.

  1. Save the configuration file.
  2. After making changes, clear the cache to ensure the updates are applied.
  3. Go to the Magento admin panel or run the following command in the terminal:

php bin/magento cache:flush

Magento Installation and Database Performance Optimization

Phase Component Requirements/Actions Performance Impact
Pre-Installation Server Setup - PHP 7.4 or higher
- MySQL/MariaDB
- Apache/Nginx - Composer

- Foundation for performance
- System stability
- Resource efficiency
Installation Methods Deployment Options - Composer (recommended)
- Git repository
- Archive file (ZIP/TAR)
- Installation speed
- Update flexibility
- Version control
Database Configuration Initial Setup - Database creation
- User privileges
- Character set (UTF-8)
- InnoDB engine
- Query performance
- Data integrity
- Storage optimization
Performance Features Core Optimization - Flat catalog enablement
- Full page cache
- Redis integration
- Varnish implementation
- Faster page loads
- Reduced server load
- Better user experience
Database Tuning MySQL Optimization - Buffer pool size
- Query cache
- Table indexing
- Connection pooling
- Query speed
- Resource utilization
- Transaction efficiency
Caching Strategy Multi-Level Cache - Browser caching
- Server-side cache
- Database query cache
- Object caching
- Reduced load times
- Lower server stress
- Improved scalability
Maintenance Regular Tasks - Database cleanup
- Log management
- Index optimization
- Cache flush scheduling
- Sustained performance
- System health
- Resource availability
Monitoring Performance Tracking - Query monitoring
- Resource usage
- Cache hit rates
- Response times
- Issue identification
- Optimization opportunities
- Performance metrics

Advanced Features of the Database System in Magento

1. Scalability

The Magento backend is the central repository for storing information in your store. This database is built on MySQL, a widely used open-source relational database system. It manages everything, including:

  • Product catalogs
  • Customer details
  • Order history
  • Website settings

2. EAV Data Model

magento eav data model hierarchy connecting entity model to value tables

Magento uses a unique Entity-Attribute-Value (EAV) model, allowing flexibility in data storage. The database can store information efficiently, even if entities have different attributes.

3. MySQL 8 Integration

Heavy-load production systems support MySQL 8 capabilities for:

  • Twice as fast query processing
  • Enhanced security protocols
  • Better resource management
  • Advanced data encoding

4. Multi-Store Management

The multi-store database handles the core database schema. It shares the same core_website structure for efficiency.

Each store view gets its own:

  • Unique store_id
  • Independent website_id
  • Separate group_id

5. Elasticsearch Integration

Elasticsearch lets you use the following:

  • Lightning-fast product searches
  • Smart autocomplete
  • Real-time indexing
  • Reduced database load

6. Backup and Recovery

The Magento Open Source database connection includes:

  • Automated backup scheduling
  • Point-in-time recovery options
  • Differential backups
  • Quick restore capabilities

7. Security

magento database security features including encryption and access control

Modern security features include:

  • Advanced encryption for sensitive customer data
  • Role-based access control
  • SQL injection prevention
  • Regular security patches

8. Performance Optimization Tools

Built-in tools for additional database types include:

  • Query performance monitoring
  • Index management
  • Cache optimization
  • Database cleanup

Oracle Corporation Best Practices for Magento Database Configuration

Configuration Area Best Practices Implementation Benefits
Control Files - Apply two control files.
- Set large CONTROL_FILE_RECORD_KEEP_TIME.
- Allow "~200MB" per control file.
- Enhanced backup security
- Quick recovery options
- Damage protection
Log Management - Enable ARCHIVELOG mode.
- Set LOG_BUFFER to "128MB+".
- Configure multiple redo log files.
- Hot backup capability
- Improved performance
- Better recovery options
Performance Tuning - Use Fast-Start Checkpointing.
- Enable block checksums.
- Set TIMED_STATISTICS to "TRUE".
- Predictable recovery time
- Data integrity
- Performance monitoring
Space Management - Use locally managed tablespaces.
- Implement automatic undo management.
- Enable resumable space allocation.
- Efficient space usage
- Better concurrency
- Reduced maintenance
Security Implementation - Set up a centralized parameter file (SPFILE).
- Enable forced logging mode.
- Implement database block checking.
- Simplified management
- Data protection
- Corruption prevention
Recovery Options - Configure Fast Recovery Area.
- Enable Flashback Database.
- Set recovery file destination.
- Centralized backup location
- Quick restore capability
- Disaster recovery
Resource Allocation - Set up Database Resource Manager.
- Configure temporary tablespace.
- Conduct memory management techniques.
- Optimized resources
- Better sort operations
- Enhanced performance
Maintenance Schedule - Gather regular statistics.
- Automated backup routines.
- Implement performance monitoring.
- Consistent performance
- Data safety
- Proactive management

EAV and Magento Extension Attributes

Magento offers two types of attributes that help developers extend its functionality with ease:

1. Custom and EAV Attributes

Magento automatically adds custom attributes without support. These attributes include shape, size, or volume. Merchants define them through the Magento admin panel to describe products. The EAV attributes are primarily used by Magento modules, such as:

  • Catalog
  • Customer
  • Order

2. Extension Attributes

magento database extension attributes with search, analytics, and financial modules

Extension attributes allow developers to extend Magento's capabilities using more complex data types. Unlike custom attributes, extension attributes do not appear within the Magento admin panel. But they provide additional functionality for Magento modules.

Common Shipment or Cancellation Issues and Solutions in Magento Database

Issue Category Problem Description Database Impact Solution
Order Status Conflicts - Cannot cancel processing orders
- Status stuck in "pending"
- Invalid status transitions
- Inconsistent order_status table
- Corrupted status flags
- Transaction log errors
- Clear status flags in the database.
- Update order status manually.
- Rebuild indexes.
Inventory Sync - Stock not updating after cancellation
- Incorrect quantity reversals
- Multiple inventory entries
- Mismatched cataloginventory tables
- Duplicate stock entries
- Index corruption
- Reindex inventory.
- Clean duplicate entries.
- Sync inventory tables.
Payment Integration - Refund not processing
- Payment status mismatch
- Gateway synchronization
- Incomplete transaction records
- Payment table inconsistencies
- Missing refund entries
- Verify payment tables.
- Clear pending transactions.
- Update payment status.
Shipment Records - Unable to cancel shipments
- Missing shipment data
- Duplicate shipment entries
- Corrupted sales_shipment tables
- Incomplete shipping records
- Grid data misalignment
- Reset shipment status.
- Clean grid tables.
- Rebuild shipping data.
Credit Memo Issues - Credit memo generation fails
- Incorrect refund amounts
- Missing credit records
- Inconsistent creditmemo tables
- Transaction record errors
- Missing entries
- Verify credit memo tables.
- Update refund records.
- Clean transaction logs.
Database Performance - Slow cancellation processing
- Timeout during operations
- Heavy table loads
- Large transaction tables
- Unoptimized indexes
- Resource constraints
- Optimize tables.
- Clean old records.
- Index management.
Multi-Store Conflicts - Store-specific cancellation issues
- Cross-store inventory problems
- Mixed store data
- Store view inconsistencies
- Mixed store IDs
- Scope conflicts
- Verify store mappings.
- Clean store-specific data.
- Update store relations.
Cache Management - Cache invalidation issues
- Stale data display
- Performance degradation
- Cache table corruption
- Invalid cache entries
- Cache synchronization
- Flush specific caches.
- Clean cache tables.
- Rebuild cache.

Where and How to Find Magento Database Configuration Files?

Suppose you do not know the database credentials but have FTP access. In that case, you can find the Magento database access details as follows:

  1. Backup changes & edits database details, as well as updates server hostname, username, & password.

Note: You can also change the database name to work with MySQL servers.

  1. Navigate to: <Magento Install Dir>/app/etc/env.php.
  2. Edit the env.php configuration file.
  3. Look for the following settings to make the required changes:
  • 'host'
  • 'dbname'
  • 'username'
  • 'password'
  1. Save the updates.

Note: It is not recommended to use the object manager to get system config values in .phtml files.

Often, changes are made to the system, and no one from the admin team knows how or why they occurred. To prevent this, you should use the Magento 2 Admin Actions Log extension. It allows you to track all actions, store log data for a defined period, and send notifications. It protects your store from unauthorized login attempts and ensures your store's security.

5 Steps to Edit Magento 2 Database Configuration File

  1. From the root of your Magento directory, navigate to <Magento Install Dir>/app/etc/, and edit the env.php file.

Note: This file contains all the necessary database configuration information.

  1. All database configurations are located in the 'db' node. Here, you can edit values related to your configuration file, such as:
  • host: Your host address.
  • dbname: The name of your Magento website database.
  • username & password: Credentials for accessing the database.
  1. Remember to save the file and clear your cache by navigating to your Magento backend.
  2. Go to System > Tools > Cache Management.
  3. Click on Flush Magento Cache to apply the updates.

Tips for Navigating the Magento 2 Database

1. Magento Database Diagrams

You can find community-created diagrams illustrating the Magento 2 database structure. These diagrams provide visual representations of the relationships between database tables.

2. Magento Database Tables

Familiarize yourself with core database tables that store vital information:

  • catalog_product_entity: Stores basic product information.

  • eav_ tables:* Store Entity-Attribute-Value (EAV) data, such as eav_attribute and catalog_product_entity_*.

  • sales_ tables:* Store sales order, invoice, and shipment data.

  • customer_ tables:* Contain customer-related information.

  • quote_ tables:* Store data related to the shopping cart.

3. Magento Entity Types

Magento uses different types of entities, such as products, customers, and orders. Understanding these types helps interpret data across multiple tables.

4. Magento Codebase

Exploring the codebase sections related to your data can help Magento developers. Models, resource models, and repositories all interact with the database.

5. Community Documentation and Articles

Look for community-contributed documentation, blogs, and articles. They explain the Magento database structure for reporting purposes. Forums and Magento-related websites can also provide insights into valuable resources.

6. Database Visualization Tools

Tools like MySQL Workbench help visualize the Magento database schema. It makes it easier to understand relationships and structures.

7. Third-Party Extensions

If third-party extensions are installed, they may provide insights into the database structure. For more information, you can visit the Magento Extension Developer's Guide.

8. Magento 2 Official Documentation

The official Magento 2 documentation is valuable for understanding concepts like:

  • Data flows
  • Terminology

FAQs

1. What is the difference between Magento 1 and version 2.4?

Magento 1 uses a basic database setup with limited scalability. Magento Version 2.4 offers improved performance and security features. The newer version supports modern MySQL 5.7 and higher. It handles more complex data relationships, which brings better speed and mobile-friendly features.

2. How does MySQL work as an open-source relational database in Magento?

MySQL runs on a client-server model. It stores Magento data in organized tables & manages connections between different data types. It handles multiple users at once, which makes MySQL ideal for networked environments.

3. Where can I find the local.xml file when I install Magento?

The local.xml file sits in the app/etc/local.xml directory. This file holds database connection settings and stores your MySQL login details. Always keep a backup of this file, and remember not to share its content publicly.

4. How does Magento manage SKUs belonging to an entity?

Each product SKU links to specific database tables. Products share common attributes in the database structure. The EAV model organizes product data efficiently, which allows quick product information updates. It enables different entities to reference the same SKU.

5. Why do many companies use MySQL in their tech stacks?

MySQL offers reliable data storage and management. The system works with most hosting providers & runs well in high-traffic online stores. MySQL supports multiple programming languages, which are free and community-supported.

6. What makes Magento's data model suitable for ecommerce?

The data model handles complex product relationships. It supports unlimited custom product attributes and manages multiple store views efficiently. Product data updates happen in real-time, and customer information stays organized and accessible.

7. How does Magento communicate with the server using MySQL?

MySQL is an open-source relational system for database management. The Magento model is a data model that connects multiple tables between the server and the store. MySQL processes these requests on the server side to fetch or update information. The server returns data to your Magento store through secure database connections.

CTA

Summary

The Magento database database system ensures smooth operations while managing complex data relationships through MySQL and the EAV (Entity-Attribute-Value) model. It allows Magento store owners and developers:

  • Better understand their database management needs.
  • Manage and provide flexibility to their e-commerce store effectively.
  • Ensure smooth data management for products, customers, orders, and more.
  • Maintain an efficient and scalable e-commerce system.
  • Make a significant difference in how you manage your online store.

Improve store performance and streamline database operations with Magento optimized server.

Dikshya Shaw
Dikshya Shaw
Technical Writer

Dikshya leverages her content marketing and writing proficiency to deliver fresh, insightful content. Her meticulous research ensures industry expertise and emerging trends within the Magento landscape.


Get the fastest Magento Hosting! Get Started