{"id":2435,"date":"2015-02-04T11:53:55","date_gmt":"2015-02-04T11:53:55","guid":{"rendered":"http:\/\/wiki.davelevy.info\/?p=2435"},"modified":"2015-02-04T14:11:52","modified_gmt":"2015-02-04T14:11:52","slug":"wordpress-database-schema","status":"publish","type":"post","link":"https:\/\/davelevy.info\/wiki\/wordpress-database-schema\/","title":{"rendered":"WordPress Database Schema"},"content":{"rendered":"<p>While working on Nulis and while attempting to solve some other problems I began to need to document the contents of wordpress databases. The first problem I sought to solve was to build a visual map of the site. This needs the schema to be understood and the table contents to be extracted. This needs the login parameters and a connection route. The second problem involves creating a new template and will need it&#8217;s SQL designed and encapsulated in PHP.<!--more--><\/p>\n<p><a title=\"Relationship with Tags, Catagories and Posts at Dimuthu's blog\" href=\"http:\/\/www.dimuthu.org\/blog\/2008\/12\/20\/wordpress-database-relationship-with-tags-catagories-and-posts\/\">This article<\/a> documents the <strong>relationships between tags and posts<\/strong>, which can be categories and pages.<\/p>\n<p>In order to extract the schema logic, I was pointed at<a href=\"http:\/\/stackoverflow.com\/questions\/2488\/auto-generate-database-diagram-mysql\"> this page at Stack Over flow<\/a>.<\/p>\n<p>From these I examined,<\/p>\n<ol>\n<li><a href=\"http:\/\/schemaspy.sourceforge.net\/\">http:\/\/schemaspy.sourceforge.net\/<\/a> &amp;<\/li>\n<li><a href=\"https:\/\/code.google.com\/p\/database-diagram\/\">https:\/\/code.google.com\/p\/database-diagram\/<\/a><\/li>\n<\/ol>\n<p>the first requires java which is not always available in hosting environments, the second doesn&#8217;t seem to do foreign keys, at least not with My SQL, it does however work from the SQL\/DDL. It might be best to extract the schema using mysqldump, parse it using a scripting language and generate the graph using dot. (This of course could be used to generate an html page).<\/p>\n<p>While looking for an image to decorate this page, using google image search with the keywords &#8220;wordpress database&#8221;\u00a0 I came across a bunch of schema diagrams, I wonder if these are useful and usable. It would seem they are, here is <a href=\"http:\/\/codex.wordpress.org\/Database_Description\">Database Descriptions at the WordPress Codex<\/a>. It&#8217;s documented as V3.3, so I will check if it&#8217;s changed since.<\/p>\n<p>Here is the schema diagram.<\/p>\n<p><a href=\"http:\/\/codex.wordpress.org\/Database_Description\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"WP DB Schema taken from the codex\" src=\"http:\/\/codex.wordpress.org\/images\/thumb\/9\/97\/WP3.8-ERD.png\/500px-WP3.8-ERD.png\" alt=\"wp db schema\" width=\"500\" height=\"698\" \/><\/a><\/p>\n<p style=\"text-align: center;\">ooOOOoo<\/p>\n<p>The featured image taken from <a href=\"http:\/\/www.metserve.com\/blog\/optimise-wordpress-database\">http:\/\/www.metserve.com\/blog\/optimise-wordpress-database<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While working on Nulis and while attempting to solve some other problems I began to need to document the contents of wordpress databases. The first problem I sought to solve was to build a visual map of the site. This needs the schema to be understood and the table contents to be extracted. This needs&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2436,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_share_on_mastodon":"0"},"categories":[3,584],"tags":[496,812,911,28],"class_list":["post-2435","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","category-wordpress-technology","tag-database","tag-schema","tag-technology","tag-wordpress"],"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"https:\/\/davelevy.info\/wiki\/wp-content\/uploads\/2015\/02\/Optimize-WordPress.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/2435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/comments?post=2435"}],"version-history":[{"count":1,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/2435\/revisions"}],"predecessor-version":[{"id":2437,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/2435\/revisions\/2437"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media\/2436"}],"wp:attachment":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media?parent=2435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/categories?post=2435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/tags?post=2435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}