wordpress database: what's behind those 12 tables

64
WordPress Database: What’s behind those 12 tables? Mauricio Gelves | @maugelves

Upload: mauricio-gelves

Post on 12-Apr-2017

254 views

Category:

Internet


6 download

TRANSCRIPT

WordPress Database: What’s behind those 12 tables?

Mauricio Gelves | @maugelves

Do you know this Masterpiece?

@takisbig Athens, 2016

A love story

Set of columnsData typesIndexes

The table anatomy

Table rows

I’m Rebel!

Normalization

Process to avoid:

• Data redundancy • Unnecessary updates • Data integrity problems

Process to avoid:

• Data redundancy • Unnecessary updates • Data integrity problems

WordPress code of conduct:No political jokes are allowed

UPDATE tbl_students SET president = '<new president name>' WHERE president = 'Prokopis Pavlopoulos'

On every change:

Process to avoid:

• Data redundancy • Unnecessary updates • Data integrity problems

Normalized tables:

FK’s (Foreign Keys)

Is WordPress Rebel?

• wp-posts

• wp-term-taxonomy

33,3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333…%

Why WordPress powers 27% of all websites?

SHE’S FLEXIBLE

KEY => VALUE

wp_posts WordPress Heart.

wp_posts

Where’s the rest of the information?

Meta Tables

wp_posts => wp_postmeta wp_users => wp_usermeta

wp_comments => wp_commentmeta wp_terms => wp_termmeta

KEY VALUE=>

wp_posts

wp_postmeta

KEY VALUE=>

wp_users

wp_usermeta

SHE ’S ORGANIZED

KEY VALUE=>

wp_options

SHE’S ADAPTABLE

Taxonomies

Taxonomies

Terms list

Sets the taxonomy name

Es muy fácil comunicarse con ella: Diapositiva: una mujer con un teléfono

It’s easy to talk to her

SQLStructured Query Language

Query structure:Which column/s?

Which table/s?

Should we filter the search?

Do we have to know SQL to work with WordPress?

WordPress Functions:

What if we need Meta values?

WordPress Functions:

and for more complex searches?

WP_Query

CUSTOM TABLESHow and why?

Why Custom Tables?:

• Efficiency (Inner joins) • Efficiency (calculated fields) • Space (uncompleted fields) • Data security

How to create a Custom Tables?:• Create it on plugin/theme activation

How to create a Custom Tables?:• Create it on plugin/theme activation • UI implementation with WP_List class

http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/

Because of this and more I’m in love with the

WordPress database.

Thank you!

Mauricio Gelves @maugelves - maugelves.com