<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>TyroCity: DATA 210 Database Design &amp;amp; Analytics</title>
    <description>The latest articles on TyroCity by DATA 210 Database Design &amp;amp; Analytics (@database).</description>
    <link>https://tyrocity.com/database</link>
    <image>
      <url>https://tyrocity.com/images/7UPTBX8LjFxCeVU3M_DbFjWFr8vuiAjzIwiY6MPApVI/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9vcmdhbml6/YXRpb24vcHJvZmls/ZV9pbWFnZS80OC82/MDBkYTFjZS1jNjlj/LTRlMGYtOTQxMi1h/YjkwMDE4ZDcwMTgu/cG5n</url>
      <title>TyroCity: DATA 210 Database Design &amp;amp; Analytics</title>
      <link>https://tyrocity.com/database</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://tyrocity.com/feed/database"/>
    <language>en</language>
    <item>
      <title>SQL aggregate functions activities</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Sat, 29 Nov 2025 14:14:07 +0000</pubDate>
      <link>https://tyrocity.com/database/sql-aggregate-functions-activities-5c47</link>
      <guid>https://tyrocity.com/database/sql-aggregate-functions-activities-5c47</guid>
      <description>&lt;p&gt;Choose to either use the existing database or create a new one as you prefer.&lt;/p&gt;

&lt;p&gt;If you want to use existing database simply type &lt;code&gt;USE DatabaseName&lt;/code&gt; - where DatabaseName is the name of the database that exists within your system that you want to use.&lt;/p&gt;

&lt;p&gt;If you want to create a new database simply type &lt;code&gt;CREATE DATABASE DatabaseName&lt;/code&gt; - where DatabaseName is the name of the database you seek to create/add. Then follow the same USE command to continue with that database.&lt;/p&gt;

