The database architecture in Venddor IO follows specific conventions for table naming, column structure, and relationship management. Understanding these conventions is essential for effective development and customization.
When laying out tables in the Venddor IO database, the naming convention is straightforward:
An intricate relationship among tables is illustrated below:
products - Stands for the fundamental data on products.product_features - Denotes features applicable to products.product_feature_variants - Specifies diverse feature variants.product_feature_variant_descriptions - Indicates the multi-lingual aspects of feature variant descriptions for each language.For deeper dependencies, only the final suffix in a table's name remains plural.
At the time of installation, Venddor IO lets you set a unique prefix for all its tables. By default, this prefix is set as 'venddor_'.
When dealing with database functions in Venddor IO, the symbol ?: acts as a placeholder, representing this table prefix in SQL queries. Thus, every SQL query involving a table name should be prefixed with this placeholder ?:.
Here's how you'd implement it:
$items = db_get_array(
'SELECT * FROM ?:products LEFT JOIN ?:product_popularity USING(product_id)'
);
In Venddor IO, primary and foreign key fields are prefixed with the entity's name for clarity. For instance, the unique primary key field in the 'products' table is labeled 'product_id'. For consistency and clarity when customizing Venddor IO, it's recommended to adhere to this naming convention.
Certain database entities in Venddor IO might possess attributes that vary based on language. A classic case is products having descriptions and titles in multiple languages. Here's how Venddor IO manages such multi-lingual fields:
The PHP code drives the functioning logic of such tables. Using the 'product_descriptions' as a reference:
Here's a SQL query illustration:
SELECT products.*, product_descriptions.* FROM products
INNER JOIN product_descriptions
ON product_descriptions.product_id = products.product_id
AND product_descriptions.lang_code = 'en'
While Venddor IO predominantly employs MyISAM for its tables, transitioning to InnoDB is an option without hindering Venddor IO's performance. InnoDB offers several superior features compared to MyISAM:
However, with InnoDB's structure, certain query types might be slower compared to MyISAM. Additionally, migrating to InnoDB might impact data deletion and modification orders in Venddor IO due to the architecture's foreign constraints.
In Venddor IO, PHP code takes charge of updating and deleting interconnected entities. Hence, when implementing cascading data updates and removals, it's advisable to use PHP code.
Venddor IO recommends against embedding logic directly in the database. Some servers might not provide the necessary MySQL privileges for triggers or stored procedures. Moreover, any logic integrated into the database can overlap or conflict with what's already defined in PHP code.