Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Giorgos Georgopoulos - Understanding WordPress WooCommerce Database - 6th Heraklion Meetup

Giorgos Georgopoulos - Understanding WordPress WooCommerce Database - 6th Heraklion Meetup

A717e9d055b2284e573b2412e32f5397?s=128

WordPress Greek Community

December 10, 2016
Tweet

Transcript

  1. Understanding WordPress/WooCommerce Database George Georgopoulos, Papaki Full Stack Web Developer

    & WP enthusiast https://github.com/ggeorg0p Heraklion 10/12/2016
  2. Introduction • High Level approach • No Multisite • No

    Optimization • Outline ◦ WordPress Core ▪ General Architecture ▪ Table Structure ◦ WooCommerce DB
  3. https://codex.wordpress.org/File:WP4.4.2-ERD.png

  4. General Architecture [WP 4.6.1] • MySQL version >=5.6 OR MariaDB

    version >=10.0 • Default prefix: “wp_” • 12 tables • Table “wp_links” no longer used in core • Hybrid entity/object-oriented and key-value store • Unique IDs (primary key: bigint[20] unsigned) for each entity within a table (Post/User/Comment/Term ID)
  5. Table Structure [WP 4.6.1] • wp_{object}s tables ◦ Main tables

    are modelled after the object they are storing: ▪ wp_posts ▪ wp_comments ▪ wp_users ▪ wp_terms • wp_{object}meta tables ◦ Each object type has a key-value meta store: ▪ wp_postmeta ▪ wp_usermeta ▪ wp_commentmeta ▪ wp_termmeta
  6. Table Structure [WP 4.6.1] • Key/Value Store (“NoSQL” like) •

    A bit like a dynamic dictionary, in table form • Values relating to objects are identified by a key • key can be any valid varchar(255); value can be any primitive or serializable object (PHP serialize function). • WP_OPTIONS ◦ option_id bigint(20) ◦ option_name varchar(64) <= key ◦ option_value longtext <= value ◦ autoload varchar(20)
  7. Table Structure [WP 4.6.1] Terms, Term Taxonomies, and Term Relationships

    • Legacy Issues • wp_terms/wp_termmeta: the Term Object/Data • wp_term_taxonomy: Taxonomy Assignment • wp_term_relationships: Object relationships ◦ object_id ◦ term_taxonomy_id ◦ term_order
  8. WooCommerce [2.6.8] • Uses Core WP tables for products, coupons,

    orders, and webhooks • wp_posts/wp_postmeta/taxonomies • Vertical structure (Horizontal coming in version 3) Custom tables (“wp_” prefix) woocommerce_sessions woocommerce_tax_rate_locations woocommerce_api_keys woocommerce_shipping_zones woocommerce_attribute_taxonomies woocommerce_shipping_zone_locations woocommerce_tax_rates woocommerce_shipping_zone_methods woocommerce_order_items woocommerce_payment_tokens woocommerce_order_itemmeta woocommerce_payment_tokenmeta woocommerce_downloadable_product_permissions
  9. Thank You :) Any Questions? George Georgopoulos, Papaki Full Stack

    Web Developer & WP enthusiast https://github.com/ggeorg0p