&lt;p&gt;Let's create 3 tables and add values under it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table 1: Patients&lt;/li&gt;
&lt;li&gt;Table 2: Therapists&lt;/li&gt;
&lt;li&gt;Table 3: TherapySessions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;a id="t1"&gt;Table 1: Patients&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Code to create table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Patients 
(patient_id INT NOT NULL PRIMARY KEY, 
first_name VARCHAR(50) NOT NULL, 
last_name VARCHAR(50) NOT NULL, 
address VARCHAR(100) NOT NULL, 
city VARCHAR(50) NOT NULL, 
state VARCHAR(50) NOT NULL, 
zip_code VARCHAR(10) NOT NULL, 
phone_number VARCHAR(20) NOT NULL, 
balance DECIMAL(10,2) NOT NULL );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code to insert values within the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Patients 
(patient_id, first_name, last_name, address, city, state, zip_code, phone_number, balance) 
VALUES 
(1, 'John', 'Doe', '123 Main St', 'Waterville', 'ME', '04901', '555-1234', 500.00), 
(2, 'Jane', 'Smith', '456 Elm St', 'Augusta', 'ME', '04330', '555-5678', 1000.00), 
(3, 'Bob', 'Johnson', '789 Maple St', 'Waterville', 'ME', '04901', '555-9012', 1500.00), 
(4, 'Sarah', 'Lee', '321 Oak St', 'Bangor', 'ME', '04401', '555-3456', 2000.00), 
(5, 'Mike', 'Brown', '654 Pine St', 'Portland', 'ME', '04101', '555-7890', 2500.00), 
(6, 'Lisa', 'Taylor', '987 Cedar St', 'Waterville', 'ME', '04901', '555-2345', 3000.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a id="t2"&gt;Table 2: Therapists&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Code to create table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Therapists 
(therapist_id INT AUTO_INCREMENT PRIMARY KEY, 
first_name VARCHAR(50), 
last_name VARCHAR(50), 
email VARCHAR(50), 
phone VARCHAR(20), 
street_address VARCHAR(100), 
city VARCHAR(50), 
state VARCHAR(2), 
zip_code VARCHAR(10), 
date_hired DATE, 
active TINYINT);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code to insert values within the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Therapists 
(first_name, last_name, email, phone, street_address, city, state, zip_code, date_hired, active) 
VALUES 
('John', 'Doe', 'johndoe@example.com', '555-123-4567', '123 Main St', 'Los Angeles', 'CA', '90001', '2021-01-01', 1), 
('Jane', 'Smith', 'janesmith@example.com', '555-234-5678', '456 Oak Ave', 'San Francisco', 'CA', '94101', '2021-02-15', 1), 
('Tom', 'Wilson', 'tomwilson@example.com', '555-345-6789', '789 Pine St', 'San Diego', 'CA', '92001', '2021-03-15', 1), 
('Emily', 'Jones', 'emilyjones@example.com', '555-456-7890', '321 Elm St', 'Sacramento', 'CA', '95814', '2021-04-01', 1), 
('Mark', 'Lee', 'marklee@example.com', '555-567-8901', '654 Cedar St', 'San Jose', 'CA', '95101', '2021-05-15', 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a id="t3"&gt;Table 3: TherapySessions&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Code to create table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE TherapySessions 
(session_id INT NOT NULL PRIMARY KEY, 
therapist_id INT NOT NULL, 
patient_id INT NOT NULL, 
session_date DATE NOT NULL, 
session_time TIME NOT NULL, 
therapy_description VARCHAR(100) NOT NULL, 
session_length INT NOT NULL, 
session_cost DECIMAL(10,2) NOT NULL, 
FOREIGN KEY (therapist_id) REFERENCES Therapists(therapist_id),
FOREIGN KEY (patient_id) REFERENCES Patients(patient_id) );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code to insert values within the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO TherapySessions 
(session_id, therapist_id, patient_id, session_date, session_time, therapy_description, session_length, session_cost) 
VALUES 
(1, 1, 1, '2021-10-18', '10:00:00', 'Physical Therapy', 30, 50.00),
(2, 2, 2, '2021-10-19', '11:00:00', 'Occupational Therapy', 45, 75.00), 
(3, 3, 3, '2021-10-20', '14:00:00', 'Speech Therapy', 60, 100.00), 
(4, 4, 1, '2021-10-21', '12:00:00', 'Movement Therapy', 60, 90.00), 
(5, 2, 5, '2021-10-22', '09:00:00', 'Physical Therapy', 30, 50.00), 
(6, 3, 6, '2021-10-23', '10:00:00', 'Speech Therapy', 60, 100.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the end of it, you should have 3 tables with data populated under each of it.&lt;/p&gt;

&lt;p&gt;Verify if the table is created successfully or not by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHOW TABLES;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the outcome shows all table names - you're good.&lt;/p&gt;

&lt;p&gt;Check if each of the 3 tables have the required data added correct or not by entering:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SELECT * FROM &lt;strong&gt;TableName&lt;/strong&gt;;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;where TableName is the name of the table you created. Use it 3 times - once per table to see their values.&lt;/p&gt;




&lt;p&gt;Questions to answer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How many therapists are there? Answer in one number only.&lt;/li&gt;
&lt;li&gt;How many therapists are there with their first name Tom? Answer in one number only.&lt;/li&gt;
&lt;li&gt;How many therapists are there living in San Jose? Answer in one number only.&lt;/li&gt;
&lt;li&gt;How much is the total session cost in the organization? &lt;/li&gt;
&lt;li&gt;How much total session cost is the organization getting for Physical Therapy? &lt;/li&gt;
&lt;li&gt;How much average session cost is the organization getting? &lt;/li&gt;
&lt;li&gt;How much average session cost is the organization getting for Physical Therapy? &lt;/li&gt;
&lt;li&gt;What is the lowest session cost that the organization is getting? &lt;/li&gt;
&lt;li&gt;What is the lowest session cost  that the organization is getting for Physical Therapy? &lt;/li&gt;
&lt;li&gt;What is the highest session cost that the organization is paying for Physical Therapy? &lt;/li&gt;
&lt;li&gt;What is the highest session cost that the organization is getting? &lt;/li&gt;
&lt;li&gt;How many sessions have the highest session cost? Answer in one number only.&lt;/li&gt;
&lt;li&gt;Extract just the month for each of the entries under "session_date" under TherapySessions. &lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;For the next phase of activities - let's create another table and populate it with data:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating table Employee&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Employee 
(Name VARCHAR(10), 
Gender VARCHAR(10), 
Department VARCHAR(10), 
Salary INT);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's insert data under the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Employee 
(Name, Gender, Department, Salary) 
VALUES 
('Ram', 'Male', 'Sales', 50000), 
('Sita', 'Female', 'IT', 70000), 
('Hari', 'Male', 'IT', 60000), 
('Geeta', 'Female', 'Sales', 50000), 
('Hari', 'Male', 'IT', 50000), 
('Rita', 'Female', 'Sales', 60000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once done, we should have the table as below created:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Gender&lt;/th&gt;
&lt;th&gt;Department&lt;/th&gt;
&lt;th&gt;Salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ram&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;td&gt;50,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sita&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;70,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hari&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;60,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Geeta&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;td&gt;50,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hari&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;50,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rita&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;td&gt;60,000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's continue with this to perform further activities.&lt;/p&gt;

</description>
      <category>bsit</category>
      <category>bscs</category>
    </item>
    <item>
      <title>WK2 Activity - Working with queries</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Thu, 16 May 2024 15:15:55 +0000</pubDate>
      <link>https://tyrocity.com/database/wk2-activity-working-with-queries-58k6</link>
      <guid>https://tyrocity.com/database/wk2-activity-working-with-queries-58k6</guid>
      <description>&lt;p&gt;Practice table::&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Order ID&lt;/th&gt;
&lt;th&gt;Customer Name&lt;/th&gt;
&lt;th&gt;Order Date&lt;/th&gt;
&lt;th&gt;Total Cost&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Jane Doe&lt;/td&gt;
&lt;td&gt;1/1/2022&lt;/td&gt;
&lt;td&gt;$100.00&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Jane Doe&lt;/td&gt;
&lt;td&gt;1/2/2022&lt;/td&gt;
&lt;td&gt;$75.00&lt;/td&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Mark Smith&lt;/td&gt;
&lt;td&gt;1/3/2022&lt;/td&gt;
&lt;td&gt;$50.00&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Emily Gray&lt;/td&gt;
&lt;td&gt;1/4/2022&lt;/td&gt;
&lt;td&gt;$200.00&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Tom Hill&lt;/td&gt;
&lt;td&gt;1/5/2022&lt;/td&gt;
&lt;td&gt;$150.00&lt;/td&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Sarah Jones&lt;/td&gt;
&lt;td&gt;1/6/2022&lt;/td&gt;
&lt;td&gt;$25.00&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Mike Brown&lt;/td&gt;
&lt;td&gt;1/7/2022&lt;/td&gt;
&lt;td&gt;$300.00&lt;/td&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Anna Green&lt;/td&gt;
&lt;td&gt;1/8/2022&lt;/td&gt;
&lt;td&gt;$100.00&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;David White&lt;/td&gt;
&lt;td&gt;1/9/2022&lt;/td&gt;
&lt;td&gt;$50.00&lt;/td&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Karen Black&lt;/td&gt;
&lt;td&gt;2/10/2022&lt;/td&gt;
&lt;td&gt;$175.00&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Questions to answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Retrieve all orders that have been shipped.&lt;/li&gt;
&lt;li&gt; Retrieve all orders that are still pending.&lt;/li&gt;
&lt;li&gt; Retrieve all orders that have a total cost of $100 or more.&lt;/li&gt;
&lt;li&gt; Retrieve all orders that were placed in January 2022.&lt;/li&gt;
&lt;li&gt; Retrieve all orders that were placed by customers whose name starts with "J".&lt;/li&gt;
&lt;li&gt; Retrieve all orders that were placed by customers whose name contains the letter "a".&lt;/li&gt;
&lt;li&gt; Retrieve the total cost of all orders that have been shipped.&lt;/li&gt;
&lt;li&gt; Retrieve the average cost of all orders that are still pending.&lt;/li&gt;
&lt;li&gt; Retrieve the earliest order date for each customer.&lt;/li&gt;
&lt;li&gt;Retrieve the customer who has placed the most orders.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>WK3 Assignment</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Sun, 28 Jan 2024 14:33:15 +0000</pubDate>
      <link>https://tyrocity.com/database/wk3-assignment-ach</link>
      <guid>https://tyrocity.com/database/wk3-assignment-ach</guid>
      <description>&lt;p&gt;To create database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE WK3ASSIGNMENT;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create Patient table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Patient 
(
    PatientNum  INT,
    LastName    VARCHAR(512),
    FirstName   VARCHAR(512),
    Address VARCHAR(512),
    City    VARCHAR(512),
    State   VARCHAR(512),
    ZipCode INT,
    Balance VARCHAR(512)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To input data into Patient table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Patient (PatientNum, LastName, FirstName, Address, City, State, ZipCode, Balance) VALUES
    ('1010', 'Koehler', 'Robbie', '119  West Bay Dr.', 'San  Vista', 'TX', '72510', '1,535.15 '),
    ('1011', 'King', 'Joseph', '941  Treemont', 'Oak  Hills', 'TX', '74081', '212.80 '),
    ('1012', 'Houghland', 'Susan', '7841  Lake  Side Dr.', 'Munster', 'TX', '72380', '1,955.40 '),
    ('1013', 'Falls', 'Tierra', '44 Applewood Ave.', 'Palm  Rivers', 'TX', '72511', '1,000.35 '),
    ('1014', 'Odepaul', 'Ben', '546  WCR 150  South', 'Munster', 'TX', '74093', '525.00 '),
    ('1015', 'Venable', 'Isaiah', '37 High School Road', 'Waterville', 'TX', '74183', '432.30 '),
    ('1016', 'Waggoner', 'Brianna', '2691  Westgrove St.', 'Delbert', 'TX', '72381', '714.25 '),
    ('1017', 'Short', 'Tobey', '1928  10th Ave.', 'Munster', 'TX', '72512', '967.60 '),
    ('1018', 'Baptist', 'Joseph', '300  Erin  Dr.', 'Waterville', 'TX', '76658', '1,846.75 '),
    ('1019', 'Culling', 'Latisha', '4238  East  71st  St.', 'San  Vista', 'TX', '74071', '1,988.50 '),
    ('1020', 'Marino', 'Andre', '919  Horton Ave.', 'Georgetown', 'TX', '72379', '688.95 '),
    ('1021', 'Wilson', 'Tammy', '424  October Blvd.', 'Waterville', 'TX', '76658', '2,015.30');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create another table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Session 
(
    SessionNum  INT,
    SessionDate VARCHAR(512),
    PatientNum  INT,
    LengthOfSession INT,
    TherapistID VARCHAR(512),
    TherapyCode INT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And, to input data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Session (SessionNum, SessionDate, PatientNum, LengthOfSession, TherapistID, TherapyCode) VALUES
    ('27', '10/10/2021', '1011', '45', 'JR085', '92507'),
    ('28', '10/11/2021', '1016', '30', 'AS648', '97010'),
    ('29', '10/11/2021', '1014', '60', 'SW124', '97014'),
    ('30', '10/12/2021', '1013', '30', 'BM273', '97033'),
    ('31', '10/15/2021', '1016', '90', 'AS648', '98960'),
    ('32', '10/16/2021', '1018', '15', 'JR085', '97035'),
    ('33', '10/17/2021', '1017', '60', 'SN852', '97039'),
    ('34', '10/17/2021', '1015', '45', 'BM273', '97112'),
    ('35', '10/18/2021', '1010', '30', 'SW124', '97113'),
    ('36', '10/18/2021', '1019', '75', 'SN852', '97116'),
    ('37', '10/19/2021', '1020', '30', 'BM273', '97124'),
    ('38', '10/19/2021', '1021', '60', 'AS648', '97535');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create Therapist table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Therapist 
(
    TherapistID VARCHAR(512),
    LastName    VARCHAR(512),
    FirstName   VARCHAR(512),
    Street  VARCHAR(512),
    City    VARCHAR(512),
    State   VARCHAR(512),
    ZipCode INT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To insert data into the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Therapist (TherapistID, LastName, FirstName, Street, City, State, ZipCode) VALUES
    ('AS648', 'Shields', 'Anthony', '5222  Eagle Court', 'Palm  Rivers', 'TX', '72511'),
    ('BM273', 'McClain', 'Bridgette', '385  West Mill St.', 'Waterville', 'TX', '76658'),
    ('JR085', 'Risk', 'Jonathan', '1010  650  North', 'Palm  Rivers', 'TX', '72511'),
    ('SN852', 'Nair', 'Saritha', '25 North Elm St.', 'Livewood', 'TX', '72512'),
    ('SW124', 'Wilder', 'Steven', '7354  Rockville Road', 'San  Vista', 'TX', '72510');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create Therapies table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Therapies 
(
    TherapyCode INT,
    Description VARCHAR(512),
    UnitOfTime  VARCHAR(512)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To insert data into it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Therapies (TherapyCode, Description, UnitOfTime) VALUES
    ('90901', 'Biofeedback training by any modality', ''),
    ('92240', 'Shoulder strapping', ''),
    ('92507', 'Treatment of speech', '15'),
    ('92530', 'Knee strapping', ''),
    ('92540', 'Ankle and/or foot strapping', ''),
    ('95831', 'Extremity or trunk muscle testing', ''),
    ('97010', 'Hot or cold pack application', ''),
    ('97012', 'Mechanical traction', ''),
    ('97014', 'Electrical stimulation', ''),
    ('97016', 'Vasopneumatic devices', ''),
    ('97018', 'Paraf n bath', ''),
    ('97022', 'Whirlpool', ''),
    ('97026', 'Infrared', ''),
    ('97032', 'Electrical stimulation', '15'),
    ('97033', 'Iontophoresis', '15'),
    ('97035', 'Ultrasound', '15'),
    ('97039', 'Unlisted  modality', '15'),
    ('97110', 'Therapeutic exercises to develop  strength and endurance, range of motion, and   exibility', '15'),
    ('97112', 'Neuromuscular re-education of movement, balance, coordination, etc.', '15'),
    ('97113', 'Aquatic  therapy with therapeutic exercises', '15'),
    ('97116', 'Gait training', '15'),
    ('97124', 'Massage', '15'),
    ('97139', 'Unlisted  therapeutic procedure', ''),
    ('97140', 'Manual therapy techniques', '15'),
    ('97150', 'Group  therapeutic procedure', '15'),
    ('97530', 'Dynamic activities to improve functional performance, direct (one-on-one) with the patient', '15'),
    ('97535', 'Self-care/home management training', '15'),
    ('97750', 'Physical performance test  or measurement', '15'),
    ('97799', 'Unlisted  physical medicine/rehabilitation service  or procedure', ''),
    ('98941', 'CMT of the spine', ''),
    ('98960', 'Education and training for patient self-management', '30');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;P.S. in each of the cases - it's down to your personal discretion to choose the data types for the values and make alterations to them as is required for your case. These data types provided are just placeholder and as such you're recommended to update those as is best.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Questions to answer based on it:&lt;/p&gt;

&lt;p&gt;-- 1. List all the information in the patient’s table sorted by city.&lt;/p&gt;

&lt;p&gt;-- 2. List the last names of patients whose balance is greater than 1,000.&lt;/p&gt;

&lt;p&gt;-- 3. List the city, last name, and balance of patients who live in Waterville and have a balance greater than 1,000.&lt;/p&gt;

&lt;p&gt;-- 4. List the last name, city, and balance of patients who live in Waterville or have a balance greater than $2,000.&lt;/p&gt;

&lt;p&gt;-- 5. Increase the balance by 2% of any patient whose balance is greater than $2,000.&lt;/p&gt;

&lt;p&gt;-- 6. List the session dates and numbers for those sessions scheduled between 10/18/2021 and 10/21/2021.&lt;/p&gt;

&lt;p&gt;-- 7. List the full name of the therapist scheduled to work on 10/16/2021.&lt;/p&gt;

&lt;p&gt;-- 8. How long are the therapy sessions for the therapist whose last name is Shields? List the length of each session.&lt;/p&gt;

&lt;p&gt;-- 9. Which therapies have the word “movement” in their description? List the therapy description only.&lt;/p&gt;

&lt;p&gt;-- 10. How many therapies are offered? Answer with one number only.&lt;/p&gt;

&lt;p&gt;-- 11. Write an SQL query that displays the therapies and their unit of time for the therapies that include the word bath, hot, or electrical.&lt;/p&gt;

&lt;p&gt;-- 12. Write an SQL query to display every therapist’s first name and last name as their full name, but only for those instructors not living in zip code 72511.&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 WK4 Assignment</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Sun, 26 Mar 2023 17:01:05 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-wk4-assignment-48h8</link>
      <guid>https://tyrocity.com/database/data-210-wk4-assignment-48h8</guid>
      <description>&lt;p&gt;In the following exercises, you will use the data in the JC Consulting database. Don’t forget to use a copy of the JC Consulting database so any changes you make will not affect future modules.&lt;/p&gt;

&lt;p&gt;Examine the JC Consulting data and complete the following case exercises/problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is or are not a benefit(s) of a view within the JC Consulting database?&lt;/li&gt;
&lt;li&gt;Which fields from the Projects table is or are not a good candidate to index?&lt;/li&gt;
&lt;li&gt;Which security features is or are not available to the JC Consulting database given it is an Access database?&lt;/li&gt;
&lt;li&gt;In the Employees table, how could you ensure that no HireDate values were entered prior to 1/1/2019?&lt;/li&gt;
&lt;li&gt;To query whether the Clients table has records that do not have any matching records in the Projects table, which join statement should be used?&lt;/li&gt;
&lt;li&gt;Write a SQL command that adds a new field named Region to the Clients table.&lt;/li&gt;
&lt;li&gt;What feature could you use to create system information about the tables and fields in the JC Consulting database?&lt;/li&gt;
&lt;li&gt;Where do you create data macros in the JC Consulting Access database?&lt;/li&gt;
&lt;li&gt;According to the article referenced by the Bureau of Labor Statistics, which fundamental competency for a job in database administration is not worth knowing?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apply key module concepts to the JC Consulting case:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using Access, open the Relationships window and identify all of the one-to-many relationships in the database as well as the field used in both tables to make the connection using the following pattern found in SQL, when connecting two tables using a WHERE or INNER JOIN clause. An example of one of the relationships is provided as a guide.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Clients.ClientID = Projects.ClientID&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using Access, an employee at JC Consulting tried to delete TaskID CODE01 from the
TaskMasterList table and received the following error message: “The record cannot be
deleted or changed because table ‘ProjectLineItemsincludes related records.”&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Why did the employee receive this error message?&lt;/p&gt;

&lt;p&gt;Submit your answers to the Examine and Apply questions in a single Word document.&lt;/p&gt;

&lt;p&gt;===&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Guide:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Q1: List the benefits of "view" for JC Consulting DB. What does it enable? Think and answer based on it.&lt;/p&gt;

&lt;p&gt;Q2: Index refers to primary, foreign key. From the projects table - what is and what is not the index?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/sHou2xrAN6DP2eQ6ZQqyckkt_YY1F4o6M4Vq9GTLyPk/rt:fit/w:800/g:sm/q:0/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9ncGhsYjYwbnZ6/eGs0aHBoOTFqei5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/sHou2xrAN6DP2eQ6ZQqyckkt_YY1F4o6M4Vq9GTLyPk/rt:fit/w:800/g:sm/q:0/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9ncGhsYjYwbnZ6/eGs0aHBoOTFqei5w/bmc" alt="index identification: projects table" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Q3: This is a MSAccess DB - so what security limitations does it have? Go general.&lt;/p&gt;

&lt;p&gt;Q4: You can do this in either &lt;a href="https://tyrocity.com/database/triggers-in-mysql-25f1"&gt;MySQL (trigger&lt;/a&gt; to make it no new entries are with that detail) or Access (with criteria)&lt;/p&gt;

&lt;p&gt;Q5: Review the relationships of the table - you simply need to answer what type of JOIN is to be used and why (or write the query itself)&lt;/p&gt;

&lt;p&gt;Q6: SQL query - general.&lt;/p&gt;

&lt;p&gt;Q7: General question, no review of data itself required.&lt;/p&gt;

&lt;p&gt;Q8: Macro creation - one of your group presented about it in the class itself. Does not ask you to write a macro itself but rather "where do you create" - as think smart.&lt;/p&gt;

&lt;p&gt;Q9: Refer to post here: &lt;a href="https://www.bls.gov/ooh/computer-and-information-technology/database-administrators.htm#tab-1" rel="noopener noreferrer"&gt;https://www.bls.gov/ooh/computer-and-information-technology/database-administrators.htm#tab-1&lt;/a&gt; or any other as you see fit. Navigate across different tabs for further info.&lt;/p&gt;

&lt;p&gt;Part 2 Q1: Below is the relation chat - one of the answer is already there in question list other such answers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/MdP9FmjDXMTuXBwb4wji6gsTp9guJTAU9uOsNNT03aI/rt:fit/w:800/g:sm/q:0/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy8yOTJzdjhzbWc4/ZHRwdXZ0YWRsYy5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/MdP9FmjDXMTuXBwb4wji6gsTp9guJTAU9uOsNNT03aI/rt:fit/w:800/g:sm/q:0/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy8yOTJzdjhzbWc4/ZHRwdXZ0YWRsYy5w/bmc" alt="JC Consulting DB relationship" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part 2 Q2: Why is there the error message - a simple answer would suffice.&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>Triggers in MySQL</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Thu, 23 Mar 2023 16:26:06 +0000</pubDate>
      <link>https://tyrocity.com/database/triggers-in-mysql-25f1</link>
      <guid>https://tyrocity.com/database/triggers-in-mysql-25f1</guid>
      <description>&lt;p&gt;Triggers are associated with a table and can not operate on it's own. If it's not specified to a table - it does not exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Triggers:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;BEFORE INSERT&lt;/li&gt;
&lt;li&gt;AFTER INSERT&lt;/li&gt;
&lt;li&gt;BEFORE UPDATE&lt;/li&gt;
&lt;li&gt;AFTER UPDATE&lt;/li&gt;
&lt;li&gt;BEFORE DELETE&lt;/li&gt;
&lt;li&gt;AFTER DELETE&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Trigger general flow / Syntax&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/5HejZBI6fc2aVxCGHyxiz7rNH-fpPtS24oQzLCiZFFs/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9zOGU2ZXN4MXA4/Yndib3h0ZDF0Zy5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/5HejZBI6fc2aVxCGHyxiz7rNH-fpPtS24oQzLCiZFFs/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9zOGU2ZXN4MXA4/Yndib3h0ZDF0Zy5w/bmc" alt="Trigger syntax" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TRIGGER TriggerName
    (AFTER | BEFORE) (INSERT | UPDATE | DELETE)  
         ON TableName FOR EACH ROW    
         BEGIN    
        -- trigger body   
        END;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new terminology: &lt;strong&gt;DELIMITER&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The default delimiter MySQL considers is semicolon (;). However, in cases where ; might be used before the actual end of the query, command - we need to find a way to get past it. This is where we set the delimiter to be anything else. Often times, it is commonly set to $$, which means that the semicolon (;) used in the trigger code WILL NOT be interpreted as the end of the statement.&lt;/p&gt;

&lt;p&gt;Then, after the END statement of the trigger, you need to use the same delimiter ($$) again to tell MySQL that the trigger definition has ended, and reset the delimiter to its default value (;) using the statement DELIMITER ;.&lt;/p&gt;

&lt;p&gt;An example of the same as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER TriggerName
    (AFTER | BEFORE) (INSERT | UPDATE | DELETE)  
         ON TableName FOR EACH ROW    
         BEGIN    
        -- trigger body   
        END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's practice.&lt;/p&gt;

&lt;p&gt;First, let's create the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE triggers;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create our first table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE `employee` (
  `name` varchar(45) NOT NULL,
  `occupation` varchar(35) DEFAULT NULL,
  `working_date` date DEFAULT NULL,
  `working_hours` varchar(10) DEFAULT NULL,
  `Age` varchar(3) DEFAULT NULL
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dumping data for table &lt;code&gt;employee&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO `employee` (`name`, `occupation`, `working_date`, `working_hours`, `Age`) VALUES
('Antonio', 'Business', '2020-10-04', '11', '52'),
('Brayden', 'Teacher', '2020-10-04', '12', '44'),
('Marco', 'Doctor', '2020-10-04', '14', '28'),
('Peter', 'Actor', '2020-10-04', '13', '26'),
('Robin', 'Scientist', '2020-10-04', '12', '29'),
('Warner', 'Engineer', '2020-10-04', '10', '32');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;BEFORE INSERT Trigger - 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER capitalize_name
BEFORE INSERT ON employee
FOR EACH ROW
BEGIN
SET NEW.name = CONCAT(UCASE(LEFT(NEW.name, 1)), SUBSTRING(NEW.name, 2));
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Where to find the triggers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From your phpMyAdmin interface - click on database you're working under. On the page that opens, from top menu bar locate "Triggers" and click on it to find it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/Y2Bg-07eoJPWSL-Fo5svnoIGbecV7dvocvHfVsST1co/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9zbnJiOGl5M3Qy/Y3g1ajR2Zjg1ZS5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/Y2Bg-07eoJPWSL-Fo5svnoIGbecV7dvocvHfVsST1co/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9zbnJiOGl5M3Qy/Y3g1ajR2Zjg1ZS5w/bmc" alt="locating trigger in phpMyAdmin" width="880" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking on it would open interface as below where all the avaiable triggers for the database along with the table those trigger are associated with is displayed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/zIXXd23ZZ6laqKpRi2DViCqrdpF7-rEgj9KGSn_pie4/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9lYnkxdGpxZGpw/N3g4cW5qcjBsOS5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/zIXXd23ZZ6laqKpRi2DViCqrdpF7-rEgj9KGSn_pie4/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9lYnkxdGpxZGpw/N3g4cW5qcjBsOS5w/bmc" alt="trigger list phpMyAdmin" width="880" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ok, so let's get to the first trigger we just created - what does it do and how does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ignoring the general structure for trigger, and just taking the query from it, that would be:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SET NEW.name = CONCAT(UCASE(LEFT(NEW.name, 1)), SUBSTRING(NEW.name, 2));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here's a breakdown of what each function does: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;LEFT(NEW.name, 1)&lt;/strong&gt;: Returns the leftmost character of the name field, i.e. the first letter. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UCASE((LEFT(NEW.name, 1))&lt;/strong&gt;: Converts the first letter from left to uppercase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SUBSTRING(NEW.name, 2)&lt;/strong&gt;: Returns the remainder of the name field starting from the second character.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CONCAT()&lt;/strong&gt;: Concatenates the capitalized first letter with the rest of the name field.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This will take the first character of the name and capitalize it and then join it with all the other text to insert the name.&lt;/p&gt;

&lt;p&gt;Let's test if the trigger work by attempting to insert a name which is in lower case via SQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO `employee` (`name`, `occupation`, `working_date`, `working_hours`, `Age`) VALUES
('john', 'Business', '2020-10-04', '11', '52');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The outcome however, has the first letter 'j' of "john" capitalized  even if we entered it in all lower case:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/YLRy2COm-rY-2LJJI-xc5BpHRjxuiy38mwSqdOrwW_U/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy80dWNzZWNyeXR3/enMxZXFzOTNzbC5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/YLRy2COm-rY-2LJJI-xc5BpHRjxuiy38mwSqdOrwW_U/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy80dWNzZWNyeXR3/enMxZXFzOTNzbC5w/bmc" alt="trigger outcome" width="858" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This confirms that the query did work as required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BEFORE INSERT Trigger - 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's test with another trigger for the same table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER set_min_working_hours
BEFORE INSERT ON employee
FOR EACH ROW
BEGIN
    IF NEW.working_hours &amp;lt; 8 THEN
        SET NEW.working_hours = 8;
    END IF;
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This trigger do not allow a new employee with working hours less than 8. If it's any lower it'll automatically set it to be 8.&lt;/p&gt;

&lt;p&gt;Let's test this by inserting an employee with working hour less than 8:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO employee (name,working_hours) VALUES
('master',3);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The outcome:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/mX0VDYkq7np7Hc6nxgNJyAvdrTdrrjwDo8EQBICm3Ow/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy83MnZxanIzdjFx/M291bmY0djQ1ay5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/mX0VDYkq7np7Hc6nxgNJyAvdrTdrrjwDo8EQBICm3Ow/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy83MnZxanIzdjFx/M291bmY0djQ1ay5w/bmc" alt="trigger outcome 2" width="880" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see from the above outcome - the name even if was inserted in all lower case has it's first letter capital while the working hour even if was set to be 3 is coming as 8.&lt;/p&gt;

&lt;p&gt;This refers that both the triggers are working for the following table.&lt;/p&gt;




&lt;p&gt;Let's create 2 tables &lt;code&gt;order&lt;/code&gt; and &lt;code&gt;counter&lt;/code&gt; to test AFTER INSERT trigger. Below is the code used to create the table and dump values  as required. We will only populate one of the two tables as of now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE orders (
    id INT PRIMARY KEY AUTO_INCREMENT,
    order_date DATE,
    customer_name VARCHAR(50),
    total_amount DECIMAL(10, 2)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE counter (
    id INT PRIMARY KEY,
    order_count INT DEFAULT 0
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO counter (id, order_count) VALUES (1, 0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's now create a trigger to count the number of orders i.e. as any new values are inserted in the table &lt;code&gt;orders&lt;/code&gt; - the &lt;code&gt;order_count&lt;/code&gt; field under &lt;code&gt;counter&lt;/code&gt; table should update as well with the correct count.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AFTER INSERT Trigger - 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER orders_insert_trigger
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
    UPDATE counter SET order_count = order_count + 1;
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's try inserting the values to see how it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO orders (order_date, customer_name, total_amount) VALUES ('2023-03-21', 'John Doe', 100.00);
INSERT INTO orders (order_date, customer_name, total_amount) VALUES ('2023-03-21', 'Ram Bahadur', 300.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the outcome:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/Ya0hgLUBOKIfCUvgyRX5IZwD93Xjzs8Pxf1jM7dqcFc/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9wdTRncWYxamc1/ZTY4MWo4a2VpYi5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/Ya0hgLUBOKIfCUvgyRX5IZwD93Xjzs8Pxf1jM7dqcFc/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9wdTRncWYxamc1/ZTY4MWo4a2VpYi5w/bmc" alt="trigger order count outcome" width="880" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With 2 new values inserted to &lt;code&gt;order&lt;/code&gt; table - the &lt;code&gt;order_count&lt;/code&gt; increased accordingly. You can test this further by adding more orders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AFTER INSERT Trigger - 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For this, let's try to calculate the total order value. And, for which we will create a table &lt;code&gt;amount_counter&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE amount_counter (
  id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  total_amount DECIMAL(10,2) NOT NULL DEFAULT 0.00
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO amount_counter (total_amount) VALUES (0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create a trigger for the same as below to calculate the total order value (P.S. this will only count for new orders as such if you do already have fields in the table the outcome will be different) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER orders_amount_trigger 
AFTER INSERT ON orders 
FOR EACH ROW 
BEGIN
  UPDATE amount_counter SET total_amount = total_amount + NEW.total_amount WHERE id = 1;
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's test this by inserting two new values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO orders (order_date, customer_name, total_amount) VALUES ('2023-03-22', 'Sita Kumari', 200.00);
INSERT INTO orders (order_date, customer_name, total_amount) VALUES ('2023-03-22', 'RK Bahadur', 400.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, visiting &lt;code&gt;amount_counter&lt;/code&gt; table, we can see that the &lt;code&gt;total_amount&lt;/code&gt; is 600 as it should be based on the two values we added:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/izNX9euzE7UKIcK2CPPWZDoc0b6fxv78rCEKbin2lrM/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9qcG03YTZqamdw/emZnMXRwdng5dS5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/izNX9euzE7UKIcK2CPPWZDoc0b6fxv78rCEKbin2lrM/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9qcG03YTZqamdw/emZnMXRwdng5dS5w/bmc" alt="amount counter trigger outcome" width="844" height="526"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;For learning about BEFORE UPDATE trigger - let's start by first creating the table and inserting dummy data to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE employee_salary (
    id INT PRIMARY KEY,
    name VARCHAR(50),
    salary INT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO employee_salary (id, name, salary) VALUES
(1, 'John', 50000),
(2, 'Sarah', 60000),
(3, 'Mike', 45000),
(4, 'Emily', 55000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the table is created - let's now create the trigger for &lt;strong&gt;BEFORE UPDATE&lt;/strong&gt; action. In this trigger, we check for UPDATE action if the salary is anything lower than 40,000 and if it is the case - the salary is auto set to the lowest limit allowed which would be 40,000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER update_salary
BEFORE UPDATE ON employee_salary
FOR EACH ROW
BEGIN
    IF NEW.salary &amp;lt; 40000 THEN
        SET NEW.salary = 40000;
    END IF;
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's test the trigger to action - for this let's try setting the salary for one of the employee to 35,000 and see what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE employee_salary SET salary = 35000 WHERE id = 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://tyrocity.com/images/D0xkzE05yLIff9Y6idbxK7Ig42K4_W0YDAEisEFItTA/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy8yOG1vcTZlcTFq/bHg5NmF1dnBlbi5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/D0xkzE05yLIff9Y6idbxK7Ig42K4_W0YDAEisEFItTA/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy8yOG1vcTZlcTFq/bHg5NmF1dnBlbi5w/bmc" alt="trigger update salary outcome" width="796" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that the employee with id 3 has salary set to 40,000 by the system even if we had updated the salary to be 35,000 due to the trigger in place.&lt;/p&gt;

&lt;p&gt;The trigger prevented the salary to be set any lower than 40k - anything lower and it's set to 40k automatically.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;AFTER UPDATE trigger exercise&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's create 2 tables &lt;code&gt;product&lt;/code&gt; and &lt;code&gt;product_inventory&lt;/code&gt; to test AFTER UPDATE trigger. Below is the code used to create the table and dump values  as required:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE product (
  id INT PRIMARY KEY,
  name VARCHAR(50),
  price DECIMAL(10,2),
  quantity INT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO product (id, name, price, quantity)
VALUES
  (1, 'Product 1', 10.00, 5),
  (2, 'Product 2', 20.00, 3),
  (3, 'Product 3', 30.00, 7),
  (4, 'Product 4', 15.00, 2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE product_inventory (
  product_id INT NOT NULL,
  quantity INT NOT NULL,
  PRIMARY KEY (product_id)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO product_inventory (product_id, quantity)
VALUES
  (1, 5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create a trigger to update the &lt;code&gt;product_inventory&lt;/code&gt; table with the updated stock for product_id 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER update_product_inventory
AFTER UPDATE ON product
FOR EACH ROW
BEGIN
  DECLARE inventory INT;

  SET inventory = NEW.quantity - OLD.quantity;

  UPDATE product_inventory
  SET quantity = quantity + inventory
  WHERE product_id = NEW.id;
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, to test it let's update quantity for Product 1 from 5 to 8 and see what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE product
SET quantity = 8
WHERE id = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The outcome as below shows that the &lt;code&gt;product_inventory&lt;/code&gt; table does have quantity increased to 8 instead of previous 5 even if the above UPDATE command was only done for product table, confirming the query action:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/mXq_0eg0BPOqg0F8_g6ENZYAGzyAylFUn7nn4YmLlho/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9mOTFyOGc4dm42/OWYweGs5NGg2cC5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/mXq_0eg0BPOqg0F8_g6ENZYAGzyAylFUn7nn4YmLlho/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9mOTFyOGc4dm42/OWYweGs5NGg2cC5w/bmc" alt="after update query output" width="853" height="408"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;BEFORE DELETE trigger exercise&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For the following exercise, let's create a table &lt;code&gt;products&lt;/code&gt; of whose structure and dummy data are as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE products (
  id INT PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  price DECIMAL(10,2) NOT NULL,
  stock_quantity INT NOT NULL
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO products (id, name, price, stock_quantity) VALUES
(1, 'Product 1', 10.50, 0),
(2, 'Product 2', 5.99, -50),
(3, 'Product 3', 20.00, 25),
(4, 'Product 4', 15.75, 75);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create a trigger which will not allow the removal of any product if it has any stuck left (meaning - it'll only allow to remove products with 0 or lesser stock_quantity):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$
CREATE TRIGGER delete_products
BEFORE DELETE ON products
FOR EACH ROW
BEGIN
  IF OLD.stock_quantity &amp;gt; 0 THEN
    SIGNAL SQLSTATE '45000'
      SET MESSAGE_TEXT = 'Cannot delete product, stock quantity still left.';
  END IF;
END $$
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's test the function by removing &lt;code&gt;product_id&lt;/code&gt; 1 which has 0 as &lt;code&gt;stock_quantity&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM products WHERE id = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Outcome is successful execution of the same and data removal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/BBCwq88YdxneLM9RpIJMLjUIP85NloElraOP36qnHVo/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy82ZjdqaDFpaXlw/eG9hb3d3bXN4ai5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/BBCwq88YdxneLM9RpIJMLjUIP85NloElraOP36qnHVo/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy82ZjdqaDFpaXlw/eG9hb3d3bXN4ai5w/bmc" alt="BEFORE DELETE trigger outcome 1" width="535" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's now try removing another product with &lt;code&gt;product_id&lt;/code&gt; 3 which has 25 as &lt;code&gt;stock_quantity&lt;/code&gt; (which is higher than 0) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM products WHERE id = 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Outcome for this is a failed process:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/xTcidXaw8So2JOGAqCFijYJzz5yW1NUx3OUeekIDQcU/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy92OGJzanJwMTFu/OGFuYjlrY3hidy5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/xTcidXaw8So2JOGAqCFijYJzz5yW1NUx3OUeekIDQcU/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy92OGJzanJwMTFu/OGFuYjlrY3hidy5w/bmc" alt="BEFORE DELETE trigger outcome 2" width="661" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, we can see the successful execution of the BEFORE DELETE trigger here which did not allow the operation to complete if there's at least one or more quantity left but did allow the removal of a product if it has 0 or lesser product left to sell.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;AFTER DELETE trigger exercise&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For the following activity/learning let's create two tables &lt;code&gt;salaries&lt;/code&gt; and &lt;code&gt;total_salary_budget&lt;/code&gt; and insert dummy data to it as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE salaries (  
    emp_num INT PRIMARY KEY,  
    salary DEC(8 , 2 ) NOT NULL DEFAULT 0  
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO salaries (emp_num, salary)  
VALUES  
    (101, 50000),  
    (102, 55000),  
    (103, 60000),
    (104, 65000),
    (105, 70000),              
    (106, 75000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE total_salary_budget(  
    total_budget DECIMAL(10,2) NOT NULL  
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO total_salary_budget (total_budget)  
SELECT SUM(salary) FROM salaries;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create a trigger to update &lt;code&gt;total_salary_budget&lt;/code&gt; table's &lt;code&gt;total_budget&lt;/code&gt; field with the updated budget as a employee is fired/leaves the job (here: removed from the database table):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELIMITER $$    
CREATE TRIGGER after_delete_total_salary  
AFTER DELETE  
ON salaries FOR EACH ROW  
BEGIN  
   UPDATE total_salary_budget SET total_budget = total_budget - old.salary;  
END $$   
DELIMITER ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before writing a query to remove an employee - let's take a minute to review the current &lt;code&gt;total_budget&lt;/code&gt; where we can see it's 375,000.00:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/ILi8gb-30x1PykEOagrlmg4fYcmy8KNf2ZnWsBUm0Ns/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy80eG9obDVwMXBq/cjRocHlybTk5bC5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/ILi8gb-30x1PykEOagrlmg4fYcmy8KNf2ZnWsBUm0Ns/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy80eG9obDVwMXBq/cjRocHlybTk5bC5w/bmc" alt="total budget - AFTER DELETE trigger learning" width="841" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's remove &lt;code&gt;emp_num&lt;/code&gt; from &lt;code&gt;salaries&lt;/code&gt; table using the following command and see what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM salaries WHERE emp_num = 101;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;emp_num&lt;/code&gt; 101 had a salary of 50,000 as such when the employ is removed from the salary slab the &lt;code&gt;total_budget&lt;/code&gt; which was previously 375,000 should come as 325,000 if it was successfully updated. Let's check:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/KUY1rHfMkACecZ2knZd2T2MykqgJol5hh_k21P0prYE/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9hM2lxOHI1MTd4/dmk0emJncHRyZC5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/KUY1rHfMkACecZ2knZd2T2MykqgJol5hh_k21P0prYE/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9hM2lxOHI1MTd4/dmk0emJncHRyZC5w/bmc" alt="AFTER DELETE trigger test outcome" width="877" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can indeed see that the &lt;code&gt;total_budget&lt;/code&gt; is now 325,000 and as such we can confirm that the trigger did function as was intended.&lt;/p&gt;

&lt;p&gt;This is all for Triggers in MySQL. If you have any further concerns or questions - do drop them below in the comments section.&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 Week 3 Class 3 Answers</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Fri, 17 Mar 2023 03:38:00 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-week-3-class-3-answers-270n</link>
      <guid>https://tyrocity.com/database/data-210-week-3-class-3-answers-270n</guid>
      <description>&lt;p&gt;-- 1. SUM: What is the total amount of all orders?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(order_total) FROM orders;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 2. COUNT: How many customers are there in the database?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT COUNT(*) FROM customers;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 3. AVG: What is the average total amount of all orders?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT AVG(order_total) FROM orders;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 4. MIN: What is the minimum total amount of all orders?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT MIN(order_total) FROM orders;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 5. MAX: What is the maximum total amount of all orders?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT MAX(order_total) FROM orders;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 6. GROUP BY: What is the total amount of orders for each customer?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT customer_id, SUM(order_total) FROM orders GROUP BY customer_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 7. SELECT subquery: What is the first name and last name of the customer with the highest total amount of orders?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT first_name, last_name FROM customers WHERE customer_id = (SELECT customer_id FROM orders GROUP BY customer_id ORDER BY SUM(order_total) DESC LIMIT 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 8. WHERE subquery: What is the total amount of orders made by customer with last_name in Smith?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(order_total) FROM orders WHERE customer_id IN (SELECT customer_id FROM customers WHERE last_name = 'Smith');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 9. FROM subquery: What is the total amount of orders made by customers who live in the same city as customer_id 2? (ALTER table to include city field and add values to it with UPDATE)&lt;/p&gt;

&lt;p&gt;===========&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTRA STEPS - Do first
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER TABLE customers ADD COLUMN city VARCHAR(255);

UPDATE customers SET city = 'New York' WHERE customer_id = 1;
UPDATE customers SET city = 'Kathmandu' WHERE customer_id = 2;
UPDATE customers SET city = 'Kathmandu' WHERE customer_id = 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(order_total) FROM orders WHERE customer_id IN (SELECT customer_id FROM customers WHERE city = (SELECT city FROM customers WHERE customer_id = 2));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 10. UNION: What are the customer names of customers who have placed an order, as well as customers who have not placed an order?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT first_name, last_name FROM customers WHERE customer_id IN (SELECT customer_id FROM orders) UNION SELECT first_name, last_name FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM orders);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 11. UNION ALL: What are the customer names of customers who have placed an order, as well as customers who have not placed an order, and what is the corresponding city for each customer?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT first_name, last_name, city FROM customers WHERE customer_id IN (SELECT customer_id FROM orders) UNION ALL SELECT first_name, last_name, city FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM orders);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 12. UPDATE: Change the total amount of order_id 3 to 100.00.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE orders SET order_total = 100.00 WHERE order_id = 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 13. INSERT: Add a new order for customer_id 101 with order_total 150.00.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO orders (customer_id, order_total) VALUES (101, 150.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 14. DELETE: Delete all orders with customer_id more than 100&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM orders WHERE customer_id &amp;gt; 100;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 Week 3 Class 3 Resources</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Thu, 16 Mar 2023 15:15:31 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-week-3-class-3-resources-5fje</link>
      <guid>https://tyrocity.com/database/data-210-week-3-class-3-resources-5fje</guid>
      <description>&lt;p&gt;Let's create a database to start with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE WK3CLASS3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create 2 tables (orders &amp;amp; customers) and input data for the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE orders (
  order_id INT NOT NULL AUTO_INCREMENT,
  customer_id INT NOT NULL,
  order_date DATE NOT NULL,
  order_total DECIMAL(10,2) NOT NULL,
  PRIMARY KEY (order_id)
);

INSERT INTO orders (customer_id, order_date, order_total)
VALUES (1, '2022-12-01', 100.50),
       (1, '2022-12-02', 75.25),
       (2, '2022-12-01', 200.00),
       (2, '2022-12-03', 150.75),
       (3, '2022-12-02', 50.00),
       (3, '2022-12-03', 125.50);

CREATE TABLE customers (
  customer_id INT NOT NULL AUTO_INCREMENT,
  first_name VARCHAR(50) NOT NULL,
  last_name VARCHAR(50) NOT NULL,
  email VARCHAR(100) NOT NULL,
  PRIMARY KEY (customer_id)
);

INSERT INTO customers (first_name, last_name, email)
VALUES ('John', 'Doe', 'jdoe@example.com'),
       ('Jane', 'Smith', 'jsmith@example.com'),
       ('Bob', 'Johnson', 'bjohnson@example.com');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Questions to practice&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;-- 1. SUM: What is the total amount of all orders?&lt;/p&gt;

&lt;p&gt;-- 2. COUNT: How many customers are there in the database?&lt;/p&gt;

&lt;p&gt;-- 3. AVG: What is the average total amount of all orders?&lt;/p&gt;

&lt;p&gt;-- 4. MIN: What is the minimum total amount of all orders?&lt;/p&gt;

&lt;p&gt;-- 5. MAX: What is the maximum total amount of all orders?&lt;/p&gt;

&lt;p&gt;-- 6. GROUP BY: What is the total amount of orders for each customer?&lt;/p&gt;

&lt;p&gt;-- 7. SELECT subquery: What is the first name and last name of the customer with the highest total amount of orders?&lt;/p&gt;

&lt;p&gt;-- 8. WHERE subquery: What is the total amount of orders made by customer with last_name in Smith?&lt;/p&gt;

&lt;p&gt;-- 9. FROM subquery: What is the total amount of orders made by customers who live in the same city as customer_id 2? (ALTER table to include city field and add values to it with UPDATE)&lt;/p&gt;

&lt;p&gt;Do perform the following action before writing SQL for the question::&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER TABLE customers ADD COLUMN city VARCHAR(255);

UPDATE customers SET city = 'New York' WHERE customer_id = 1;
UPDATE customers SET city = 'Kathmandu' WHERE customer_id = 2;
UPDATE customers SET city = 'Kathmandu' WHERE customer_id = 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 10. UNION: What are the customer names of customers who have placed an order, as well as customers who have not placed an order?&lt;/p&gt;

&lt;p&gt;Do perform the following action before writing the query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO customers (first_name, last_name, email)
VALUES ('Happy', 'Says', 'happy@example.com');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- 11. UNION ALL: What are the customer names of customers who have placed an order, as well as customers who have not placed an order, and what is the corresponding city for each customer?&lt;/p&gt;

&lt;p&gt;-- 12. UPDATE: Change the total amount of order_id 3 to 100.00.&lt;/p&gt;

&lt;p&gt;-- 13. INSERT: Add a new order for customer_id 101 with order_total 150.00.&lt;/p&gt;

&lt;p&gt;-- 14. DELETE: Delete all orders with customer_id more than 100&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 Week 3 Class 2 Activity 2 Resources</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Wed, 15 Mar 2023 15:44:02 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-week-3-class-2-activity-2-resources-1f3p</link>
      <guid>https://tyrocity.com/database/data-210-week-3-class-2-activity-2-resources-1f3p</guid>
      <description>&lt;h2&gt;
  
  
  Activity 2: Assignment reference activity
&lt;/h2&gt;

&lt;p&gt;Tools used: XAMPP (Apache &amp;amp; MySQL service started)&lt;/p&gt;

&lt;p&gt;Start by first starting both Apache and MySQL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/bUC5Pq5YzDXeEKaJTP51OMC8HCkbHp14cbU88IiUe20/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9kcnU4M3hpemFu/d2xxYTQwamU1eS5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/bUC5Pq5YzDXeEKaJTP51OMC8HCkbHp14cbU88IiUe20/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9kcnU4M3hpemFu/d2xxYTQwamU1eS5w/bmc" alt="XAMPP Interface" width="832" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once that is done, click on "Admin" next to MySQL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/tHqy4WabsLE9invd-g0A4-Do-hpoRedF6bB22sucZO8/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy93MnFhNXB0azd0/ZHl1aG1oY3AxbC5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/tHqy4WabsLE9invd-g0A4-Do-hpoRedF6bB22sucZO8/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy93MnFhNXB0azd0/ZHl1aG1oY3AxbC5w/bmc" alt="XAMPP MySQL" width="834" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you do so, it will open phpMyAdmin in your local device. Visit "SQL":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/DxaUY4ANWi-MPCalJIs0kPNVJtjLCqWdPpumTUhHvk4/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9zbjZ0OHc1dXE4/MzV4ZjN4cmVwNS5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/DxaUY4ANWi-MPCalJIs0kPNVJtjLCqWdPpumTUhHvk4/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9zbjZ0OHc1dXE4/MzV4ZjN4cmVwNS5w/bmc" alt="phpMyAdmin interface" width="880" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, start entering the command to first create the database, and then table and then insert data within it as detailed below.&lt;/p&gt;

&lt;p&gt;Statements based on MySQL&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Database&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE WK3ACTIVITY2;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating &lt;code&gt;Patients&lt;/code&gt; table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Patients (
  patient_id INT NOT NULL PRIMARY KEY,
  first_name VARCHAR(50) NOT NULL,
  last_name VARCHAR(50) NOT NULL,
  address VARCHAR(100) NOT NULL,
  city VARCHAR(50) NOT NULL,
  state VARCHAR(50) NOT NULL,
  zip_code VARCHAR(10) NOT NULL,
  phone_number VARCHAR(20) NOT NULL,
  balance DECIMAL(10,2) NOT NULL
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Inserting data into &lt;code&gt;Patients&lt;/code&gt; table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Patients (patient_id, first_name, last_name, address, city, state, zip_code, phone_number, balance) VALUES
  (1, 'John', 'Doe', '123 Main St', 'Waterville', 'ME', '04901', '555-1234', 500.00),
  (2, 'Jane', 'Smith', '456 Elm St', 'Augusta', 'ME', '04330', '555-5678', 1000.00),
  (3, 'Bob', 'Johnson', '789 Maple St', 'Waterville', 'ME', '04901', '555-9012', 1500.00),
  (4, 'Sarah', 'Lee', '321 Oak St', 'Bangor', 'ME', '04401', '555-3456', 2000.00),
  (5, 'Mike', 'Brown', '654 Pine St', 'Portland', 'ME', '04101', '555-7890', 2500.00),
  (6, 'Lisa', 'Taylor', '987 Cedar St', 'Waterville', 'ME', '04901', '555-2345', 3000.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating &lt;code&gt;Therapists&lt;/code&gt; table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Therapists (
    therapist_id INT AUTO_INCREMENT PRIMARY KEY,
    first_name VARCHAR(50),
    last_name VARCHAR(50),
    email VARCHAR(50),
    phone VARCHAR(20),
    street_address VARCHAR(100),
    city VARCHAR(50),
    state VARCHAR(2),
    zip_code VARCHAR(10),
    date_hired DATE,
    active TINYINT(1)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inserting into &lt;code&gt;Therapists&lt;/code&gt; table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Therapists (first_name, last_name, email, phone, street_address, city, state, zip_code, date_hired, active)
VALUES
('John', 'Doe', 'johndoe@example.com', '555-123-4567', '123 Main St', 'Los Angeles', 'CA', '90001', '2021-01-01', 1),
('Jane', 'Smith', 'janesmith@example.com', '555-234-5678', '456 Oak Ave', 'San Francisco', 'CA', '94101', '2021-02-15', 1),
('Tom', 'Wilson', 'tomwilson@example.com', '555-345-6789', '789 Pine St', 'San Diego', 'CA', '92001', '2021-03-15', 1),
('Emily', 'Jones', 'emilyjones@example.com', '555-456-7890', '321 Elm St', 'Sacramento', 'CA', '95814', '2021-04-01', 1),
('Mark', 'Lee', 'marklee@example.com', '555-567-8901', '654 Cedar St', 'San Jose', 'CA', '95101', '2021-05-15', 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating &lt;code&gt;TherapySessions&lt;/code&gt; table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE TherapySessions (
  session_id INT NOT NULL PRIMARY KEY,
  therapist_id INT NOT NULL,
  patient_id INT NOT NULL,
  session_date DATE NOT NULL,
  session_time TIME NOT NULL,
  therapy_description VARCHAR(100) NOT NULL,
  session_length INT NOT NULL,
  session_cost DECIMAL(10,2) NOT NULL,
  FOREIGN KEY (therapist_id) REFERENCES Therapists(therapist_id),
  FOREIGN KEY (patient_id) REFERENCES Patients(patient_id)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Inserting into &lt;code&gt;TherapySessions&lt;/code&gt; table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO TherapySessions (session_id, therapist_id, patient_id, session_date, session_time, therapy_description, session_length, session_cost) VALUES
  (1, 1, 1, '2021-10-18', '10:00:00', 'Physical Therapy', 30, 50.00),
  (2, 2, 2, '2021-10-19', '11:00:00', 'Occupational Therapy', 45, 75.00),
  (3, 3, 3, '2021-10-20', '14:00:00', 'Speech Therapy', 60, 100.00),
  (4, 4, 1, '2021-10-21', '12:00:00', 'Movement Therapy', 60, 90.00),
  (5, 2, 5, '2021-10-22', '09:00:00', 'Physical Therapy', 30, 50.00),
  (6, 3, 6, '2021-10-23', '10:00:00', 'Speech Therapy', 60, 100.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Questions to answer (write queries for) based on the above table&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1 . List all the information in the patient’s table sorted by city.&lt;/p&gt;

&lt;p&gt;2 . List the last names of patients whose balance is greater than $1,000.&lt;/p&gt;

&lt;p&gt;3 . List the city, last name, and balance of patients who live in Waterville and have a balance greater than $1,000.&lt;/p&gt;

&lt;p&gt;4 . List the last name, city, and balance of patients who live in Waterville or have a balance greater than $2,000.&lt;/p&gt;

&lt;p&gt;5 . Increase the balance by 2% of any patient whose balance is greater than $2,000.&lt;/p&gt;

&lt;p&gt;6 . List the session dates and id for those sessions scheduled between 10/18/2021 and 10/21/2021.&lt;/p&gt;

&lt;p&gt;7 . List the full name of the therapist scheduled to work on 10/21/2021.&lt;/p&gt;

&lt;p&gt;8 . How long are the therapy sessions for the therapist whose last name is Smith? List the length of each session.&lt;/p&gt;

&lt;p&gt;9 . Which therapies have the word “movement” in their description? List the therapy description only.&lt;/p&gt;

&lt;p&gt;10 . How many therapies are offered? Answer with one number only.&lt;/p&gt;

&lt;p&gt;11 . Display the therapies and their unit of time for the therapies that include the word speech, move, or pat.&lt;/p&gt;

&lt;p&gt;12 . Display every therapist’s first name and last name as their full name, but only for those instructors not living in zip code 90001.&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 Week 3 Class 2 Activity 1 Resources</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Wed, 15 Mar 2023 15:38:30 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-week-3-class-2-activity-1-resources-273e</link>
      <guid>https://tyrocity.com/database/data-210-week-3-class-2-activity-1-resources-273e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Activity 1: Learn about JOINS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creating &lt;code&gt;employees&lt;/code&gt; table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE employees (
  employee_id INT PRIMARY KEY,
  first_name VARCHAR(50),
  last_name VARCHAR(50),
  department_id INT,
  salary DECIMAL(10,2)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert data for &lt;code&gt;employees&lt;/code&gt; table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO employees (employee_id, first_name, last_name, department_id, salary) VALUES
  (1, 'John', 'Doe', 1, 50000.00),
  (2, 'Jane', 'Smith', 2, 60000.00),
  (3, 'Bob', 'Johnson', 1, 55000.00),
  (4, 'Sarah', 'Lee', 3, 65000.00),
  (5, 'Mike', 'Brown', 2, 70000.00),
  (6, 'Karen', 'Davis', 3, 75000.00),
  (7, 'Happy', 'Says', 4, 80000.00);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating &lt;code&gt;departments&lt;/code&gt; table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE departments (
  department_id INT PRIMARY KEY,
  department_name VARCHAR(50)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert data for &lt;code&gt;departments&lt;/code&gt; table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO departments (department_id, department_name) VALUES
  (1, 'Sales'),
  (2, 'Marketing'),
  (3, 'Engineering'),
  (5, 'Whatever');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Question implementing INNER JOIN
&lt;/h4&gt;

&lt;p&gt;What is the name of each employee and their corresponding department?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT employees.first_name, employees.last_name, departments.department_name
FROM employees
INNER JOIN departments ON employees.department_id = departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Question implementing LEFT OUTER JOIN
&lt;/h4&gt;

&lt;p&gt;What is the name of each employee and their corresponding department, even if the department has no employees?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT employees.first_name, employees.last_name, departments.department_name
FROM employees
LEFT OUTER JOIN departments ON employees.department_id = departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Question implementing RIGHT OUTER JOIN
&lt;/h4&gt;

&lt;p&gt;What is the name of each employee and their corresponding department, even if the employee has no department assigned?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT employees.first_name, employees.last_name, departments.department_name
FROM employees
RIGHT OUTER JOIN departments ON employees.department_id = departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 Week 3 Class 1 Resources</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Mon, 13 Mar 2023 14:56:50 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-week-3-class-1-resources-34cd</link>
      <guid>https://tyrocity.com/database/data-210-week-3-class-1-resources-34cd</guid>
      <description>&lt;p&gt;&lt;strong&gt;Activity 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create the table as below (start with table headers and then values) :&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;StudentID&lt;/td&gt;
&lt;td&gt;FirstName&lt;/td&gt;
&lt;td&gt;LastName&lt;/td&gt;
&lt;td&gt;Gender&lt;/td&gt;
&lt;td&gt;Age&lt;/td&gt;
&lt;td&gt;City&lt;/td&gt;
&lt;td&gt;State&lt;/td&gt;
&lt;td&gt;Country&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;John&lt;/td&gt;
&lt;td&gt;Doe&lt;/td&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;New York&lt;/td&gt;
&lt;td&gt;NY&lt;/td&gt;
&lt;td&gt;USA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Jane&lt;/td&gt;
&lt;td&gt;Doe&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;Los Angeles&lt;/td&gt;
&lt;td&gt;CA&lt;/td&gt;
&lt;td&gt;USA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;Smith&lt;/td&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;27&lt;/td&gt;
&lt;td&gt;Chicago&lt;/td&gt;
&lt;td&gt;IL&lt;/td&gt;
&lt;td&gt;USA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;Johnson&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;21&lt;/td&gt;
&lt;td&gt;Houston&lt;/td&gt;
&lt;td&gt;TX&lt;/td&gt;
&lt;td&gt;USA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Tom&lt;/td&gt;
&lt;td&gt;Jones&lt;/td&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;24&lt;/td&gt;
&lt;td&gt;London&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;UK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Linda&lt;/td&gt;
&lt;td&gt;Smith&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;23&lt;/td&gt;
&lt;td&gt;Paris&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;France&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Need help? Follow the code as below to create a table:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Students (
  StudentID INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50),
  Gender CHAR(1),
  Age INT,
  City VARCHAR(50),
  State VARCHAR(50),
  Country VARCHAR(50)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, insert values in the table with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Students VALUES
  (1, 'John', 'Doe', 'M', 25, 'New York', 'NY', 'USA'),
  (2, 'Jane', 'Doe', 'F', 22, 'Los Angeles', 'CA', 'USA'),
  (3, 'Bob', 'Smith', 'M', 27, 'Chicago', 'IL', 'USA'),
  (4, 'Alice', 'Johnson', 'F', 21, 'Houston', 'TX', 'USA'),
  (5, 'Tom', 'Jones', 'M', 24, 'London', NULL, 'UK'),
  (6, 'Linda', 'Smith', 'F', 23, 'Paris', NULL, 'France');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, answer the following questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select all students from the USA.&lt;/li&gt;
&lt;li&gt;Select all students from the USA who are over 25 years old.&lt;/li&gt;
&lt;li&gt;Select all students who are either from New York or Los Angeles.&lt;/li&gt;
&lt;li&gt;Select all students who are not from the USA.&lt;/li&gt;
&lt;li&gt;Select all students who are not from the USA and are over 25 years old.&lt;/li&gt;
&lt;li&gt;Select all students from the USA.&lt;/li&gt;
&lt;li&gt;Select all students from the USA who are over 25 years old.&lt;/li&gt;
&lt;li&gt;Select all students who are either from New York or Los Angeles.&lt;/li&gt;
&lt;li&gt;Select all students who are not from the USA.&lt;/li&gt;
&lt;li&gt;Select all students who are not from the USA and are over 25 years old.&lt;/li&gt;
&lt;li&gt;Select all students and include a computed field called 'FullName' which is the concatenation of first and last name. &lt;/li&gt;
&lt;li&gt;Select all students and include a computed field called 'GenderAndAge' which is a concatenation of gender and age, separated by a dash.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Solutions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- 1. Select all students from the USA.
SELECT * FROM Students WHERE Country = 'USA';

-- 2. Select all students from the USA who are over 25 years old.
SELECT * FROM Students WHERE Country = 'USA' AND Age &amp;gt; 25;

-- 3. Select all students who are either from New York or Los Angeles.
SELECT * FROM Students WHERE City = 'New York' OR City = 'Los Angeles';

-- 4. Select all students who are not from the USA.
SELECT * FROM Students WHERE Country &amp;lt;&amp;gt; 'USA';

-- 5. Select all students who are not from the USA and are over 25 years old.
SELECT * FROM Students WHERE Country &amp;lt;&amp;gt; 'USA' AND Age &amp;gt; 25;

-- 6. Select all students whose age is between 22 and 25 inclusive.
SELECT * FROM Students WHERE Age BETWEEN 22 AND 25;

-- 7. Select all students whose last name starts with 'S'.
SELECT * FROM Students WHERE LastName LIKE 'S%';

-- 8. Select all students whose first name is 'Bob' or 'Tom' or 'Linda'.
SELECT * FROM Students WHERE FirstName IN ('Bob', 'Tom', 'Linda');

-- 9. Select all students and include a computed field called 'FullName' which is the concatenation of first and last name.
SELECT *, CONCAT(FirstName, ' ', LastName) AS FullName FROM Students;

-- 10. Select all students and include a computed field called 'GenderAndAge' which is a concatenation of gender and age, separated by a dash.
SELECT *, CONCAT(Gender, '-', Age) AS GenderAndAge FROM Students;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Activity 2&lt;/strong&gt;&lt;br&gt;
Create a table called Employees with columns for employee ID, name, job title, department ID, and salary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Employees (
  EmployeeID INT PRIMARY KEY,
  Name VARCHAR(50),
  JobTitle VARCHAR(50),
  DepartmentID INT,
  Salary INT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert some sample data into the Employees table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Employees VALUES
  (1, 'John Smith', 'Manager', 1, 80000),
  (2, 'Jane Doe', 'Sales Representative', 2, 60000),
  (3, 'Bob Johnson', 'Software Developer', 3, 70000),
  (4, 'Alice Brown', 'Sales Manager', 2, 90000),
  (5, 'Tom Jones', 'Software Architect', 3, 100000),
  (6, 'Linda Davis', 'HR Specialist', 4, 50000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, work to answer the following questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select all employees from department 3.&lt;/li&gt;
&lt;li&gt;Select all employees who make more than $70,000 per year.&lt;/li&gt;
&lt;li&gt;Select all employees whose job title contains the word 'Manager'.&lt;/li&gt;
&lt;li&gt;Select all employees who work in departments other than department 2.&lt;/li&gt;
&lt;li&gt;Select all employees who work in departments other than department 2 and make more than $70,000 per year.&lt;/li&gt;
&lt;li&gt;Select all employees whose salary is between $60,000 and $80,000 inclusive.&lt;/li&gt;
&lt;li&gt;Select all employees whose name starts with 'J'.&lt;/li&gt;
&lt;li&gt;Select all employees whose job title is 'Manager' or 'Sales Representative'.&lt;/li&gt;
&lt;li&gt;Select all employees and include a computed field called 'FullName' which is the concatenation of first and last name.&lt;/li&gt;
&lt;li&gt;Select all employees and include a computed field called 'DepartmentAndJobTitle' which is a concatenation of department and job title, separated by a comma.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Activity 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create table as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Employees (
  EmployeeID INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50),
  Email VARCHAR(50),
  Phone VARCHAR(20),
  Address VARCHAR(100),
  HireDate DATE,
  Salary INT,
  Department VARCHAR(50)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert the following values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO Employees VALUES
  (1, 'John', 'Doe', 'john.doe@company.com', '555-1234', '123 Main St, Anytown USA', '2020-01-01', 50000, 'Sales'),
  (2, 'Jane', 'Smith', 'jane.smith@company.com', '555-5678', '456 Oak St, Anytown USA', '2019-05-15', 60000, 'Marketing'),
  (3, 'Bob', 'Johnson', 'bob.johnson@company.com', '555-4321', '789 Pine St, Anytown USA', '2018-09-01', 70000, 'Finance'),
  (4, 'Alice', 'Williams', 'alice.williams@company.com', '555-8765', '321 Maple St, Anytown USA', '2021-03-01', 55000, 'Sales'),
  (5, 'Tom', 'Jones', 'tom.jones@company.com', '555-2468', '654 Elm St, Anytown USA', '2017-01-01', 75000, 'Finance'),
  (6, 'Linda', 'Davis', 'linda.davis@company.com', '555-3698', '987 Cedar St, Anytown USA', '2022-01-01', 80000, 'Marketing');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, work to answer the following questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select all employees in the Sales department.&lt;/li&gt;
&lt;li&gt;Select all employees in the Finance department with a salary greater than $60,000.&lt;/li&gt;
&lt;li&gt;Select all employees whose last name starts with 'D'.&lt;/li&gt;
&lt;li&gt;Select all employees hired after January 1st, 2020.&lt;/li&gt;
&lt;li&gt;Select all employees whose first name is either 'John' or 'Jane'.&lt;/li&gt;
&lt;li&gt;Select all employees whose salary is between $50,000 and $70,000.&lt;/li&gt;
&lt;li&gt;Select all employees whose email address contains 'company.com'.&lt;/li&gt;
&lt;li&gt;Select all employees and include a computed field called 'FullName' which is the concatenation of first and last name.&lt;/li&gt;
&lt;li&gt;Select all employees and include a computed field called 'SalaryPerMonth' which is the employee's annual salary divided by 12.&lt;/li&gt;
&lt;li&gt;Select all employees and include a computed field called 'YearsOfService' which is the number of years the employee has been with the company.&lt;/li&gt;
&lt;/ol&gt;




</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 WK1 Assignment Resources</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Thu, 09 Mar 2023 02:38:11 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-wk1-assignment-resources-k7j</link>
      <guid>https://tyrocity.com/database/data-210-wk1-assignment-resources-k7j</guid>
      <description>&lt;p&gt;Attached would be the Excel file that you can make use of to analyze further or to import the details in other DBMS system to extract the answer for the questions as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://generationunlimited.tyrocity.com/resources/WK1_DQ_Table.xlsx"&gt;Download File&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table 1: Employees&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/GCLcdePZLY6ARcXB1H28V235AxRmZrX39Pcy3dbnTrk/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9waXoxd2Z2MDZ5/NGhrMTVtemZ5cC5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/GCLcdePZLY6ARcXB1H28V235AxRmZrX39Pcy3dbnTrk/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9waXoxd2Z2MDZ5/NGhrMTVtemZ5cC5w/bmc" alt="Employees table" width="880" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table 2: Clients&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/WbWTn4omegH-h0XsrMBn_pTz4Bel1eSAv7YzbAud3CA/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy80cm1jbG1zc2ti/NWNudzl5czlocy5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/WbWTn4omegH-h0XsrMBn_pTz4Bel1eSAv7YzbAud3CA/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy80cm1jbG1zc2ti/NWNudzl5czlocy5w/bmc" alt="Clients table" width="880" height="711"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table 3: Projects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/NfV3bN23nWrAm9BbjhhtiKYnSfttiV4TMjfRDhcEE5U/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9vNXZ6OWVyNnhn/d2EzMnM4dGtoZi5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/NfV3bN23nWrAm9BbjhhtiKYnSfttiV4TMjfRDhcEE5U/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9vNXZ6OWVyNnhn/d2EzMnM4dGtoZi5w/bmc" alt="Projects table" width="880" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table 4: ProjectLineItems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/_W4RVzBjEQcHuOJMZJacmKYOkU6kNUrfmpze42EhfUE/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy82dWZrNGg1Nmpu/ZzdodmxtaWQ1cy5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/_W4RVzBjEQcHuOJMZJacmKYOkU6kNUrfmpze42EhfUE/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy82dWZrNGg1Nmpu/ZzdodmxtaWQ1cy5w/bmc" alt="ProjectLineItems table" width="880" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table 5: TaskMasterList&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/SPI97rQaPJ6YyjJRMTayrblyP0MIO31B20BbZR-yR_U/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9xcW8xYTVhdWVi/enFlanB4emx1di5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/SPI97rQaPJ6YyjJRMTayrblyP0MIO31B20BbZR-yR_U/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9xcW8xYTVhdWVi/enFlanB4emx1di5w/bmc" alt="TaskMasterList table" width="866" height="802"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examine the JC Consulting data and complete the following case exercises/problems:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Which employee(s) has a salary value of $8,100?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which client&lt;/strong&gt;(s) is or are &lt;strong&gt;not a government entity&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;Which project(s) had an estimated start date prior to 1/1/2020?&lt;/li&gt;
&lt;li&gt;List ProjectLineItemID values that are related to ProjectID 3.&lt;/li&gt;
&lt;li&gt;List the name of the client related to Project ID 3.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which task&lt;/strong&gt;(s) is or are &lt;strong&gt;not priced&lt;/strong&gt; by the project?&lt;/li&gt;
&lt;li&gt;For the record with a ProjectLineID value of 7, why does the Quantity field contain 20?&lt;/li&gt;
&lt;li&gt;For the record with a ProjectLineID value of 7, why does the Factor field contain 1.3?&lt;/li&gt;
&lt;li&gt;What is the cost for an initial meeting with a client, TaskID MEET00?&lt;/li&gt;
&lt;li&gt;What is the cost for creating a shopping card, TaskID CODE15?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Apply key module concepts to the JC Consulting case:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JCC needs to be able to contact clients when problems arise concerning an estimate.
What other attributes could JCC include in the Clients table to assist in contacting
clients?&lt;/li&gt;
&lt;li&gt;JCC wants the database to include data on all its employees, not just those who may be
involved in projects. What additional entities would the DBA need to include in the
database to store this data? What attributes?&lt;/li&gt;
&lt;li&gt;What kinds of unstructured data or big data might JCC want to gather in the future?&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Guiding points&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q2 asks for&lt;/strong&gt;&lt;br&gt;
Which client(s) "is or are" not a government entity?&lt;/p&gt;

&lt;p&gt;This is asking you to list the client(s) which aren't government entity. Listing ones that are is incorrect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q3 mentions&lt;/strong&gt;&lt;br&gt;
start date prior to 1/1/2020&lt;/p&gt;

&lt;p&gt;This refers to date before and not after.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q4 asks for&lt;/strong&gt;&lt;br&gt;
ProjectLineItemID values&lt;/p&gt;

&lt;p&gt;This refers to you requiring to list the values that are present under "ProjectLineItemID" for project's with "ProjectID" 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q6 mentions&lt;/strong&gt;&lt;br&gt;
Which task(s) "is or are" not priced by the project&lt;/p&gt;

&lt;p&gt;Like for Q2 or point 1 here. List ones that are not priced by project - all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q7 asks for&lt;/strong&gt; "why does the Quantity field contain 20" - this does require you to look on book for definition/answer. The section just below Figure 1-5 -&amp;gt; 3rd last paragraph on that page. Frame your answer based on your understanding there - it is not to be copied.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tyrocity.com/images/_fHjYd1ENOHgzPE9uxBDdWrLrQIunRmxCqKQlcwCr1k/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9yeWE3NGNibGk4/dmVnamhybnR2My5w/bmc" class="article-body-image-wrapper"&gt;&lt;img src="https://tyrocity.com/images/_fHjYd1ENOHgzPE9uxBDdWrLrQIunRmxCqKQlcwCr1k/w:880/mb:500000/ar:1/aHR0cHM6Ly90eXJv/Y2l0eS5jb20vdXBs/b2Fkcy9hcnRpY2xl/cy9yeWE3NGNibGk4/dmVnamhybnR2My5w/bmc" alt="Decoding Q7 answer" width="880" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q8 asks for&lt;/strong&gt; "why does the Factor field contain 1.3" - this does require you to look the book for definition/answer. It is the next 2 line after Q7 answer itself. Frame your answer based on your understanding there - it is not to be copied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q10&lt;/strong&gt; - do not forget to mention the unit.&lt;/p&gt;




&lt;p&gt;For "&lt;strong&gt;Apply key module concepts to the JC Consulting case&lt;/strong&gt;" section of questions - give it a new title.&lt;/p&gt;

&lt;p&gt;And, then Question number followed by answer to it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Q1/Q2&lt;/strong&gt; - you just need to list the attributes name to be added.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Q3&lt;/strong&gt; - asks for unstructured data so no specific attribute name required but the category, types of data to be collected like about client feedback and satisfaction for one. You will need to list few and then also explain in a sentence or two of what that will include/cover.&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
    <item>
      <title>DATA 210 WK2 Assignment Resources</title>
      <dc:creator>Angel Paudel</dc:creator>
      <pubDate>Thu, 09 Mar 2023 02:37:47 +0000</pubDate>
      <link>https://tyrocity.com/database/data-210-wk2-assignment-resources-1laf</link>
      <guid>https://tyrocity.com/database/data-210-wk2-assignment-resources-1laf</guid>
      <description>&lt;p&gt;Attached would be the Excel file that you can make use of to analyze further or to import the details in other DBMS system to extract the answer for the questions as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://generationunlimited.tyrocity.com/resources/WK2_DQ_Table.xlsx"&gt;Download File&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The owner of Pitt Fitness knows that the power of the company’s database is in running queries to find out important information for making good business decisions. In the following exercises, use the data in the Pitt Fitness database shown in Figures 1-15, 1-16, 1-17, 1-18, and 1-19 in Module 1. When you use Microsoft Access to respond to these exercises, make a copy of the original database to create the queries. In each step, use QBE to obtain the desired results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examine the Pitt Fitness data and complete the following case exercises/problems:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Which customer lives on Negley Avenue?&lt;/li&gt;
&lt;li&gt;How many customers were born from 2001 onward?&lt;/li&gt;
&lt;li&gt;Which instructors live in zip code 15217?&lt;/li&gt;
&lt;li&gt;Which classes (by name) have the highest number of reservations?&lt;/li&gt;
&lt;li&gt;How many customers have registered for a class on Wednesdays?&lt;/li&gt;
&lt;li&gt;What are the three most popular class names on Saturday?&lt;/li&gt;
&lt;li&gt;How many classes did Pablo Brough sign up for?&lt;/li&gt;
&lt;li&gt;How many customers have signed up for a class on January 8, 2021?&lt;/li&gt;
&lt;li&gt;Which customers prefer the 45-minute class length?&lt;/li&gt;
&lt;li&gt;Which instructor teaches the most classes?&lt;/li&gt;
&lt;li&gt;Which instructor teaches Zumba?&lt;/li&gt;
&lt;li&gt;Of all reservations for classes containing the word Cycle, which customer does not owe
another fee besides the class price? (Note: This field is called “OtherFees.”) Create a
calculated field to total both costs.&lt;/li&gt;
&lt;li&gt;According to the reservations so far, how much money will the Combination classes
generate?&lt;/li&gt;
&lt;li&gt;Instructor Michael Nguyen is injured and has to cancel his class on Wednesday. Delete
that record. How many classes does he have left to teach?&lt;/li&gt;
&lt;li&gt;Which instructor will customer Margo Patterson get for her HIIT class?&lt;/li&gt;
&lt;li&gt;How many classes are offered on Tuesday at 6 am and last 45 minutes?&lt;/li&gt;
&lt;li&gt;Which day of the week has the most classes?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Apply key module concepts to the Pitt Fitness case:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Suppose you want to list information on all the classes that Pitt Fitness offers, including the day of the week, time, location, and length of class. To do this, you could create a query. What table(s) should you add to the query? If you use the Classes table instead of all the tables together, does it make a difference to the output? What if someone had never reserved a specific class?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The owner of Pitt Fitness is considering whether to consolidate his clubs and offer classes in only one location to ensure profitability. To explore his question, what query or queries would you create to answer this business strategy question? In the following exercises, you use data in the Sports Physical Therapy database shown in Figures 1-21 through 1-24 in Module 1. When you use Microsoft Access to answer these questions, make a copy of the original database to create the queries to answer these questions. In each step, use QBE to obtain the desired results.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;HINTS (ignore &amp;amp; or and used anywhere - this is also just a hint and not the only way you can solve it):&lt;/p&gt;

&lt;p&gt;Q1: Use LIKE &amp;amp; *&lt;br&gt;
Q2: Use &amp;gt;= and COUNT (optional)&lt;br&gt;
Q3: =&lt;br&gt;
Q4: GROUP BY &amp;amp; COUNT&lt;br&gt;
Q5: Use LIKE &amp;amp; *&lt;br&gt;
Q6: GROUP BY, COUNT, WHERE (where "WHERE" is used make sure "Show" field is unchecked i.e. not ticked) and shorting: descending &lt;br&gt;
Q7: AND (just refers to criteria check in 2 locations)&lt;br&gt;
Q8: =, GROUP BY &amp;amp; COUNT&lt;br&gt;
Q9: =&lt;br&gt;
Q10: GROUP BY &amp;amp; COUNT&lt;br&gt;
Q11: GROUP BY &amp;amp; WHERE&lt;/p&gt;

&lt;p&gt;More hints:&lt;br&gt;
Q12: Like &lt;code&gt;"*Cycle*"&lt;/code&gt;; For OtherFees - you can update Reservations table if you like to make it all 0 and then use "=0" for condition or as is you can check if the field contains null value; here, you will also need to create a calculate field. This is how you can do it:&lt;br&gt;
TotalCost: [Field1]+[Field2]&lt;/p&gt;

&lt;p&gt;It is to be added under a new field. "TotalCost" can read anything which you want that field to be called as. While the other elements in the [...] are the field names which you want to add. Update it as is required.&lt;/p&gt;

</description>
      <category>bsit</category>
    </item>
  </channel>
</rss>
