INFO 2480-61: Website Database Implementation
  • Syllabus
  • Welcome Letter
  • Week 1: Software and Setup
    • Folder Structure
    • Git: Getting Started
      • Installing a Git Client
      • Creating a Local Repository
      • Making Changes and Merging them
      • Git Wrap Up
    • Git: Github
      • Creating a New Account
      • Creating a Repo on Github
      • Cloning and Forking
      • Cloning a Repo from Github
      • Pushing Changes to Github.com
      • Github: Adding a Collaborator
    • Command Box
      • Downloading the Software
      • Unzipping and Running the Software for the first time
      • Using CommandBox And Installing the UML-Info package.
      • Setting Up Your Local Server
      • Last Step
    • IDE ( Integrated Development Environment )
      • VS Code
      • IntelliJ
    • Journal
  • Week 2: Review of HTML and CSS
    • Making Point In Time and Working Branches
    • Opening our Project from Week 1 and Starting our BoxLang server
    • HTTP Calls and Requests
    • Making a Static Website Dynamic
    • Creating The Management Index.bxm
    • Creating An HTML Form with Bootstrap
    • Last Steps
  • Week 3: Working Forms and our First Table
    • Data Types
    • Case Types and Naming Conventions
    • Database Tools and Your First DB
      • Installing MySql WorkBench
      • Connecting to your MySQL database
      • Creating Your First Table
    • Working Forms
      • Separation of Concerns
      • Configuring Our Site To Use Our Database
      • Capturing Your Form Data
      • Creating Our Server Side Logic
  • Week 5: SQL and Modelling
    • Our Project And Its Users
    • Introduction to SQL
    • Completing our Articles page.
      • Adapting manageArticles.bxm to display existing articles in the database
      • Completing ManageArticles.bxm to Edit Existing Articles.
      • Making Active Articles Appear On The Public Page
  • Week 6: Managing Books
    • Introduction To Modelling
    • Our Data Models
    • Adapting Our Management Page To Be Multi-Tool
    • Creating The Manage Books Page
    • Adding Search To Our Front Index Page
  • Week 7: Working with Selects, Files, WYSIWYG and more.
    • Adding WYSIWYG Capabilities
    • Adding WYSIWYG to the Manage Books Tool
    • Adding Images To Our Store
    • Creating Our Publisher Select Control
  • Week 9: Joins and Better Searching
    • Displaying Our Publisher
    • Searching By Publisher
    • Creating a Browse by Genre
      • Adapting Our Database
      • Building our Queries: Part 1
      • Assigning Genres to a Book in our AddEdit.bxm page
      • Building our Queries: Part 2
      • Building the GenreNav.bxm
      • Adapting The Details.bxm Page to Search By Genre
  • End of Project Checkllist
Powered by GitBook
On this page
  • Background
  1. Week 9: Joins and Better Searching

Creating a Browse by Genre

Background

We have added a search function to our site but obviously we don’t have every book in existence in our site. In fact, we have very few although what we’ve built could accommodate quite a lot. Typically, people search for a book they have heard of or a topic in which they are interested. Categorizing books according to topic or genres allow the user to look for information (or books) by browsing instead of guessing what keywords are going to get them what they want. It’s a different approach that allows users to find their content in the manner they choose.

In this exercise, we are going to add to our existing site the ability to browse by genres. This includes a few parts and is contingent on a few different techniques which we have not investigated yet. These are listed below.

  • In a form, if multiple inputs have the same name, they are submitted together and are separated by a comma like this: item1,item2,item3,item4 etc. BoxLang has built in support for handling lists like this. We can use <bx:loop list=””> to loop over the list and do something with the individual items.

  • We are going to use a feature in JavaScript which allows up to check a checkbox in a form based on its Id. This is document.getElementById(‘id’).checked=true;

  • We are use a new SQL technique which includes the word DISTINCT. This means, of all the rows in the datatable, give me each value only once. If there are 1000 rows and they all have the same value, let’s say “bob”, only one row with “bob” in it will be returned. If there are 500 “bob”s and 500 “steve”s, then two rows will be returned which will be bob and steve. Make sense?

  • The use of a “many to many” join by using a separate table to link the genres to the books. Our publishers are linked to book by a one-to-many. This means that each book has one and only one publisher. For genres, each book can have many genres and each genre can be assigned to many books. This is many to many. The best way to handle that relationship is to have a table which contains the index from each of the tables and links them together.

PreviousSearching By PublisherNextAdapting Our Database

Last updated 2 months ago