{"id":431,"date":"2022-07-26T20:39:01","date_gmt":"2022-07-26T20:39:01","guid":{"rendered":"https:\/\/jonthecyberguy.tech\/?p=431"},"modified":"2023-03-22T22:54:56","modified_gmt":"2023-03-22T22:54:56","slug":"practice-with-a-sql-database","status":"publish","type":"post","link":"https:\/\/jonthecyberguy.tech\/?p=431","title":{"rendered":"Practice with SQL &#038; Databases"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Practice with SQL &amp; Databases<\/h2>\n\n\n\n<p>I took a class that required me to do an assignment that required me to create a database, create the tables within a database, Input data into said tables, configure the relationships between tables (primary\/foreign keys) and finally write SQL queries that query the data in different ways. I included the data that was output when the queries I wrote was executed.<\/p>\n\n\n\n<p>Color Key:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Purple = SQL Code<\/li>\n\n\n\n<li>Orange = Question\/Prompt used to determine what SQL code will be written<\/li>\n<\/ul>\n\n\n\n<p><strong>I did the table creation and data input in Microsoft SQL server management Studio then switched to Microsoft Access to actually write queries for the prompts.<\/strong><\/p>\n\n\n\n<p class=\"has-kubio-color-2-color has-text-color\">A. Write the SQL statements in order to create the tables for the database. Use the Entity Relationship Diagram (ERD) of the database shown in Figure 1. For simplicity, we are assuming in this project that a book cannot be written by more than one author. You need to create the tables as well as the required constraints, including the keys (primary and foreign), and the relationships between tables.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"302\" src=\"https:\/\/jonthecyberguy.tech\/wp-content\/uploads\/2022\/07\/new_erd_new_db_assignment.png\" alt=\"\" class=\"wp-image-448\" srcset=\"https:\/\/jonthecyberguy.tech\/wp-content\/uploads\/2022\/07\/new_erd_new_db_assignment.png 350w, https:\/\/jonthecyberguy.tech\/wp-content\/uploads\/2022\/07\/new_erd_new_db_assignment-300x259.png 300w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/figure>\n\n\n\n<p class=\"has-kubio-color-2-color has-text-color\">B. Populate your database with the sample set of data given to you in the tables below the assignment prompts.<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">{CREATING DATABASE}<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creating the Database SDC<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">CREATE DATABASE SDC;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Moving into the SDC database to then populate tables<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">USE SDC;<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">{CREATING TABLES}<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I create Author table<\/li>\n\n\n\n<li>I set AuthorId as NOT NULL and set it as the primary key<\/li>\n\n\n\n<li>I use the IDENTITY operator so that the primary key can auto increment<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">CREATE TABLE Author (<br>AuthorId INT NOT NULL IDENTITY PRIMARY KEY,<br>AuthorFirstName VARCHAR(30),<br>AuthorLastName VARCHAR(30),<br>AuthorNationality VARCHAR(50),<br>AuthorDoB DATE<br>);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I create Book table<\/li>\n\n\n\n<li>I set BookId as NOT NULL and set it as the primary key<\/li>\n\n\n\n<li>I use the IDENTITY operator so that the primary key can auto increment<\/li>\n\n\n\n<li>I set BookAuthor as a FOREIGN KEY referencing AuthorId<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">CREATE TABLE Book (<br>BookId INT NOT NULL IDENTITY PRIMARY KEY,<br>BookTitle VARCHAR(50),<br>BookAuthor INT,<br>Genre VARCHAR(30),<br>FOREIGN KEY(BookAuthor) REFERENCES Author(AuthorId)<br>);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I create Client table<\/li>\n\n\n\n<li>I set ClientId as NOT NULL and set it as the primary key<\/li>\n\n\n\n<li>I use the IDENTITY operator so that the primary key can auto increment<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">CREATE TABLE Client (<br>ClientId INT NOT NULL IDENTITY PRIMARY KEY,<br>ClientFirstName VARCHAR(30),<br>ClientLastName VARCHAR(30),<br>ClientDoB Date,<br>Occupation VARCHAR(50)<br>);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I created Borrower table<\/li>\n\n\n\n<li>I set BorrowId as NOT NULL and set it as the primary key<\/li>\n\n\n\n<li>I use the IDENTITY operator so that the primary key can auto increment<\/li>\n\n\n\n<li>I set ClientId as a FOREIGN KEY referencing ClientId from the Client table<\/li>\n\n\n\n<li>I set BookId as a FOREIGN KEY referencing BookId from the Book table<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">CREATE TABLE Borrower (<br>BorrowId INT NOT NULL IDENTITY PRIMARY KEY,<br>ClientId INT,<br>BookId INT,<br>BorrowDate Date,<br>FOREIGN KEY(ClientId) REFERENCES Client(ClientId),<br>FOREIGN KEY(BookId) REFERENCES Book(BookId)<br>);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I confirm the creation of the tables<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT *<br>FROM Author;<\/p>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT *<br>FROM Client;<\/p>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT *<br>FROM Book;<\/p>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT *<br>FROM Borrower;<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">{INPUTTING DATA}<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I Input data into the Author Table<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">INSERT INTO Author (AuthorFirstName,AuthorLastName,AuthorNationality)<br>VALUES (&#8216;Sofia&#8217;,&#8217;Smith&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Maria&#8217;,&#8217;Brown&#8217;,&#8217;Brazil&#8217;),<br>(&#8216;Elena&#8217;,&#8217;Martin&#8217;,&#8217;Mexico&#8217;),<br>(&#8216;Zoe&#8217;,&#8217;Roy&#8217;,&#8217;France&#8217;),<br>(&#8216;Sebastian&#8217;,&#8217;Lavoie&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Dylan&#8217;,&#8217;Garcia&#8217;,&#8217;Spain&#8217;),<br>(&#8216;Ian&#8217;,&#8217;Cruz&#8217;,&#8217;Mexico&#8217;),<br>(&#8216;Lucas&#8217;,&#8217;Smith&#8217;,&#8217;USA&#8217;),<br>(&#8216;Fabian&#8217;,&#8217;Wilson&#8217;,&#8217;USA&#8217;),<br>(&#8216;Liam&#8217;,&#8217;Taylor&#8217;,&#8217;Canada&#8217;),<br>(&#8216;William&#8217;,&#8217;Thomas&#8217;,&#8217;Great Britain&#8217;),<br>(&#8216;Logan&#8217;,&#8217;Moore&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Oliver&#8217;,&#8217;Martin&#8217;,&#8217;France&#8217;),<br>(&#8216;Alysha&#8217;,&#8217;Thompson&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Isabelle&#8217;,&#8217;Lee&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Emily&#8217;,&#8217;Clark&#8217;,&#8217;USA&#8217;),<br>(&#8216;John&#8217;,&#8217;Young&#8217;,&#8217;China&#8217;),<br>(&#8216;David&#8217;,&#8217;Wright&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Thomas&#8217;,&#8217;Scott&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Helena&#8217;,&#8217;Adams&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Sofia&#8217;,&#8217;Carter&#8217;,&#8217;USA&#8217;),<br>(&#8216;Liam&#8217;,&#8217;Parker&#8217;,&#8217;Canada&#8217;),<br>(&#8216;Emily&#8217;,&#8217;Murphy&#8217;,&#8217;USA&#8217;);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input data into the Book Table<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">INSERT INTO Book (BookTitle,BookAuthor,Genre)<br>VALUES (&#8216;Build your database system&#8217;,&#8217;1&#8242;,&#8217;Science&#8217;),<br>(&#8216;The red wall&#8217;,&#8217;2&#8242;,&#8217;Fiction&#8217;),<br>(&#8216;The perfect match&#8217;,&#8217;3&#8242;,&#8217;Fiction&#8217;),<br>(&#8216;Digital Logic&#8217;,&#8217;4&#8242;,&#8217;Science&#8217;),<br>(&#8216;How to be a great lawyer&#8217;,&#8217;5&#8242;,&#8217;Law&#8217;),<br>(&#8216;Manage successful negotiations&#8217;,&#8217;6&#8242;,&#8217;Society&#8217;),<br>(&#8216;Pollution today&#8217;,&#8217;7&#8242;,&#8217;Science&#8217;),<br>(&#8216;A gray park&#8217;,&#8217;2&#8242;,&#8217;Fiction&#8217;),<br>(&#8216;How to be rich in one year&#8217;,&#8217;8&#8242;,&#8217;Humor&#8217;),<br>(&#8216;Their bright fate&#8217;,&#8217;9&#8242;,&#8217;Fiction&#8217;),<br>(&#8216;Black lines&#8217;,&#8217;10&#8217;,&#8217;Fiction&#8217;),<br>(&#8216;History of theater&#8217;,&#8217;11&#8217;,&#8217;Literature&#8217;),<br>(&#8216;Electrical transformers&#8217;,&#8217;12&#8217;,&#8217;Science&#8217;),<br>(&#8216;Build your big data system&#8217;,&#8217;1&#8242;,&#8217;Science&#8217;),<br>(&#8216;Right and left&#8217;,&#8217;13&#8217;,&#8217;Children&#8217;),<br>(&#8216;Programming using Python&#8217;,&#8217;1&#8242;,&#8217;Science&#8217;),<br>(&#8216;Computer networks&#8217;,&#8217;14&#8217;,&#8217;Science&#8217;),<br>(&#8216;Performance evaluation&#8217;,&#8217;15&#8217;,&#8217;Science&#8217;),<br>(&#8216;Daily exercise&#8217;,&#8217;16&#8217;,&#8217;Well being&#8217;),<br>(&#8216;The silver uniform&#8217;,&#8217;17&#8217;,&#8217;Fiction&#8217;),<br>(&#8216;Industrial revolution&#8217;,&#8217;18&#8217;,&#8217;History&#8217;),<br>(&#8216;Green nature&#8217;,&#8217;19&#8217;,&#8217;Well being&#8217;),<br>(&#8216;Perfect football&#8217;,&#8217;20&#8217;,&#8217;Well being&#8217;),<br>(&#8216;The chocolate love&#8217;,&#8217;21&#8217;,&#8217;Humor&#8217;),<br>(&#8216;Director and leader&#8217;,&#8217;22&#8217;,&#8217;Society&#8217;),<br>(&#8216;Play football every week&#8217;,&#8217;20&#8217;,&#8217;well being&#8217;),<br>(&#8216;Maya the bee&#8217;,&#8217;13&#8217;,&#8217;Children&#8217;),<br>(&#8216;Perfect rugby&#8217;,&#8217;20&#8217;,&#8217;Well being&#8217;),<br>(&#8216;The end&#8217;,&#8217;23&#8217;,&#8217;Fiction&#8217;),<br>(&#8216;Computer security&#8217;,&#8217;1&#8242;,&#8217;Science&#8217;),<br>(&#8216;Participate&#8217;,&#8217;22&#8217;,&#8217;Society&#8217;),<br>(&#8216;Positive figures&#8217;,&#8217;3&#8242;,&#8217;Fiction&#8217;);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input data into the Client Table<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">INSERT INTO Client(ClientFirstName,ClientLastName,ClientDoB,Occupation)<br>VALUES (&#8216;Kaiden&#8217;,&#8217;Hill&#8217;,2006,&#8217;Student&#8217;),<br>(&#8216;Alina&#8217;,&#8217;Morton&#8217;,2010,&#8217;Student&#8217;),<br>(&#8216;Fania&#8217;,&#8217;Brooks&#8217;,1983,&#8217;Food Scientist&#8217;),<br>(&#8216;Courtney&#8217;,&#8217;Jensen&#8217;,2006,&#8217;Student&#8217;),<br>(&#8216;Brittany&#8217;,&#8217;Hill&#8217;,1983,&#8217;Firefighter&#8217;),<br>(&#8216;Max&#8217;,&#8217;Rogers&#8217;,2005,&#8217;Student&#8217;),<br>(&#8216;Margaret&#8217;,&#8217;McCarthy&#8217;,1981,&#8217;School Psychologist&#8217;),<br>(&#8216;Julie&#8217;,&#8217;McCarthy&#8217;,1973,&#8217;Professor&#8217;),<br>(&#8216;Ken&#8217;,&#8217;McCarthy&#8217;,1974,&#8217;Securities Clerk&#8217;),<br>(&#8216;Britany&#8217;,&#8217;O&#8221;Quinn&#8217;,1984,&#8217;Violinist&#8217;),<br>(&#8216;Conner&#8217;,&#8217;Gardner&#8217;,1998,&#8217;Licensed Massage Therapist&#8217;),<br>(&#8216;Mya&#8217;,&#8217;Austin&#8217;,1960,&#8217;Parquet Floor Layer&#8217;),<br>(&#8216;Thierry&#8217;,&#8217;Rogers&#8217;,2004,&#8217;Student&#8217;),<br>(&#8216;Eloise&#8217;,&#8217;Rogers&#8217;,1984,&#8217;Computer Security Manager&#8217;),<br>(&#8216;Gerard&#8217;,&#8217;Jackson&#8217;,1979,&#8217;Oil Exploration Engineer&#8217;),<br>(&#8216;Randy&#8217;,&#8217;Day&#8217;,1986,&#8217;Aircraft Electrician&#8217;),<br>(&#8216;Jodie&#8217;,&#8217;Page&#8217;,1990,&#8217;Manufacturing Director&#8217;),<br>(&#8216;Coral&#8217;,&#8217;Rice&#8217;,1996,&#8217;Window Washer&#8217;),<br>(&#8216;Ayman&#8217;,&#8217;Austin&#8217;,2002,&#8217;Student&#8217;),<br>(&#8216;Jaxson&#8217;,&#8217;Austin&#8217;,1999,&#8217;Repair Worker&#8217;),<br>(&#8216;Joel&#8217;,&#8217;Austin&#8217;,1973,&#8217;Police Officer&#8217;),<br>(&#8216;Alina&#8217;,&#8217;Austin&#8217;,2010,&#8217;Student&#8217;),<br>(&#8216;Elin&#8217;,&#8217;Austin&#8217;,1962,&#8217;Payroll Clerk&#8217;),<br>(&#8216;Ophelia&#8217;,&#8217;Wolf&#8217;,2004,&#8217;Student&#8217;),<br>(&#8216;Eliot&#8217;,&#8217;McGuire&#8217;,1967,&#8217;Dentist&#8217;),<br>(&#8216;Peter&#8217;,&#8217;McKinney&#8217;,1968,&#8217;Professor&#8217;),<br>(&#8216;Annabella&#8217;,&#8217;Henry&#8217;,1974,&#8217;Nurse&#8217;),<br>(&#8216;Anastasia&#8217;,&#8217;Baker&#8217;,2001,&#8217;Student&#8217;),<br>(&#8216;Tyler&#8217;,&#8217;Baker&#8217;,1984,&#8217;Police Officer&#8217;),<br>(&#8216;Lilian&#8217;,&#8217;Ross&#8217;,1983,&#8217;Insurance Agent&#8217;),<br>(&#8216;Thierry&#8217;,&#8217;Arnold&#8217;,1975,&#8217;Bus Driver&#8217;),<br>(&#8216;Angelina&#8217;,&#8217;Rowe&#8217;,1979,&#8217;Firefighter&#8217;),<br>(&#8216;Marcia&#8217;,&#8217;Rowe&#8217;,1974,&#8217;Health Educator&#8217;),<br>(&#8216;Martin&#8217;,&#8217;Rowe&#8217;,1976,&#8217;Ship Engineer&#8217;),<br>(&#8216;Adeline&#8217;,&#8217;Rowe&#8217;,2005,&#8217;Student&#8217;),<br>(&#8216;Colette&#8217;,&#8217;Rowe&#8217;,1963,&#8217;Professor&#8217;),<br>(&#8216;Diane&#8217;,&#8217;Clark&#8217;,1975,&#8217;Payroll Clerk&#8217;),<br>(&#8216;Caroline&#8217;,&#8217;Clark&#8217;,1960,&#8217;Dentist&#8217;),<br>(&#8216;Dalton&#8217;,&#8217;Clayton&#8217;,1982,&#8217;Police Officer&#8217;),<br>(&#8216;Steve&#8217;,&#8217;Clayton&#8217;,1990,&#8217;Bus Driver&#8217;),<br>(&#8216;Melanie&#8217;,&#8217;Clayton&#8217;,1987,&#8217;Computer Engineer&#8217;),<br>(&#8216;Alana&#8217;,&#8217;Wilson&#8217;,2007,&#8217;Student&#8217;),<br>(&#8216;Carson&#8217;,&#8217;Byrne&#8217;,1995,&#8217;Food Scientist&#8217;),<br>(&#8216;Conrad&#8217;,&#8217;Byrne&#8217;,2007,&#8217;Student&#8217;),<br>(&#8216;Ryan&#8217;,&#8217;Porter&#8217;,2008,&#8217;Student&#8217;),<br>(&#8216;Elin&#8217;,&#8217;Porter&#8217;,1978,&#8217;Computer Programmer&#8217;),<br>(&#8216;Tyler&#8217;,&#8217;Harvey&#8217;,2007,&#8217;Student&#8217;),<br>(&#8216;Arya&#8217;,&#8217;Harvey&#8217;,2008,&#8217;Student&#8217;),<br>(&#8216;Serena&#8217;,&#8217;Harvey&#8217;,1978,&#8217;School Teacher&#8217;),<br>(&#8216;Lilly&#8217;,&#8217;Franklin&#8217;,1976,&#8217;Doctor&#8217;),<br>(&#8216;Mai&#8217;,&#8217;Franklin&#8217;,1994,&#8217;Dentist&#8217;),<br>(&#8216;John&#8217;,&#8217;Franklin&#8217;,1999,&#8217;Firefighter&#8217;),<br>(&#8216;Judy&#8217;,&#8217;Franklin&#8217;,1995,&#8217;Firefighter&#8217;),<br>(&#8216;Katy&#8217;,&#8217;Lloyd&#8217;,1992,&#8217;School Teacher&#8217;),<br>(&#8216;Tamara&#8217;,&#8217;Allen&#8217;,1963,&#8217;Ship Engineer&#8217;),<br>(&#8216;Maxim&#8217;,&#8217;Lyons&#8217;,1985,&#8217;Police Officer&#8217;),<br>(&#8216;Allan&#8217;,&#8217;Lyons&#8217;,1983,&#8217;Computer Engineer&#8217;),<br>(&#8216;Marc&#8217;,&#8217;Harris&#8217;,1980,&#8217;School Teacher&#8217;),<br>(&#8216;Elin&#8217;,&#8217;Young&#8217;,2009,&#8217;Student&#8217;),<br>(&#8216;Diana&#8217;,&#8217;Young&#8217;,2008,&#8217;Student&#8217;),<br>(&#8216;Diane&#8217;,&#8217;Young&#8217;,2006,&#8217;Student&#8217;),<br>(&#8216;Alana&#8217;,&#8217;Bird&#8217;,2003,&#8217;Student&#8217;),<br>(&#8216;Anna&#8217;,&#8217;Becker&#8217;,1979,&#8217;Security Agent&#8217;),<br>(&#8216;Katie&#8217;,&#8217;Grant&#8217;,1977,&#8217;Manager&#8217;),<br>(&#8216;Joan&#8217;,&#8217;Grant&#8217;,2010,&#8217;Student&#8217;),<br>(&#8216;Bryan&#8217;,&#8217;Bell&#8217;,2001,&#8217;Student&#8217;),<br>(&#8216;Belle&#8217;,&#8217;Miller&#8217;,1970,&#8217;Professor&#8217;),<br>(&#8216;Peggy&#8217;,&#8217;Stevens&#8217;,1990,&#8217;Bus Driver&#8217;),<br>(&#8216;Steve&#8217;,&#8217;Williamson&#8217;,1975,&#8217;HR Clerk&#8217;),<br>(&#8216;Tyler&#8217;,&#8217;Williamson&#8217;,1999,&#8217;Doctor&#8217;),<br>(&#8216;Izabelle&#8217;,&#8217;Williamson&#8217;,1990,&#8217;Systems Analyst&#8217;),<br>(&#8216;Annabel&#8217;,&#8217;Williamson&#8217;,1960,&#8217;Cashier&#8217;),<br>(&#8216;Mohamed&#8217;,&#8217;Waters&#8217;,1966,&#8217;Insurance Agent&#8217;),<br>(&#8216;Marion&#8217;,&#8217;Newman&#8217;,1970,&#8217;Computer Programmer&#8217;),<br>(&#8216;Ada&#8217;,&#8217;Williams&#8217;,1986,&#8217;Computer Programmer&#8217;),<br>(&#8216;Sean&#8217;,&#8217;Scott&#8217;,1983,&#8217;Bus Driver&#8217;),<br>(&#8216;Farrah&#8217;,&#8217;Scott&#8217;,1974,&#8217;Ship Engineer&#8217;),<br>(&#8216;Christine&#8217;,&#8217;Lambert&#8217;,1973,&#8217;School Teacher&#8217;),<br>(&#8216;Alysha&#8217;,&#8217;Lambert&#8217;,2007,&#8217;Student&#8217;),<br>(&#8216;Maia&#8217;,&#8217;Grant&#8217;,1984,&#8217;School Teacher&#8217;);<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input data into the Borrow Table<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">INSERT INTO Borrower(ClientId,BookId,BorrowDate)<br>VALUES (35,17,&#8217;2016-07-20&#8242;),<br>(1,3,&#8217;2017-04-19&#8242;),<br>(42,8,&#8217;2016-10-03&#8242;),<br>(62,16,&#8217;2016-04-05&#8242;),<br>(53,13,&#8217;2017-01-17&#8242;),<br>(33,15,&#8217;2015-11-26&#8242;),<br>(40,14,&#8217;2015-01-21&#8242;),<br>(64,2,&#8217;2017-09-10&#8242;),<br>(56,30,&#8217;2017-08-02&#8242;),<br>(23,2,&#8217;2018-06-28&#8242;),<br>(46,19,&#8217;2015-11-18&#8242;),<br>(61,20,&#8217;2015-11-24&#8242;),<br>(58,7,&#8217;2017-06-17&#8242;),<br>(46,16,&#8217;2017-02-12&#8242;),<br>(80,21,&#8217;2018-03-18&#8242;),<br>(51,23,&#8217;2015-09-01&#8242;),<br>(49,18,&#8217;2015-07-28&#8242;),<br>(43,18,&#8217;2015-11-04&#8242;),<br>(30,2,&#8217;2018-08-10&#8242;),<br>(48,24,&#8217;2015-05-13&#8242;),<br>(71,5,&#8217;2016-09-05&#8242;),<br>(35,3,&#8217;2016-07-03&#8242;),<br>(57,1,&#8217;2015-03-17&#8242;),<br>(23,25,&#8217;2017-08-16&#8242;),<br>(20,12,&#8217;2018-07-24&#8242;),<br>(25,7,&#8217;2015-01-31&#8242;),<br>(72,29,&#8217;2016-04-10&#8242;),<br>(74,20,&#8217;2017-07-31&#8242;),<br>(53,14,&#8217;2016-02-20&#8242;),<br>(32,10,&#8217;2017-07-24&#8242;),<br>(12,15,&#8217;2018-04-25&#8242;),<br>(77,13,&#8217;2017-06-09&#8242;),<br>(30,4,&#8217;2017-10-24&#8242;),<br>(37,24,&#8217;2016-01-14&#8242;),<br>(27,26,&#8217;2017-06-05&#8242;),<br>(1,16,&#8217;2018-05-06&#8242;),<br>(21,9,&#8217;2016-03-19&#8242;),<br>(69,28,&#8217;2017-03-29&#8242;),<br>(17,19,&#8217;2017-03-14&#8242;),<br>(8,9,&#8217;2016-04-22&#8242;),<br>(63,18,&#8217;2015-01-25&#8242;),<br>(65,20,&#8217;2016-10-10&#8242;),<br>(51,19,&#8217;2015-07-28&#8242;),<br>(23,12,&#8217;2017-01-25&#8242;),<br>(17,4,&#8217;2017-04-18&#8242;),<br>(68,5,&#8217;2016-09-06&#8242;),<br>(46,13,&#8217;2017-09-30&#8242;),<br>(15,13,&#8217;2017-07-05&#8242;),<br>(11,19,&#8217;2017-12-14&#8242;),<br>(78,15,&#8217;2017-01-26&#8242;),<br>(47,9,&#8217;2015-03-03&#8242;),<br>(68,7,&#8217;2016-05-26&#8242;),<br>(37,26,&#8217;2017-02-06&#8242;),<br>(48,27,&#8217;2015-12-30&#8242;),<br>(9,21,&#8217;2017-10-21&#8242;),<br>(29,8,&#8217;2018-04-01&#8242;),<br>(64,18,&#8217;2017-08-29&#8242;),<br>(61,26,&#8217;2018-02-21&#8242;),<br>(39,28,&#8217;2016-07-26&#8242;),<br>(73,18,&#8217;2018-08-22&#8242;),<br>(11,13,&#8217;2018-01-17&#8242;),<br>(45,6,&#8217;2016-07-20&#8242;),<br>(33,13,&#8217;2018-03-18&#8242;),<br>(10,17,&#8217;2016-06-06&#8242;),<br>(28,18,&#8217;2017-02-17&#8242;),<br>(51,3,&#8217;2016-12-09&#8242;),<br>(29,2,&#8217;2015-09-18&#8242;),<br>(28,30,&#8217;2017-09-14&#8242;),<br>(74,20,&#8217;2015-12-12&#8242;),<br>(15,22,&#8217;2015-01-14&#8242;),<br>(57,8,&#8217;2017-08-20&#8242;),<br>(2,5,&#8217;2015-01-18&#8242;),<br>(74,12,&#8217;2018-04-14&#8242;),<br>(51,10,&#8217;2016-02-25&#8242;),<br>(25,17,&#8217;2015-02-24&#8242;),<br>(45,21,&#8217;2017-02-10&#8242;),<br>(27,25,&#8217;2016-08-03&#8242;),<br>(32,28,&#8217;2016-06-15&#8242;),<br>(71,21,&#8217;2017-05-21&#8242;),<br>(75,26,&#8217;2016-05-03&#8242;),<br>(56,32,&#8217;2015-12-23&#8242;),<br>(26,32,&#8217;2015-05-16&#8242;),<br>(66,32,&#8217;2015-05-30&#8242;),<br>(57,18,&#8217;2017-09-15&#8242;),<br>(40,15,&#8217;2016-09-02&#8242;),<br>(65,4,&#8217;2017-08-17&#8242;),<br>(54,7,&#8217;2015-12-19&#8242;),<br>(29,4,&#8217;2017-07-22&#8242;),<br>(44,9,&#8217;2017-12-31&#8242;),<br>(56,31,&#8217;2015-06-13&#8242;),<br>(17,4,&#8217;2015-04-01&#8242;),<br>(35,16,&#8217;2018-07-19&#8242;),<br>(22,18,&#8217;2017-06-22&#8242;),<br>(39,24,&#8217;2015-05-29&#8242;),<br>(63,14,&#8217;2018-01-20&#8242;),<br>(53,21,&#8217;2016-07-31&#8242;),<br>(40,9,&#8217;2016-07-10&#8242;),<br>(52,4,&#8217;2017-04-05&#8242;),<br>(27,20,&#8217;2016-09-04&#8242;),<br>(72,29,&#8217;2015-12-06&#8242;),<br>(49,16,&#8217;2017-12-19&#8242;),<br>(6,12,&#8217;2016-12-04&#8242;),<br>(74,31,&#8217;2016-07-27&#8242;),<br>(48,32,&#8217;2016-06-29&#8242;),<br>(69,2,&#8217;2016-12-27&#8242;),<br>(60,32,&#8217;2017-10-29&#8242;),<br>(45,22,&#8217;2017-06-12&#8242;),<br>(42,15,&#8217;2017-05-14&#8242;),<br>(79,8,&#8217;2016-10-13&#8242;),<br>(70,18,&#8217;2016-12-04&#8242;),<br>(34,8,&#8217;2016-03-06&#8242;),<br>(43,8,&#8217;2015-12-19&#8242;),<br>(42,32,&#8217;2016-04-20&#8242;),<br>(67,5,&#8217;2017-03-06&#8242;),<br>(80,25,&#8217;2015-06-23&#8242;),<br>(54,11,&#8217;2017-05-03&#8242;),<br>(34,28,&#8217;2017-08-30&#8242;),<br>(65,20,&#8217;2017-08-26&#8242;),<br>(61,19,&#8217;2018-01-05&#8242;),<br>(38,12,&#8217;2018-01-17&#8242;),<br>(51,4,&#8217;2016-05-13&#8242;),<br>(7,16,&#8217;2016-03-17&#8242;),<br>(46,16,&#8217;2016-11-25&#8242;),<br>(75,30,&#8217;2018-08-12&#8242;),<br>(72,32,&#8217;2015-03-12&#8242;),<br>(44,17,&#8217;2015-06-15&#8242;),<br>(68,15,&#8217;2016-02-21&#8242;),<br>(21,1,&#8217;2016-06-19&#8242;),<br>(14,25,&#8217;2016-10-10&#8242;),<br>(68,21,&#8217;2016-05-27&#8242;),<br>(35,20,&#8217;2015-03-19&#8242;),<br>(16,27,&#8217;2016-08-08&#8242;),<br>(79,31,&#8217;2018-03-07&#8242;),<br>(14,17,&#8217;2018-04-28&#8242;),<br>(29,28,&#8217;2018-03-11&#8242;),<br>(41,4,&#8217;2018-08-08&#8242;),<br>(42,3,&#8217;2016-02-23&#8242;),<br>(45,3,&#8217;2017-07-10&#8242;),<br>(36,16,&#8217;2018-07-19&#8242;),<br>(36,30,&#8217;2015-08-07&#8242;),<br>(54,32,&#8217;2018-03-14&#8242;),<br>(61,15,&#8217;2017-03-28&#8242;),<br>(1,13,&#8217;2018-05-17&#8242;),<br>(43,1,&#8217;2015-05-14&#8242;),<br>(37,14,&#8217;2015-07-30&#8242;),<br>(62,17,&#8217;2015-09-19&#8242;),<br>(50,22,&#8217;2016-12-02&#8242;),<br>(45,1,&#8217;2016-07-24&#8242;),<br>(32,17,&#8217;2018-03-10&#8242;),<br>(13,28,&#8217;2016-02-14&#8242;),<br>(15,9,&#8217;2018-08-11&#8242;),<br>(10,19,&#8217;2018-08-29&#8242;),<br>(66,3,&#8217;2016-11-27&#8242;),<br>(68,29,&#8217;2017-07-12&#8242;),<br>(21,14,&#8217;2018-06-27&#8242;),<br>(35,9,&#8217;2016-01-22&#8242;),<br>(17,24,&#8217;2016-08-25&#8242;),<br>(40,21,&#8217;2015-07-09&#8242;),<br>(1,24,&#8217;2016-03-28&#8242;),<br>(70,27,&#8217;2015-07-10&#8242;),<br>(80,26,&#8217;2016-04-24&#8242;),<br>(29,5,&#8217;2015-10-18&#8242;),<br>(76,12,&#8217;2018-04-25&#8242;),<br>(22,4,&#8217;2016-12-24&#8242;),<br>(2,2,&#8217;2017-10-26&#8242;),<br>(35,13,&#8217;2016-02-28&#8242;),<br>(40,8,&#8217;2017-10-02&#8242;),<br>(68,9,&#8217;2016-01-03&#8242;),<br>(32,5,&#8217;2016-11-13&#8242;),<br>(34,17,&#8217;2016-09-15&#8242;),<br>(34,16,&#8217;2018-04-13&#8242;),<br>(80,30,&#8217;2016-10-13&#8242;),<br>(20,32,&#8217;2015-11-17&#8242;),<br>(36,10,&#8217;2017-09-01&#8242;),<br>(78,12,&#8217;2018-06-27&#8242;),<br>(57,8,&#8217;2016-03-22&#8242;),<br>(75,11,&#8217;2017-06-27&#8242;),<br>(71,10,&#8217;2015-08-01&#8242;),<br>(48,22,&#8217;2015-09-29&#8242;),<br>(19,16,&#8217;2016-02-21&#8242;),<br>(79,30,&#8217;2018-08-20&#8242;),<br>(70,13,&#8217;2016-09-16&#8242;),<br>(30,6,&#8217;2017-02-10&#8242;),<br>(45,12,&#8217;2017-10-12&#8242;),<br>(30,27,&#8217;2016-11-23&#8242;),<br>(26,3,&#8217;2016-08-13&#8242;),<br>(66,6,&#8217;2017-01-14&#8242;),<br>(47,15,&#8217;2016-02-10&#8242;),<br>(53,30,&#8217;2018-08-08&#8242;),<br>(80,16,&#8217;2016-03-31&#8242;),<br>(70,13,&#8217;2018-02-03&#8242;),<br>(14,25,&#8217;2016-03-27&#8242;),<br>(46,22,&#8217;2016-01-13&#8242;),<br>(30,32,&#8217;2015-08-06&#8242;),<br>(60,14,&#8217;2016-11-27&#8242;),<br>(14,13,&#8217;2018-05-23&#8242;),<br>(71,15,&#8217;2016-06-22&#8242;),<br>(38,21,&#8217;2015-12-27&#8242;),<br>(69,30,&#8217;2017-04-29&#8242;),<br>(49,31,&#8217;2018-06-03&#8242;),<br>(28,28,&#8217;2015-05-29&#8242;),<br>(49,3,&#8217;2016-08-30&#8242;),<br>(75,1,&#8217;2015-10-29&#8242;),<br>(78,3,&#8217;2017-05-12&#8242;),<br>(43,18,&#8217;2015-03-25&#8242;),<br>(27,21,&#8217;2016-02-22&#8242;),<br>(64,22,&#8217;2015-04-03&#8242;),<br>(21,11,&#8217;2017-12-09&#8242;),<br>(66,29,&#8217;2016-12-20&#8242;),<br>(45,13,&#8217;2017-04-15&#8242;),<br>(48,30,&#8217;2015-01-31&#8242;),<br>(20,25,&#8217;2017-12-20&#8242;),<br>(41,20,&#8217;2018-01-29&#8242;),<br>(51,12,&#8217;2015-07-05&#8242;),<br>(5,1,&#8217;2015-04-12&#8242;),<br>(40,3,&#8217;2018-02-24&#8242;),<br>(79,4,&#8217;2018-06-27&#8242;),<br>(15,10,&#8217;2016-11-01&#8242;),<br>(42,22,&#8217;2016-12-28&#8242;),<br>(17,9,&#8217;2018-01-29&#8242;),<br>(38,13,&#8217;2016-05-09&#8242;),<br>(79,2,&#8217;2017-12-06&#8242;),<br>(74,3,&#8217;2015-12-07&#8242;),<br>(46,8,&#8217;2016-06-05&#8242;),<br>(78,22,&#8217;2018-08-11&#8242;),<br>(45,2,&#8217;2015-04-20&#8242;),<br>(72,31,&#8217;2015-11-11&#8242;),<br>(18,17,&#8217;2015-03-21&#8242;),<br>(29,3,&#8217;2017-08-13&#8242;),<br>(66,11,&#8217;2018-06-05&#8242;),<br>(36,16,&#8217;2016-04-28&#8242;),<br>(26,2,&#8217;2016-10-23&#8242;),<br>(32,1,&#8217;2017-10-31&#8242;),<br>(62,14,&#8217;2017-07-25&#8242;),<br>(12,4,&#8217;2015-07-08&#8242;),<br>(38,32,&#8217;2015-02-24&#8242;),<br>(29,16,&#8217;2016-07-28&#8242;),<br>(36,25,&#8217;2017-05-07&#8242;),<br>(76,7,&#8217;2015-06-13&#8242;),<br>(28,16,&#8217;2016-08-15&#8242;),<br>(60,13,&#8217;2016-08-26&#8242;),<br>(8,3,&#8217;2017-07-28&#8242;),<br>(25,1,&#8217;2016-07-30&#8242;),<br>(62,29,&#8217;2018-08-24&#8242;),<br>(51,8,&#8217;2016-09-01&#8242;),<br>(27,23,&#8217;2015-02-08&#8242;),<br>(69,12,&#8217;2018-06-25&#8242;),<br>(51,12,&#8217;2015-07-04&#8242;),<br>(7,4,&#8217;2015-05-01&#8242;),<br>(31,15,&#8217;2017-10-29&#8242;),<br>(14,23,&#8217;2015-01-15&#8242;),<br>(14,1,&#8217;2018-05-21&#8242;),<br>(39,25,&#8217;2015-12-26&#8242;),<br>(79,24,&#8217;2016-05-31&#8242;),<br>(40,15,&#8217;2016-03-18&#8242;),<br>(51,13,&#8217;2018-04-13&#8242;),<br>(61,1,&#8217;2015-02-11&#8242;),<br>(15,24,&#8217;2018-03-02&#8242;),<br>(10,22,&#8217;2018-01-21&#8242;),<br>(67,10,&#8217;2017-07-08&#8242;),<br>(79,11,&#8217;2016-12-11&#8242;),<br>(19,32,&#8217;2016-05-04&#8242;),<br>(35,11,&#8217;2017-08-01&#8242;),<br>(27,13,&#8217;2017-12-15&#8242;),<br>(30,22,&#8217;2015-12-22&#8242;),<br>(8,7,&#8217;2015-06-26&#8242;),<br>(70,9,&#8217;2016-03-20&#8242;),<br>(56,18,&#8217;2016-01-29&#8242;),<br>(13,19,&#8217;2015-03-06&#8242;),<br>(61,2,&#8217;2016-06-18&#8242;),<br>(47,13,&#8217;2017-09-18&#8242;),<br>(30,22,&#8217;2016-02-19&#8242;),<br>(18,22,&#8217;2016-12-31&#8242;),<br>(34,29,&#8217;2017-10-27&#8242;),<br>(32,21,&#8217;2015-06-03&#8242;),<br>(9,28,&#8217;2016-03-30&#8242;),<br>(62,24,&#8217;2015-03-23&#8242;),<br>(44,22,&#8217;2017-04-29&#8242;),<br>(27,5,&#8217;2015-03-25&#8242;),<br>(61,28,&#8217;2017-07-14&#8242;),<br>(5,13,&#8217;2016-12-04&#8242;),<br>(43,19,&#8217;2018-03-15&#8242;),<br>(34,19,&#8217;2016-06-05&#8242;),<br>(35,5,&#8217;2018-02-19&#8242;),<br>(13,12,&#8217;2016-09-23&#8242;),<br>(74,18,&#8217;2016-12-26&#8242;),<br>(70,31,&#8217;2017-08-15&#8242;),<br>(42,17,&#8217;2016-06-15&#8242;),<br>(51,24,&#8217;2018-07-30&#8242;),<br>(45,30,&#8217;2015-01-15&#8242;),<br>(70,17,&#8217;2017-10-07&#8242;),<br>(77,7,&#8217;2017-01-06&#8242;),<br>(74,25,&#8217;2015-09-25&#8242;),<br>(47,14,&#8217;2018-02-01&#8242;),<br>(10,2,&#8217;2017-04-18&#8242;),<br>(16,21,&#8217;2016-10-03&#8242;),<br>(48,5,&#8217;2016-09-17&#8242;),<br>(72,3,&#8217;2017-02-10&#8242;),<br>(26,23,&#8217;2016-03-01&#8242;),<br>(49,23,&#8217;2016-10-25&#8242;);<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">{PROMPTS}<\/h3>\n\n\n\n<p><strong>From here I switched to Microsoft Access because it was a more user friendly program to work with. Also it was easier to save my queries and their outputs. The way I populated the data into Access was by importing the tables into Excel via the web search function. I pasted the URL of the assignment page and Excel was able to pull the data directly from the website. I then saved all 4 tables in an .xlsx file and imported that into Access. I set up my primary keys easily in the Access GUI and I set the foreign keys via the relationships tab. After that all the data and relationships were created. It is also why the SQL between the first half and second half is a bit different.<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Display all contents of the Clients table<\/li>\n<\/ol>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT * FROM Client;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I used the SELECT command to retrieve data from the Client table.<\/li>\n\n\n\n<li>I used the Asterisk(*) to retrieve and display ALL the data from the Client table.<\/li>\n\n\n\n<li>I used the FROM command to designate what table I want to retrieve and display data from<\/li>\n<\/ul>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| ClientId | ClientFirstName | ClientLastName | ClientDoB | Occupation |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 1 | Kaiden | Hill | 2006 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 2 | Alina | Morton | 2010 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 3 | Fania | Brooks | 1983 | Food Scientist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 4 | Courtney | Jensen | 2006 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 5 | Brittany | Hill | 1983 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 6 | Max | Rogers | 2005 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 7 | Margaret | McCarthy | 1981 | School |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 8 | Julie | McCarthy | 1973 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 9 | Ken | McCarthy | 1974 | Securities Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 10 | Britany | O&#8217;Quinn | 1984 | Violinist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 11 | Conner | Gardner | 1998 | Licensed Massage |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 12 | Mya | Austin | 1960 | Parquet Floor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 13 | Thierry | Rogers | 2004 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 14 | Eloise | Rogers | 1984 | Computer Security |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 15 | Gerard | Jackson | 1979 | Oil Exploration |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 16 | Randy | Day | 1986 | Aircraft |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 17 | Jodie | Page | 1990 | Manufacturing |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 18 | Coral | Rice | 1996 | Window Washer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 19 | Ayman | Austin | 2002 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 20 | Jaxson | Austin | 1999 | Repair Worker |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 21 | Joel | Austin | 1973 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 22 | Alina | Austin | 2010 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 23 | Elin | Austin | 1962 | Payroll Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 24 | Ophelia | Wolf | 2004 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 25 | Eliot | McGuire | 1967 | Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 26 | Peter | McKinney | 1968 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 27 | Annabella | Henry | 1974 | Nurse |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 28 | Anastasia | Baker | 2001 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 29 | Tyler | Baker | 1984 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 30 | Lilian | Ross | 1983 | Insurance Agent |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 31 | Thierry | Arnold | 1975 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 32 | Angelina | Rowe | 1979 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 33 | Marcia | Rowe | 1974 | Health Educator |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 34 | Martin | Rowe | 1976 | Ship Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 35 | Adeline | Rowe | 2005 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 36 | Colette | Rowe | 1963 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 37 | Diane | Clark | 1975 | Payroll Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 38 | Caroline | Clark | 1960 | Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 39 | Dalton | Clayton | 1982 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 40 | Steve | Clayton | 1990 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 41 | Melanie | Clayton | 1987 | Computer Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 42 | Alana | Wilson | 2007 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 43 | Carson | Byrne | 1995 | Food Scientist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 44 | Conrad | Byrne | 2007 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 45 | Ryan | Porter | 2008 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 46 | Elin | Porter | 1978 | Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 47 | Tyler | Harvey | 2007 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 48 | Arya | Harvey | 2008 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 49 | Serena | Harvey | 1978 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 50 | Lilly | Franklin | 1976 | Doctor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 51 | Mai | Franklin | 1994 | Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 52 | John | Franklin | 1999 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 53 | Judy | Franklin | 1995 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 54 | Katy | Lloyd | 1992 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 55 | Tamara | Allen | 1963 | Ship Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 56 | Maxim | Lyons | 1985 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 57 | Allan | Lyons | 1983 | Computer Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 58 | Marc | Harris | 1980 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 59 | Elin | Young | 2009 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 60 | Diana | Young | 2008 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 61 | Diane | Young | 2006 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 62 | Alana | Bird | 2003 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 63 | Anna | Becker | 1979 | Security Agent |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 64 | Katie | Grant | 1977 | Manager |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 65 | Joan | Grant | 2010 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 66 | Bryan | Bell | 2001 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 67 | Belle | Miller | 1970 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 68 | Peggy | Stevens | 1990 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 69 | Steve | Williamson | 1975 | HR Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 70 | Tyler | Williamson | 1999 | Doctor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 71 | Izabelle | Williamson | 1990 | Systems Analyst |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 72 | Annabel | Williamson | 1960 | Cashier |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 73 | Mohamed | Waters | 1966 | Insurance Agent |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 74 | Marion | Newman | 1970 | Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 75 | Ada | Williams | 1986 | Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 76 | Sean | Scott | 1983 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 77 | Farrah | Scott | 1974 | Ship Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 78 | Christine | Lambert | 1973 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 79 | Alysha | Lambert | 2007 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 80 | Maia | Grant | 1984 | School Teacher |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>First names, last names, ages and occupations of all clients<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I used NOW() to get todays date.<\/li>\n\n\n\n<li>I accessed only the year from todays date by using YEAR()<\/li>\n\n\n\n<li>The ClientDoB was only the year.<\/li>\n\n\n\n<li>I subtracted our current year from the clients dob year and aliased the result as Age<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT client.ClientFirstName, client.ClientLastName, (YEAR(NOW())-ClientDoB) AS Age, client.Occupation<br>FROM client;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| ClientFirstName | ClientLastName | Age | Occupation |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Kaiden | Hill | 16 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Alina | Morton | 12 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Fania | Brooks | 39 | Food Scientist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Courtney | Jensen | 16 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Brittany | Hill | 39 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Max | Rogers | 17 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Margaret | McCarthy | 41 | School |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Julie | McCarthy | 49 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Ken | McCarthy | 48 | Securities Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Britany | O&#8217;Quinn | 38 | Violinist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Conner | Gardner | 24 | Licensed Massage |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Mya | Austin | 62 | Parquet Floor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Thierry | Rogers | 18 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Eloise | Rogers | 38 | Computer Security |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Gerard | Jackson | 43 | Oil Exploration |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Randy | Day | 36 | Aircraft |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Jodie | Page | 32 | Manufacturing |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Coral | Rice | 26 | Window Washer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Ayman | Austin | 20 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Jaxson | Austin | 23 | Repair Worker |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Joel | Austin | 49 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Alina | Austin | 12 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Elin | Austin | 60 | Payroll Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Ophelia | Wolf | 18 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Eliot | McGuire | 55 | Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Peter | McKinney | 54 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Annabella | Henry | 48 | Nurse |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Anastasia | Baker | 21 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Tyler | Baker | 38 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Lilian | Ross | 39 | Insurance Agent |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Thierry | Arnold | 47 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Angelina | Rowe | 43 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Marcia | Rowe | 48 | Health Educator |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Martin | Rowe | 46 | Ship Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Adeline | Rowe | 17 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Colette | Rowe | 59 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Diane | Clark | 47 | Payroll Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Caroline | Clark | 62 | Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Dalton | Clayton | 40 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Steve | Clayton | 32 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Melanie | Clayton | 35 | Computer Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Alana | Wilson | 15 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Carson | Byrne | 27 | Food Scientist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Conrad | Byrne | 15 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Ryan | Porter | 14 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Elin | Porter | 44 | Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Tyler | Harvey | 15 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Arya | Harvey | 14 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Serena | Harvey | 44 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Lilly | Franklin | 46 | Doctor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Mai | Franklin | 28 | Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| John | Franklin | 23 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Judy | Franklin | 27 | Firefighter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Katy | Lloyd | 30 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Tamara | Allen | 59 | Ship Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Maxim | Lyons | 37 | Police Officer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Allan | Lyons | 39 | Computer Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Marc | Harris | 42 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Elin | Young | 13 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Diana | Young | 14 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Diane | Young | 16 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Alana | Bird | 19 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Anna | Becker | 43 | Security Agent |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Katie | Grant | 45 | Manager |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Joan | Grant | 12 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Bryan | Bell | 21 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Belle | Miller | 52 | Professor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Peggy | Stevens | 32 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Steve | Williamson | 47 | HR Clerk |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Tyler | Williamson | 23 | Doctor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Izabelle | Williamson | 32 | Systems Analyst |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Annabel | Williamson | 62 | Cashier |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Mohamed | Waters | 56 | Insurance Agent |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Marion | Newman | 52 | Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Ada | Williams | 36 | Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Sean | Scott | 39 | Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Farrah | Scott | 48 | Ship Engineer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Christine | Lambert | 49 | School Teacher |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Alysha | Lambert | 15 | Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Maia | Grant | 38 | School Teacher |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>First and last names of clients that borrowed books in March 2018<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I accessed the ClientFirstName and ClientLastName from the Client table,<\/li>\n\n\n\n<li>I used an inner join to connect the Client table with the Borrower table based on ClientId being the same in each<\/li>\n\n\n\n<li>I used the WHERE clause to filter the data<\/li>\n\n\n\n<li>I accessed the MONTH() and YEAR() from BorrowDate<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT ClientFirstName, ClientLastName<br>FROM Client<br>INNER JOIN Borrower<br>ON Client.ClientId = Borrower.ClientId<br>WHERE MONTH(BorrowDate) = 3 AND YEAR(BorrowDate) = 2018<\/p>\n\n\n\n<p class=\"has-kubio-color-2-color has-text-color\">-Index SQL<\/p>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">CREATE INDEX Borrower_idx<br>ON Borrower (BorrowId ,ClientId,BookId,BorrowDate);<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| ClientFirstName | ClientLastName |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Maia | Grant |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Marcia | Rowe |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Katy | Lloyd |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Tyler | Williamson |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Serena | Harvey |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Carson | Byrne |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>First and last names of the top 5 authors clients borrowed in 2017<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I need information found on three different tables.<\/li>\n\n\n\n<li>I solved this by using two inner joins<\/li>\n\n\n\n<li>I accessed AuthorFirstName and AuthorLastName from the author table<\/li>\n\n\n\n<li>I used an inner join to connect the author table with the book table based on their Book.BookAuthor = Author.AuthorId being the same<\/li>\n\n\n\n<li>I used inner join to connect the book table with the borrower table based on Book.BookId = Borrower.BookId being the same<\/li>\n\n\n\n<li>I used the WHERE clause to filter the data<\/li>\n\n\n\n<li>I accessed the YEAR() from BorrowDate<\/li>\n\n\n\n<li>I ordered them by how many times the authors bookid was used, in descending order<\/li>\n\n\n\n<li>I used the TOP 5 operator to limited the count to 5<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT TOP 5 Author.AuthorFirstName, Author.AuthorLastName<br>FROM Author INNER JOIN (Book INNER JOIN Borrower ON Book.[BookId] = Borrower.[BookId]) ON Author.AuthorId = Book.BookAuthor<br>WHERE ((Year([BorrowDate]))=2017)<br>GROUP BY Author.AuthorFirstName, Author.AuthorLastName<br>ORDER BY Count(Borrower.BookId) DESC;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| AuthorFirstName | AuthorLastName |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Elena | Martin |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Sofia | Smith |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Logan | Moore |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Maria | Brown |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Helena | Adams |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Zoe | Roy |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Nationalities of the least 5 authors that clients borrowed during the years 2015-2017<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The information needed is on three different tables.<\/li>\n\n\n\n<li>I use two inner joins.<\/li>\n\n\n\n<li>I accessed the AuthorNationality from the author table.<\/li>\n\n\n\n<li>I used an inner join to connect the author table with the book table based on their Book.BookAuthor = Author.AuthorId being the same<\/li>\n\n\n\n<li>I used inner join to connect the book table with the borrower table based on Book.BookId = Borrower.BookId being the same<\/li>\n\n\n\n<li>I used the WHERE clause to filter the data<\/li>\n\n\n\n<li>I accessed the YEAR() from BorrowDate<\/li>\n\n\n\n<li>I used the BETWEEN clause to limit access to between the years of 2015 and 2017<\/li>\n\n\n\n<li>I ordered them by how many times the author&#8217;s bookid was used.<\/li>\n\n\n\n<li>I used a TOP 5 operator to limit the amount of records shown<\/li>\n\n\n\n<li>I ordered it Ascending<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT TOP 5 Author.AuthorNationality, Count(Author.AuthorNationality) AS CountOfAuthorNationality<br>FROM Author INNER JOIN (Book INNER JOIN Borrower ON Book.BookId = Borrower.BookId) ON Author.AuthorId = Book.BookAuthor<br>WHERE (((Year([BorrowDate])) Between 2015 And 2017))<br>GROUP BY Author.AuthorNationality<br>ORDER BY Count(Author.AuthorNationality) ASC;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| AuthorNationality | CountOfAuthorNationality |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Spain | 3 |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Great Britain | 6 |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| China | 7 |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Brazil | 18 |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| France | 24 |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li>The book that was most borrowed during the years 2015-2017<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I accessed the BookTitle from the Book table<\/li>\n\n\n\n<li>I used inner join to connect the Book table with the Borrower table based on Book.BookId = Borrower.BookId being the same<\/li>\n\n\n\n<li>I used the WHERE clause to filter the data<\/li>\n\n\n\n<li>I accessed the YEAR() from BorrowDate<\/li>\n\n\n\n<li>I used the BETWEEN clause to only access data between the years of 2015 and 2017<\/li>\n\n\n\n<li>I ordered them by how many times the authors bookid was used, in desending order<\/li>\n\n\n\n<li>I used the TOP 1 operator to show only 1 record<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT TOP 1 Book.BookTitle<br>FROM Book INNER JOIN Borrower ON Book.BookId = Borrower.BookId<br>WHERE (((Year([BorrowDate])) Between 2015 And 2017))<br>GROUP BY Book.BookTitle<br>ORDER BY Count(Borrower.BookId) DESC;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| BookTitle |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| The perfect match |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\">\n<li>Top borrowed genres for client born in years 1970-1980<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All of the informationI need is found on three different tables.<\/li>\n\n\n\n<li>I use two inner joins<\/li>\n\n\n\n<li>BookId is present in all three tables so I use it to point to the same information in all three tables.<\/li>\n\n\n\n<li>I accessed the Genre from the author table,<\/li>\n\n\n\n<li>I use an inner join to connect the Book table with the Borrower table based on Book.BookId = Borrower.BookId being the same<\/li>\n\n\n\n<li>I use an inner join to connect the Client table with the Borrower table based on their Borrower.ClientId = Client.ClientId being the same<\/li>\n\n\n\n<li>I used the WHERE clause to filter the data<\/li>\n\n\n\n<li>I access the YEAR() from BorrowDate<\/li>\n\n\n\n<li>I used the BETWEEN clause to access only between the years of 1970 and 1980<\/li>\n\n\n\n<li>I use the TOP 5 operator to show only 5 records<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT TOP 5 Genre<br>FROM (Book INNER JOIN Borrower ON Book.BookId = Borrower.BookId)<br>INNER JOIN Client<br>ON Borrower.ClientId = Client.ClientId<br>WHERE ClientDoB BETWEEN 1970 AND 1980<br>GROUP BY Genre;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Genre |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Children |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Fiction |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| History |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Humor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Law |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"8\">\n<li>Top 5 occupations that borrowed the most in 2016<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I have to access the Client table for the occupations and the Borrower table for the dates borrowed<\/li>\n\n\n\n<li>I accessed the Occupation from the Client table,<\/li>\n\n\n\n<li>I used inner join to connect the book table with the borrower table based on Borrower.ClientId = Client.ClientId being the same<\/li>\n\n\n\n<li>I used the WHERE clause to filter the data<\/li>\n\n\n\n<li>I accessed the YEAR() function from BorrowDate = 2016<\/li>\n\n\n\n<li>I counted how many times a client borrowed, ordered it descending.<\/li>\n\n\n\n<li>I used the TOP 5 operator to limit the results to just 5<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT TOP 5 Client.Occupation<br>FROM Client INNER JOIN Borrower ON Client.ClientId = Borrower.ClientId<br>WHERE (((Year([BorrowDate]))=2016))<br>GROUP BY Client.Occupation<br>ORDER BY Count(Borrower.ClientId) DESC;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Occupation |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Student |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Bus Driver |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Dentist |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Computer |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Professor |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"11\">\n<li>The top month of borrows in 2017<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I access the BorrowDate from the Borrow table and then count each BorrowDate in 2017 only as its month<\/li>\n\n\n\n<li>I used the SELECT statement to select the BorrowDate field from the Borrower database<\/li>\n\n\n\n<li>I convert it using the SQL server function MONTH()<\/li>\n\n\n\n<li>I used the COUNT function in combination with the MONTH function to count the top months<\/li>\n\n\n\n<li>I used the WHERE clause narrowed down the year<\/li>\n\n\n\n<li>I ordered my results from most to least<\/li>\n\n\n\n<li>I Used the TOP 5 operator to limit the results to 3<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT TOP 3 Month(BorrowDate) AS Top_Month, Count(Month(BorrowDate)) AS Number_borrowed<br>FROM Borrower<br>WHERE (((Year([BorrowDate]))=2017))<br>GROUP BY Month(BorrowDate)<br>ORDER BY Count(Month(BorrowDate)) DESC;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Top_Month | Number_borrowed |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 10 | 12 |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 12 | 10 |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 8 | 9 |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"13\">\n<li>The oldest and the youngest clients of the library<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I used the SELECT statement to select the ClientDoB field from the Client table<\/li>\n\n\n\n<li>I used the NOW() function to dynamically get the current date and time and calculate the ages.<\/li>\n\n\n\n<li>I used the YEAR function on the results of NOW and subtracted the clients date of birth from this and gave it an alias of Age.<\/li>\n\n\n\n<li>I used the MAX() function to get the largest number from our ages and the MIN() to get the smallest<\/li>\n\n\n\n<li>I alised each of them as Oldest &amp; Youngest.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT MAX(YEAR(NOW())-Client.ClientDoB) AS Oldest,MIN(YEAR(NOW())-Client.ClientDoB)AS Youngest<br>FROM Client<br>INNER JOIN Borrower<br>ON Borrower.ClientId = Client.ClientId;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Oldest | Youngest |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| 62 | 12 |<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"14\">\n<li>First and last names of authors that wrote books in more than one genre<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I needed information from both the Author and Book tables: Author for the names, Book for the genre count.<\/li>\n\n\n\n<li>I used a SELECT statement to select the AuthorFirstName and AuthorLastName fields from the Author table.<\/li>\n\n\n\n<li>I alised them as First_Name and Last_Name<\/li>\n\n\n\n<li>Author table and the Book table both have AuthorId<\/li>\n\n\n\n<li>I used an INNER JOIN to connect it in the query.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-kubio-color-4-color has-text-color\">SELECT Max(Author.AuthorFirstName) AS First_Name, Max(Author.AuthorLastName) AS Last_Name<br>FROM Author INNER JOIN Book ON Author.AuthorId = Book.BookAuthor<br>GROUP BY Author.AuthorId;<\/p>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| First_Name | Last_Name |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Sofia | Smith |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Maria | Brown |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Elena | Martin |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Zoe | Roy |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Sebastian | Lavoie |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Dylan | Garcia |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Ian | Cruz |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Lucas | Smith |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Fabian | Wilson |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Liam | Taylor |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| William | Thomas |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Logan | Moore |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Oliver | Martin |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Alysha | Thompson |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Isabelle | Lee |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Emily | Clark |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| John | Young |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| David | Wright |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Thomas | Scott |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Helena | Adams |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Sofia | Carter |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Liam | Parker |<\/h4>\n\n\n\n<h4 class=\"has-text-align-center wp-block-heading\">| Emily | Murphy |<\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Practice with SQL &amp; Databases I took a class that required me to do an assignment that required me to create a database, create the tables within a database, Input data into said tables, configure the relationships between tables (primary\/foreign keys) and finally write SQL queries that query the data in different ways. I included [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":433,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-431","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/posts\/431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=431"}],"version-history":[{"count":14,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/posts\/431\/revisions"}],"predecessor-version":[{"id":717,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/posts\/431\/revisions\/717"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=\/wp\/v2\/media\/433"}],"wp:attachment":[{"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jonthecyberguy.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}