Let’s create a new database table by writing a native SQL query in phpMyAdmin or Sequel Pro. The intent of this episode is (1) to give you an appreciation of the schema that defines each database table and (2) to prepare you the next episode about how WordPress creates each of the database tables.
You are actively writing the schema that will define a new custom database table. Don’t worry. Tonya walks you through each step and explains it. She also gives you insights and her thought processes.
You’ll learn about specifying default values, primary keys, and foreign keys.
|CREATE TABLE ktc_videos(|
|id BIGINT(20) unsigned NOT NULL AUTO_INCREMENT,|
|post_id BIGINT(20) unsigned NOT NULL DEFAULT 0,|
|video_id VARCHAR(200) NOT NULL,|
|PRIMARY KEY (id),|
|KEY post_id (post_id)|
|DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;|
Who needs copy/paste? Right. Writing code from scratch is fun!
Total Lab Runtime: 02:08:59
- 1 Lab Introductionfree 05:17
- 2 The Big Picturepro 14:35
- 3 Your First SQL Querypro 12:21
- 4 WordPress to Database Relationshippro 20:20
- 5 Filter Content with WHEREpro 08:24
- 6 Table Alias with ASpro 05:08
- 7 Defining Table Structure (Schema)pro 12:17
- 8 Create a New Database Tablepro 10:23
- 9 WordPress Schemapro 05:11
- 10 Exploring WordPress Queries with Query Monitorpro 07:14
- 11 SQL to Get a Custom Fieldpro 16:41
- 12 SQL to Update Custom Fieldpro 05:14
- 13 Wrap it Upfree 05:54