{"id":4972,"date":"2026-08-16T21:07:47","date_gmt":"2026-08-16T21:07:47","guid":{"rendered":"https:\/\/nmi.cool\/advweb\/?page_id=4972"},"modified":"2026-08-16T21:07:47","modified_gmt":"2026-08-16T21:07:47","slug":"exercise-databases","status":"publish","type":"page","link":"https:\/\/nmi.cool\/advweb\/exercise-databases\/","title":{"rendered":"Exercise: Databases"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Time to put our database thinking to work!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this exercise, we&#8217;re going to take a simple list of Athens coffee shops, turn that list into structured data, and then use WordPress to <strong>store, interact with, retrieve, and present<\/strong> that information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our process will be:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>STRUCTURE \u2192 STORE \u2192 INTERACT \u2192 RETRIEVE \u2192 PRESENT<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>STRUCTURE: Build the Data<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start with our collection of Athens coffee establishments:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1000 Faces<\/li>\n\n\n\n<li>Bitty &amp; Beau&#8217;s<\/li>\n\n\n\n<li>Buvez<\/li>\n\n\n\n<li>Cafe Racer<\/li>\n\n\n\n<li>Hendershot&#8217;s<\/li>\n\n\n\n<li>Jittery Joe&#8217;s<\/li>\n\n\n\n<li>Molly&#8217;s Coffee Company<\/li>\n\n\n\n<li>Sips Espresso Cafe<\/li>\n\n\n\n<li>The Rook &amp; Pawn<\/li>\n\n\n\n<li>Walker&#8217;s Coffee &amp; Pub<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new Google Sheet and put each establishment on its own row.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need some fields!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a class, decide what information would actually be useful to someone trying to choose a coffee shop.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Possible attributes could include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Neighborhood<\/li>\n\n\n\n<li>Local or Chain<\/li>\n\n\n\n<li>Outdoor Seating<\/li>\n\n\n\n<li>Food<\/li>\n\n\n\n<li>Study Friendly<\/li>\n\n\n\n<li>Dog Friendly<\/li>\n\n\n\n<li>Hours<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t just add every possible field you can think of.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What information would actually be useful to collect?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add the attributes we choose as column headings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Think About Your Values<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now add some information about the coffee shops to the spreadsheet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As you work, pay attention to places where the data gets messy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, if we have an <strong>Outdoor Seating<\/strong> field, are Yes and No enough?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What should we do if:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>we don&#8217;t know?<\/li>\n\n\n\n<li>seating is seasonal?<\/li>\n\n\n\n<li>the answer varies by location?<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t worry if the answers aren&#8217;t obvious. That&#8217;s part of the exercise!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Create a Taxonomy<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next, look for repeated values and useful ways to group our collection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We need to decide which information would work well as <strong>Categories<\/strong> and which information would work well as <strong>Tags<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remember:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Categories organize. Tags describe across that organization.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, we might decide:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Categories<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Downtown<\/li>\n\n\n\n<li>Five Points<\/li>\n\n\n\n<li>Boulevard<\/li>\n\n\n\n<li>Normaltown<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Tags<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Local<\/li>\n\n\n\n<li>Chain<\/li>\n\n\n\n<li>Outdoor Seating<\/li>\n\n\n\n<li>Dog Friendly<\/li>\n\n\n\n<li>Study Friendly<\/li>\n\n\n\n<li>Serves Food<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now ask yourself:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What will this structure allow us to retrieve later?<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MAP: Translate Your Model to WordPress<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Our spreadsheet represents our <strong>conceptual model<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need to figure out how to implement that model in WordPress.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Regular WordPress Posts provide:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Title<\/li>\n\n\n\n<li>Content<\/li>\n\n\n\n<li>Excerpt<\/li>\n\n\n\n<li>Featured Image<\/li>\n\n\n\n<li>Categories<\/li>\n\n\n\n<li>Tags<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Decide where the information from our spreadsheet should go.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Name \u2192 Post Title<\/strong><strong><br><\/strong><strong>Neighborhood \u2192 Category<\/strong><strong><br><\/strong><strong>Amenities \u2192 Tags<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not everything will map perfectly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s okay!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conceptual model \u2260 implementation.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Part of working with an existing framework is figuring out how to use the structures it already provides.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>STORE: Open WordPress Playground<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Visit:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/wordpress.org\/playground\/\">WordPress Playground<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress Playground creates a temporary WordPress installation right inside your browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, create the <strong>Categories<\/strong> we decided on as a class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then create a new Post for one of our coffee shops.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Your Post should include at least:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Title<\/li>\n\n\n\n<li>Content<\/li>\n\n\n\n<li>Category<\/li>\n\n\n\n<li>Tags<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You may also use an Excerpt and Featured Image if they make sense for our model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Publish your Post when you&#8217;re finished.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then repeat the process until we have <strong>2\u20133 coffee shops<\/strong> stored in WordPress.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Look Behind the Curtain \ud83d\udc40<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ve entered our information into WordPress, but where did it actually go?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open WordPress Playground&#8217;s <strong>Database<\/strong> controls.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open <strong>phpMyAdmin<\/strong> and locate:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">wp_posts<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Look through the records and see if you can find one of the coffee shop Posts you just created.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you find it, identify:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>the table<\/li>\n\n\n\n<li>a row \/ record<\/li>\n\n\n\n<li>a column \/ field<\/li>\n\n\n\n<li>a value<\/li>\n\n\n\n<li>the Post&#8217;s ID<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Compare what you&#8217;re looking at to our Google Sheet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What looks familiar?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll also notice that WordPress stored much more information than we explicitly entered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s because WordPress needs additional data to make the application work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You are <strong>not<\/strong> expected to understand the WordPress database structure, and you should <strong>not edit anything directly in the database<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;re just visiting. Say hello to the database and get outta there. \ud83d\udc4b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>INTERACT: CRUD<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Return to the regular WordPress interface.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s perform all four CRUD operations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Create<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create and publish a coffee shop Post.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Read<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">View the published Post.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Update<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Edit something about the Post and save your changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Delete<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a temporary test Post and move it to the Trash.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You just:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Created<\/strong><strong><br><\/strong><strong>Read<\/strong><strong><br><\/strong><strong>Updated<\/strong><strong><br><\/strong><strong>Deleted<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">some persistent data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CRUD!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>RETRIEVE: Put Our Structure to Work<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s see why we bothered organizing our information. Open one of your coffee shop Posts and click its <strong>Category<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What does WordPress show you? Try another Category.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now click one of your <strong>Tags<\/strong>. Again, pay attention to what WordPress retrieves.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think about the following:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Did we manually build this page?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Did we copy the coffee shop Posts onto it?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why did WordPress know which Posts to display?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress can retrieve these particular subsets because we gave our data structure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>STRUCTURE makes RETRIEVE possible.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>PRESENT: One Record, Multiple Views<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Pick one of your coffee shops and see how many different places you can find it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Can you find the same Post in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>its individual Post view?<\/li>\n\n\n\n<li>the main Posts listing?<\/li>\n\n\n\n<li>a Category archive?<\/li>\n\n\n\n<li>a Tag archive?<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Remember, WordPress isn&#8217;t storing a separate copy of the coffee shop for each page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s retrieving the same stored data and <strong>presenting it in different contexts<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Data \u2260 Presentation<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Put It All Together<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Think back through everything we just did:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>STRUCTURE<\/strong><strong><br><\/strong>We decided what information mattered and how to organize it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>STORE<\/strong><strong><br><\/strong>We entered that information into WordPress.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>INTERACT<\/strong><strong><br><\/strong>We used CRUD operations to work with our data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>RETRIEVE<\/strong><strong><br><\/strong>We used Categories and Tags to access meaningful subsets of the collection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>PRESENT<br><\/strong>WordPress displayed the same stored data in different contexts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Time to put our database thinking to work! In this exercise, we&#8217;re going to take a simple list of Athens coffee shops, turn that list into structured data, and then use WordPress to store, interact with, retrieve, and present that information. Our process will be: STRUCTURE \u2192 STORE \u2192 INTERACT \u2192 RETRIEVE \u2192 PRESENT STRUCTURE: &hellip; <a href=\"https:\/\/nmi.cool\/advweb\/exercise-databases\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Exercise: Databases<\/span><\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4972","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/pages\/4972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/comments?post=4972"}],"version-history":[{"count":1,"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/pages\/4972\/revisions"}],"predecessor-version":[{"id":4973,"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/pages\/4972\/revisions\/4973"}],"wp:attachment":[{"href":"https:\/\/nmi.cool\/advweb\/wp-json\/wp\/v2\/media?parent=4972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}