Initial Commit

This commit is contained in:
2022-10-07 00:48:09 -03:00
commit 5f5056d65a
186 changed files with 2500 additions and 0 deletions

View File

@ -0,0 +1,230 @@
Script started on Thu 14 Jan 2021 05:26:15 PM AST
]0;ishoebot@id414m12:~[ishoebot@id414m12 ~]$ mysql -h cs1103.cs.unb.ca -u <enter username> -pname> -p -p -p -p -p -p -p -p -p -p-p -p -p -p -p -p -pi -ps -ph -po -pe -pb -po -pt -p
Enter password:
(BWelcome to the MariaDB monitor. Commands end with ; or \g.
(B(BYour MariaDB connection id is 12752
Server version: 5.5.65-MariaDB MariaDB Server
(B(BCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
(B(BType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(B[?1034hMariaDB [(none)]> show tadatabases
-> ;
+----------------------+
| Database |
+----------------------+
| information_schema |
| Ch01_Problems |
| Ch01_Text |
| Ch02_DealCo |
| Ch02_InsureCo |
| Ch02_SaleCo |
| Ch02_TinyCollege |
| Ch03_AviaCo |
| Ch03_BeneCo |
| Ch03_CheapCo |
| Ch03_CollegeQue |
| Ch03_CollegeTry |
| Ch03_CollegeTry2 |
| Ch03_InsureCo |
| Ch03_Museum |
| Ch03_NoComp |
| Ch03_Relational_DB |
| Ch03_SaleCo |
| Ch03_StoreCo |
| Ch03_Theatre |
| Ch03_TinyCollege |
| Ch03_TransCo |
| Ch03_VendingCo |
| Ch04_Clinic |
| Ch04_CollegeTry |
| Ch04_PartCo |
| Ch04_ShortCo |
| Ch04_TinyCollege |
| Ch04_TinyCollege_Alt |
| Ch07_ConstructCo |
| Ch07_Fact |
| Ch07_LargeCo |
| Ch07_SaleCo |
| ishoebot |
+----------------------+
(B34 rows in set (0.00 sec)
(B(B
(BMariaDB [(none)]> suse Ch01_Text
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
(BDatabase changed
(BMariaDB [Ch01_Text]> show columns from show tables;
+---------------------+
| Tables_in_Ch01_Text |
+---------------------+
| AGENT |
| CERTIFIED |
| CUSTOMER |
| EMPLOYEE |
| EMPLOYEESKILLS |
| SKILL |
+---------------------+
(B6 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columnds fromlomumumns from AGENT
-> ;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| A_NAME | varchar(15) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| A_ADDRESS | varchar(20) | YES | | NULL | |
| ZIP | varchar(5) | YES | | NULL | |
| HIRED | datetime | YES | | NULL | |
| YTD_PAY | decimal(10,2) | YES | | NULL | |
| YTD_FIT | decimal(10,2) | YES | | NULL | |
| YTD_FICA | decimal(10,2) | YES | | NULL | |
| YTD_SLS | decimal(10,2) | YES | | NULL | |
| DEP | int(11) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select * from AGENT
-> ;
+--------------+--------------+--------------------+-------+---------------------+----------+---------+----------+-----------+------+
| A_NAME | A_PHONE | A_ADDRESS | ZIP | HIRED | YTD_PAY | YTD_FIT | YTD_FICA | YTD_SLS | DEP |
+--------------+--------------+--------------------+-------+---------------------+----------+---------+----------+-----------+------+
| Alex B. Alby | 713-228-1249 | 123 Toll, Nash, TN | 37119 | 2002-11-01 00:00:00 | 26566.24 | 6641.56 | 2125.30 | 132735.75 | 3 |
| Leah F. Hahn | 615-882-1244 | 334 Main, Fox, KY | 25246 | 1988-05-23 00:00:00 | 32213.76 | 8053.44 | 2577.10 | 138967.35 | 0 |
| John T. Okon | 615-123-5589 | 452 Elm, New, TN | 36155 | 2007-06-15 00:00:00 | 23198.29 | 5799.57 | 1855.86 | 127093.45 | 2 |
+--------------+--------------+--------------------+-------+---------------------+----------+---------+----------+-----------+------+
(B3 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columnds from EMPLOYEE
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'columnds from EMPLOYEE' at line 1
(B(BMariaDB [Ch01_Text]> ;show columnds from EMPLOYEE
;show columnds from EMPLOYEE[1@s
-> ;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| EMPLOYEE_ID | varchar(6) | NO | PRI | NULL | |
| EMPLOYEE_FNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_LNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_HIREDATE | datetime | YES | | NULL | |
| EMPLOYEE_TITLE | varchar(30) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
(B5 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select * from EMPLOYEE
-> ;
+-------------+----------------+----------------+---------------------+---------------------+
| EMPLOYEE_ID | EMPLOYEE_FNAME | EMPLOYEE_LNAME | EMPLOYEE_HIREDATE | EMPLOYEE_TITLE |
+-------------+----------------+----------------+---------------------+---------------------+
| 02345 | Johnny | Jones | 1997-02-14 00:00:00 | DBA |
| 03373 | Franklin | Johnson | 2004-03-15 00:00:00 | Purchasing Agent |
| 04893 | Patricia | Richards | 2006-06-11 00:00:00 | DBA |
| 06234 | Jasmine | Patel | 2007-08-10 00:00:00 | Programmer |
| 08273 | Marco | Bienz | 2008-07-28 00:00:00 | Analyst |
| 09002 | Ben | Joiner | 2012-05-20 00:00:00 | Clerk |
| 09283 | Juan | Chavez | 2012-07-04 00:00:00 | Clerk |
| 09382 | Jessica | Johnson | 2012-08-02 00:00:00 | Database Programmer |
| 10282 | Amanda | Richardson | 2013-04-11 00:00:00 | Clerk |
| 13383 | Raymond | Matthews | 2014-03-12 00:00:00 | Programmer |
| 13567 | Robert | Almond | 2014-09-30 00:00:00 | Analyst |
| 13932 | Megan | Lee | 2015-09-29 00:00:00 | Programmer |
| 14311 | Lee | Duong | 2014-09-01 00:00:00 | Programmer |
+-------------+----------------+----------------+---------------------+---------------------+
(B13 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select EMPLOYEE_ID , EMPLOYEE_TITLE from EMPLOYEE
-> ;
+-------------+---------------------+
| EMPLOYEE_ID | EMPLOYEE_TITLE |
+-------------+---------------------+
| 02345 | DBA |
| 03373 | Purchasing Agent |
| 04893 | DBA |
| 06234 | Programmer |
| 08273 | Analyst |
| 09002 | Clerk |
| 09283 | Clerk |
| 09382 | Database Programmer |
| 10282 | Clerk |
| 13383 | Programmer |
| 13567 | Analyst |
| 13932 | Programmer |
| 14311 | Programmer |
+-------------+---------------------+
(B13 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show colhow columns from EMPLOYEE
-> ;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| EMPLOYEE_ID | varchar(6) | NO | PRI | NULL | |
| EMPLOYEE_FNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_LNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_HIREDATE | datetime | YES | | NULL | |
| EMPLOYEE_TITLE | varchar(30) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
(B5 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> list cusCushow tables
-> ;
+---------------------+
| Tables_in_Ch01_Text |
+---------------------+
| AGENT |
| CERTIFIED |
| CUSTOMER |
| EMPLOYEE |
| EMPLOYEESKILLS |
| SKILL |
+---------------------+
(B6 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columnds from CUSTOMER
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'columnds from CUSTOMER' at line 1
(B(BMariaDB [Ch01_Text]> ;show columnds from CUSTOMER[1@s
-> ;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| C_NAME | varchar(20) | YES | | NULL | |
| C_PHONE | varchar(12) | YES | | NULL | |
| C_ADDRESS | varchar(30) | YES | | NULL | |
| C_ZIP | varchar(5) | YES | | NULL | |
| A_NAME | varchar(20) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| TP | varchar(2) | YES | | NULL | |
| AMT | decimal(6,2) | YES | | NULL | |
| REN | datetime | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
(B9 rows in set (0.01 sec)
(B(B
(BMariaDB [Ch01_Text]> list C_NAME , C_PADDRESS , C_PHONE from CUSTOMER;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'list C_NAME, C_ADDRESS, C_PHONE from CUSTOMER' at line 1
(B(BMariaDB [Ch01_Text]> list C_NAME, C_ADDRESS, C_PHONE from CUSTOMER;[1@s[1@e[1@l[1@e[1@c[1@t
+-----------------+------------------------+--------------+
| C_NAME | C_ADDRESS | C_PHONE |
+-----------------+------------------------+--------------+
| Alfred A. Ramas | 218 Fork Rd., Babs, TN | 615-844-2573 |
| Leona K. Dunne | Box 12A, Fox, KY | 713-894-1238 |
| Kathy W. Smith | 125 Oak Ln, Babs, TN | 615-894-2285 |
| Paul F. Olowski | 217 Lee Ln., Babs, TN | 615-894-2180 |
| Myron Orlando | Box 111, New, TN | 615-222-1672 |
| Amy B. O'Brian | 387 Troll Dr., Fox, KY | 713-442-3381 |
| James G. Brown | 21 Tye Rd., Nash, TN | 615-297-1228 |
| George Williams | 155 Maple, Nash, TN | 615-290-2556 |
| Anne G. Farriss | 2119 Elm, Crew, KY | 713-382-7185 |
| Olette K. Smith | 2782 Main, Nash, TN | 615-297-3809 |
+-----------------+------------------------+--------------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> exit
(BBye
(B]0;ishoebot@id414m12:~[ishoebot@id414m12 ~]$ exit

Binary file not shown.

231
Labs/Lab1/transcript.txt Normal file
View File

@ -0,0 +1,231 @@
Script started on Thu 14 Jan 2021 05:08:01 PM AST
]0;ishoebot@id414m35:~[ishoebot@id414m35 ~]$ exitlsexitexitlsexitmysql -h cs1103.cs.unb.ca -u <enter username> -p -p -p -p -p -p -p -p -p -p-p -p -p -p -p -p -pi -ps -ph -po -pe -pb -po -pt -p
Enter password:
(BWelcome to the MariaDB monitor. Commands end with ; or \g.
(B(BYour MariaDB connection id is 12655
Server version: 5.5.65-MariaDB MariaDB Server
(B(BCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
(B(BType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(B[?1034hMariaDB [(none)]> 5show show databaxses
-> ;
+----------------------+
| Database |
+----------------------+
| information_schema |
| Ch01_Problems |
| Ch01_Text |
| Ch02_DealCo |
| Ch02_InsureCo |
| Ch02_SaleCo |
| Ch02_TinyCollege |
| Ch03_AviaCo |
| Ch03_BeneCo |
| Ch03_CheapCo |
| Ch03_CollegeQue |
| Ch03_CollegeTry |
| Ch03_CollegeTry2 |
| Ch03_InsureCo |
| Ch03_Museum |
| Ch03_NoComp |
| Ch03_Relational_DB |
| Ch03_SaleCo |
| Ch03_StoreCo |
| Ch03_Theatre |
| Ch03_TinyCollege |
| Ch03_TransCo |
| Ch03_VendingCo |
| Ch04_Clinic |
| Ch04_CollegeTry |
| Ch04_PartCo |
| Ch04_ShortCo |
| Ch04_TinyCollege |
| Ch04_TinyCollege_Alt |
| Ch07_ConstructCo |
| Ch07_Fact |
| Ch07_LargeCo |
| Ch07_SaleCo |
| ishoebot |
+----------------------+
(B34 rows in set (0.01 sec)
(B(B
(BMariaDB [(none)]> use Ch01_Text
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
(BDatabase changed
(BMariaDB [Ch01_Text]> show tables;
+---------------------+
| Tables_in_Ch01_Text |
+---------------------+
| AGENT |
| CERTIFIED |
| CUSTOMER |
| EMPLOYEE |
| EMPLOYEESKILLS |
| SKILL |
+---------------------+
(B6 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columns from AGENT
-> ;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| A_NAME | varchar(15) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| A_ADDRESS | varchar(20) | YES | | NULL | |
| ZIP | varchar(5) | YES | | NULL | |
| HIRED | datetime | YES | | NULL | |
| YTD_PAY | decimal(10,2) | YES | | NULL | |
| YTD_FIT | decimal(10,2) | YES | | NULL | |
| YTD_FICA | decimal(10,2) | YES | | NULL | |
| YTD_SLS | decimal(10,2) | YES | | NULL | |
| DEP | int(11) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> ;show columns from AGENTEMPLOYEE
-> ;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| EMPLOYEE_ID | varchar(6) | NO | PRI | NULL | |
| EMPLOYEE_FNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_LNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_HIREDATE | datetime | YES | | NULL | |
| EMPLOYEE_TITLE | varchar(30) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
(B5 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select EMPLOYEE_ID , EMPLOYEE_TiITLE from EMPLOYEE
-> ;.
+-------------+---------------------+
| EMPLOYEE_ID | EMPLOYEE_TITLE |
+-------------+---------------------+
| 02345 | DBA |
| 03373 | Purchasing Agent |
| 04893 | DBA |
| 06234 | Programmer |
| 08273 | Analyst |
| 09002 | Clerk |
| 09283 | Clerk |
| 09382 | Database Programmer |
| 10282 | Clerk |
| 13383 | Programmer |
| 13567 | Analyst |
| 13932 | Programmer |
| 14311 | Programmer |
+-------------+---------------------+
(B13 rows in set (0.00 sec)
(B(B
(B -> ;.
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.' at line 1
(B(BMariaDB [Ch01_Text]> ;.select EMPLOYEE_ID, EMPLOYEE_TITLE from EMPLOYEE;
+-------------+---------------------+
| EMPLOYEE_ID | EMPLOYEE_TITLE |
+-------------+---------------------+
| 02345 | DBA |
| 03373 | Purchasing Agent |
| 04893 | DBA |
| 06234 | Programmer |
| 08273 | Analyst |
| 09002 | Clerk |
| 09283 | Clerk |
| 09382 | Database Programmer |
| 10282 | Clerk |
| 13383 | Programmer |
| 13567 | Analyst |
| 13932 | Programmer |
| 14311 | Programmer |
+-------------+---------------------+
(B13 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columns from AGENT
-> ;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| A_NAME | varchar(15) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| A_ADDRESS | varchar(20) | YES | | NULL | |
| ZIP | varchar(5) | YES | | NULL | |
| HIRED | datetime | YES | | NULL | |
| YTD_PAY | decimal(10,2) | YES | | NULL | |
| YTD_FIT | decimal(10,2) | YES | | NULL | |
| YTD_FICA | decimal(10,2) | YES | | NULL | |
| YTD_SLS | decimal(10,2) | YES | | NULL | |
| DEP | int(11) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> Sselect A_NAME , A-_PAdDDRESS , A_ePhHONE from AG
AGAINST AGENT AGENT.A_ADDRESS AGENT.A_NAME AGENT.A_PHONE AGENT.DEP AGENT.HIRED AGENT.YTD_FICA AGENT.YTD_FIT AGENT.YTD_PAY AGENT.YTD_SLS AGENT.ZIP AGGREGATE
MariaDB [Ch01_Text]> select A_NAME, A_ADDRESS, A_PHONE from AGENT
-> ;
+--------------+--------------------+--------------+
| A_NAME | A_ADDRESS | A_PHONE |
+--------------+--------------------+--------------+
| Alex B. Alby | 123 Toll, Nash, TN | 713-228-1249 |
| Leah F. Hahn | 334 Main, Fox, KY | 615-882-1244 |
| John T. Okon | 452 Elm, New, TN | 615-123-5589 |
+--------------+--------------------+--------------+
(B3 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show tables
-> ;
+---------------------+
| Tables_in_Ch01_Text |
+---------------------+
| AGENT |
| CERTIFIED |
| CUSTOMER |
| EMPLOYEE |
| EMPLOYEESKILLS |
| SKILL |
+---------------------+
(B6 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columns from CUSTOMER
-> ;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| C_NAME | varchar(20) | YES | | NULL | |
| C_PHONE | varchar(12) | YES | | NULL | |
| C_ADDRESS | varchar(30) | YES | | NULL | |
| C_ZIP | varchar(5) | YES | | NULL | |
| A_NAME | varchar(20) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| TP | varchar(2) | YES | | NULL | |
| AMT | decimal(6,2) | YES | | NULL | |
| REN | datetime | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
(B9 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select AC_NAME , C-_AdDDRESS , C_PohHONE from cusCUsSTOMER
-> ;
+-----------------+------------------------+--------------+
| C_NAME | C_ADDRESS | C_PHONE |
+-----------------+------------------------+--------------+
| Alfred A. Ramas | 218 Fork Rd., Babs, TN | 615-844-2573 |
| Leona K. Dunne | Box 12A, Fox, KY | 713-894-1238 |
| Kathy W. Smith | 125 Oak Ln, Babs, TN | 615-894-2285 |
| Paul F. Olowski | 217 Lee Ln., Babs, TN | 615-894-2180 |
| Myron Orlando | Box 111, New, TN | 615-222-1672 |
| Amy B. O'Brian | 387 Troll Dr., Fox, KY | 713-442-3381 |
| James G. Brown | 21 Tye Rd., Nash, TN | 615-297-1228 |
| George Williams | 155 Maple, Nash, TN | 615-290-2556 |
| Anne G. Farriss | 2119 Elm, Crew, KY | 713-382-7185 |
| Olette K. Smith | 2782 Main, Nash, TN | 615-297-3809 |
+-----------------+------------------------+--------------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> exit;
(BBye
(B]0;ishoebot@id414m35:~[ishoebot@id414m35 ~]$ exit
exit

230
Labs/Lab1/transcript_v2.txt Normal file
View File

@ -0,0 +1,230 @@
Script started on Thu 14 Jan 2021 05:26:15 PM AST
]0;ishoebot@id414m12:~[ishoebot@id414m12 ~]$ mysql -h cs1103.cs.unb.ca -u <enter username> -pname> -p -p -p -p -p -p -p -p -p -p-p -p -p -p -p -p -pi -ps -ph -po -pe -pb -po -pt -p
Enter password:
(BWelcome to the MariaDB monitor. Commands end with ; or \g.
(B(BYour MariaDB connection id is 12752
Server version: 5.5.65-MariaDB MariaDB Server
(B(BCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
(B(BType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(B[?1034hMariaDB [(none)]> show tadatabases
-> ;
+----------------------+
| Database |
+----------------------+
| information_schema |
| Ch01_Problems |
| Ch01_Text |
| Ch02_DealCo |
| Ch02_InsureCo |
| Ch02_SaleCo |
| Ch02_TinyCollege |
| Ch03_AviaCo |
| Ch03_BeneCo |
| Ch03_CheapCo |
| Ch03_CollegeQue |
| Ch03_CollegeTry |
| Ch03_CollegeTry2 |
| Ch03_InsureCo |
| Ch03_Museum |
| Ch03_NoComp |
| Ch03_Relational_DB |
| Ch03_SaleCo |
| Ch03_StoreCo |
| Ch03_Theatre |
| Ch03_TinyCollege |
| Ch03_TransCo |
| Ch03_VendingCo |
| Ch04_Clinic |
| Ch04_CollegeTry |
| Ch04_PartCo |
| Ch04_ShortCo |
| Ch04_TinyCollege |
| Ch04_TinyCollege_Alt |
| Ch07_ConstructCo |
| Ch07_Fact |
| Ch07_LargeCo |
| Ch07_SaleCo |
| ishoebot |
+----------------------+
(B34 rows in set (0.00 sec)
(B(B
(BMariaDB [(none)]> suse Ch01_Text
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
(BDatabase changed
(BMariaDB [Ch01_Text]> show columns from show tables;
+---------------------+
| Tables_in_Ch01_Text |
+---------------------+
| AGENT |
| CERTIFIED |
| CUSTOMER |
| EMPLOYEE |
| EMPLOYEESKILLS |
| SKILL |
+---------------------+
(B6 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columnds fromlomumumns from AGENT
-> ;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| A_NAME | varchar(15) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| A_ADDRESS | varchar(20) | YES | | NULL | |
| ZIP | varchar(5) | YES | | NULL | |
| HIRED | datetime | YES | | NULL | |
| YTD_PAY | decimal(10,2) | YES | | NULL | |
| YTD_FIT | decimal(10,2) | YES | | NULL | |
| YTD_FICA | decimal(10,2) | YES | | NULL | |
| YTD_SLS | decimal(10,2) | YES | | NULL | |
| DEP | int(11) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select * from AGENT
-> ;
+--------------+--------------+--------------------+-------+---------------------+----------+---------+----------+-----------+------+
| A_NAME | A_PHONE | A_ADDRESS | ZIP | HIRED | YTD_PAY | YTD_FIT | YTD_FICA | YTD_SLS | DEP |
+--------------+--------------+--------------------+-------+---------------------+----------+---------+----------+-----------+------+
| Alex B. Alby | 713-228-1249 | 123 Toll, Nash, TN | 37119 | 2002-11-01 00:00:00 | 26566.24 | 6641.56 | 2125.30 | 132735.75 | 3 |
| Leah F. Hahn | 615-882-1244 | 334 Main, Fox, KY | 25246 | 1988-05-23 00:00:00 | 32213.76 | 8053.44 | 2577.10 | 138967.35 | 0 |
| John T. Okon | 615-123-5589 | 452 Elm, New, TN | 36155 | 2007-06-15 00:00:00 | 23198.29 | 5799.57 | 1855.86 | 127093.45 | 2 |
+--------------+--------------+--------------------+-------+---------------------+----------+---------+----------+-----------+------+
(B3 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columnds from EMPLOYEE
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'columnds from EMPLOYEE' at line 1
(B(BMariaDB [Ch01_Text]> ;show columnds from EMPLOYEE
;show columnds from EMPLOYEE[1@s
-> ;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| EMPLOYEE_ID | varchar(6) | NO | PRI | NULL | |
| EMPLOYEE_FNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_LNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_HIREDATE | datetime | YES | | NULL | |
| EMPLOYEE_TITLE | varchar(30) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
(B5 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select * from EMPLOYEE
-> ;
+-------------+----------------+----------------+---------------------+---------------------+
| EMPLOYEE_ID | EMPLOYEE_FNAME | EMPLOYEE_LNAME | EMPLOYEE_HIREDATE | EMPLOYEE_TITLE |
+-------------+----------------+----------------+---------------------+---------------------+
| 02345 | Johnny | Jones | 1997-02-14 00:00:00 | DBA |
| 03373 | Franklin | Johnson | 2004-03-15 00:00:00 | Purchasing Agent |
| 04893 | Patricia | Richards | 2006-06-11 00:00:00 | DBA |
| 06234 | Jasmine | Patel | 2007-08-10 00:00:00 | Programmer |
| 08273 | Marco | Bienz | 2008-07-28 00:00:00 | Analyst |
| 09002 | Ben | Joiner | 2012-05-20 00:00:00 | Clerk |
| 09283 | Juan | Chavez | 2012-07-04 00:00:00 | Clerk |
| 09382 | Jessica | Johnson | 2012-08-02 00:00:00 | Database Programmer |
| 10282 | Amanda | Richardson | 2013-04-11 00:00:00 | Clerk |
| 13383 | Raymond | Matthews | 2014-03-12 00:00:00 | Programmer |
| 13567 | Robert | Almond | 2014-09-30 00:00:00 | Analyst |
| 13932 | Megan | Lee | 2015-09-29 00:00:00 | Programmer |
| 14311 | Lee | Duong | 2014-09-01 00:00:00 | Programmer |
+-------------+----------------+----------------+---------------------+---------------------+
(B13 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> select EMPLOYEE_ID , EMPLOYEE_TITLE from EMPLOYEE
-> ;
+-------------+---------------------+
| EMPLOYEE_ID | EMPLOYEE_TITLE |
+-------------+---------------------+
| 02345 | DBA |
| 03373 | Purchasing Agent |
| 04893 | DBA |
| 06234 | Programmer |
| 08273 | Analyst |
| 09002 | Clerk |
| 09283 | Clerk |
| 09382 | Database Programmer |
| 10282 | Clerk |
| 13383 | Programmer |
| 13567 | Analyst |
| 13932 | Programmer |
| 14311 | Programmer |
+-------------+---------------------+
(B13 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show colhow columns from EMPLOYEE
-> ;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| EMPLOYEE_ID | varchar(6) | NO | PRI | NULL | |
| EMPLOYEE_FNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_LNAME | varchar(20) | YES | | NULL | |
| EMPLOYEE_HIREDATE | datetime | YES | | NULL | |
| EMPLOYEE_TITLE | varchar(30) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
(B5 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> list cusCushow tables
-> ;
+---------------------+
| Tables_in_Ch01_Text |
+---------------------+
| AGENT |
| CERTIFIED |
| CUSTOMER |
| EMPLOYEE |
| EMPLOYEESKILLS |
| SKILL |
+---------------------+
(B6 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> show columnds from CUSTOMER
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'columnds from CUSTOMER' at line 1
(B(BMariaDB [Ch01_Text]> ;show columnds from CUSTOMER[1@s
-> ;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| C_NAME | varchar(20) | YES | | NULL | |
| C_PHONE | varchar(12) | YES | | NULL | |
| C_ADDRESS | varchar(30) | YES | | NULL | |
| C_ZIP | varchar(5) | YES | | NULL | |
| A_NAME | varchar(20) | YES | | NULL | |
| A_PHONE | varchar(12) | YES | | NULL | |
| TP | varchar(2) | YES | | NULL | |
| AMT | decimal(6,2) | YES | | NULL | |
| REN | datetime | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
(B9 rows in set (0.01 sec)
(B(B
(BMariaDB [Ch01_Text]> list C_NAME , C_PADDRESS , C_PHONE from CUSTOMER;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'list C_NAME, C_ADDRESS, C_PHONE from CUSTOMER' at line 1
(B(BMariaDB [Ch01_Text]> list C_NAME, C_ADDRESS, C_PHONE from CUSTOMER;[1@s[1@e[1@l[1@e[1@c[1@t
+-----------------+------------------------+--------------+
| C_NAME | C_ADDRESS | C_PHONE |
+-----------------+------------------------+--------------+
| Alfred A. Ramas | 218 Fork Rd., Babs, TN | 615-844-2573 |
| Leona K. Dunne | Box 12A, Fox, KY | 713-894-1238 |
| Kathy W. Smith | 125 Oak Ln, Babs, TN | 615-894-2285 |
| Paul F. Olowski | 217 Lee Ln., Babs, TN | 615-894-2180 |
| Myron Orlando | Box 111, New, TN | 615-222-1672 |
| Amy B. O'Brian | 387 Troll Dr., Fox, KY | 713-442-3381 |
| James G. Brown | 21 Tye Rd., Nash, TN | 615-297-1228 |
| George Williams | 155 Maple, Nash, TN | 615-290-2556 |
| Anne G. Farriss | 2119 Elm, Crew, KY | 713-382-7185 |
| Olette K. Smith | 2782 Main, Nash, TN | 615-297-3809 |
+-----------------+------------------------+--------------+
(B10 rows in set (0.00 sec)
(B(B
(BMariaDB [Ch01_Text]> exit
(BBye
(B]0;ishoebot@id414m12:~[ishoebot@id414m12 ~]$ exit

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Labs/Lab10/Lab10.zip Normal file

Binary file not shown.

BIN
Labs/Lab10/getStatus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
Labs/Lab10/numOfMethods.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

BIN
Labs/Lab2/Lab2.docx Normal file

Binary file not shown.

1
Labs/Lab2/Lab2.drawio Normal file
View File

@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2021-01-21T21:18:56.984Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75" etag="HbJHqGCg1yvTsoIWctFC" version="14.2.6" type="device"><diagram id="0-UjUI5zx-0e33ZyQNgJ" name="Page-1">7V1bc5s4GP01ftwOV9t53DiX7iTpdpJ0un1UjGzYYuQFObHz61cCCWxkOTgGIy6dTAcJIYPO4XwfB8kemJPF+jYES/cBOdAfGJqzHphXA8MY6yb5n1ZskgpLGycV89Bzkio9q3jy3iGr1FjtynNgtNMQI+Rjb7lbOUVBAKd4pw6EIXrbbTZD/u6nLsEcChVPU+CLtT89B7vssmwtq/8KvbnLP1nX2J4F4I1ZReQCB71tVZnXA3MSIoSTrcV6An06dnxckuNuJHvTEwthgIscYPy8nUVoFF28Dx9vbj3t5Q6u/mC9vAJ/xS74RwTDiJ0x3vBhICe/pJsYvNCqywiDEDO0TI1UkPHHwAtgSCr0uOz7YBl5cfOkxvV85x5s0ArzjnjpcuatofOYgEXbEtzuSWe0SDufkc6f2MnQ3cD35gHZnpJLp594GcKInMs9iDBrwS4LhhiupeOlpygQ9kK0gDjckCZrztTkiM1u8S1jgT5mde42A4asEjDmzdOeM3DIBsPnCKwMASspTOQqsQf8R3JHgGAeI7YLCB1VJ0TLZxDOIWYVS+TR8bx+JSOUDr3n+xPkI4prgALaE0ZLttOHM37sC8IYLTh8bDjSTuOhsC/JHxmcifbFHtjkdCekrGdl8kebh3iCggiHhE20D0hAfYMU2GKgymkuIs2gNQtCa1aFrCkg+/3uOGxj8QMZtkfDpuVgy99yiAz7zI/1y/UcBwYn4WHsx2MLAPOc42/tVcG/rmrGgMtc0vYyWoKpF8zvkyOHOZDsc4G0lt809jlBsxshh3lMGyCHw7rlcCgge1O3HELH4/2Vr4a2Wmo4EoZ/gsDUVV8Oz4KKKvI37uWvGvm7qFv+Lk5EtlniN1ZL/LjvsDX638ACdkv6JJioIn266Fr02leK9ulG3eKnn+pyNEv9dAketcmfaEV8BS8e/rZadEsCZcAoo4GiZxED1Vu3ZI/FoziTtZFdTNUuKkOrGWaFmt6tdTBk1W7e6qJd0XL3VlfMsNBFxyLWQvUdi2oNXBlOysSw3sOoShVr93D1brkYumI2hiHaGEke3zkvQ4aMKiJo7LHbXTj97QV9Kk+FzPpcKp+CWD5gzYhaSubyCdnVzeUNMWq1PJc3FAtcpiRwMU3sekovg0uVaGb21nxV4lh7Sm+K1ny752WYipnzpsScV18Uz4OLMiIoevO9CJYjgrVPzjBFJ7/lIigxmmoTQdFub8Zk3fPAoowGirZGr4HlaGD9kzTMUy2QhkmgBI/aJFB0Kdjj8RXAHbN3ZdioooOW6GfEs6lh7+4OhDV2ZtFFdpVN1LCa4V8oae5a2n6sVTF3LdG/aLm5aylmYFiigdGQpSXVuroynJQJYr2hUZUq1u7qWqdOTWxWLm8pZmdYop3RvTkaMlBU0T9bjFvUc2rJhGsHRC50BqUl9SkOTOKMon5FamyUD2AzApiSaX1CfnXTelsMYC1P623FYpi935JvyLvJalN7GVbKhLbep69KGWtP7W3Rpr+509uc3duKOfW26NR38WWlDBZVRJDfqb0Ili6CtU/YGIqO/s1dqy2OocRxqksEh6Lv3pDU8Dy4KKOCYho/QYtFrFhN9zgKoXbcShRTLyhtRmW2xrAZybuStkbCdnVtjaGYvLfc1hgqlrwP9yTvgfffCqofuKr1NGRAqRLIRn06X5Us1u5pjPal823O5keKZfMjSTbfmAV654FHGS0UX132WliOFtZubYzEt5ot10KJ11SbFoqvHrto78pgUUYDRWOj18ByNLD+tSgj0QNpuQhKEKlNBEWjoiGTes+DiyoqOO78U3HsiiQetW5Uqop23ao4PnUdS7M0cazYQ/JYfEhmr1K6t0JPho0yutj5J+Tz6eK4dl08dSJww3RRsQfmsfjAzHTxGa5xx3RR9afmAt/gmlcOFy98RmQYOH/S318lxevHdxiiZ/QAgs2AzRXI7/s7BgyuPfwPheOLzUq/+G1Ctq/W24UNLwTkarcOosVf6UmQQnZYXOLHJRcDHeH3X3MTAsgFo1U4hQeGis8MwFz1ZQ0/Xo+Z/n7szsIIXhlCH2DvdfeM9yHPPuM7DRIZp3T+ZoyvzBjlyJNcKTsq44/YUe4L9tO5ELyjZCSEjmIiphd+go4U4CZFlr8DJYh6ePMYjx4KrrM9QuyTMZgIymECp/tC9BtyHRqQ2zP+t83tbWanPN/P7RI5yn+CQHWOmhe71NKtT3LUypE9TTTOxFF+HQc5mlGMhawt/oVoFTjxwiztILHyFJYJovaBIO5ZB1aEeR8SSjZD9FSiGDl889OsihLF1nKqmA+pVRPFPKhdjBgkf3fRHAXAv0dxWkNR+hdivGHYgxVGOQFjiqMfoTgZeXaokzFJQp5DQV2aCeSZmzH+OAqWJ36y71ctzNXTfvmvwNNJGSnXAgROgs2BcPVJFSlROGRPk+cKRSNhIeuopFCUj2mfVhhSDBHC281DsHQfkANpi/8B</diagram></mxfile>

BIN
Labs/Lab2/Lab2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Binary file not shown.

BIN
Labs/Lab3/Lab3.docx Normal file

Binary file not shown.

BIN
Labs/Lab3/Lab3.pdf Normal file

Binary file not shown.

BIN
Labs/Lab3/Lab3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

BIN
Labs/Lab4/Lab4.docx Normal file

Binary file not shown.

BIN
Labs/Lab4/Lab4.pdf Normal file

Binary file not shown.

17
Labs/Lab4/Queries.txt Normal file
View File

@ -0,0 +1,17 @@
Question 1:
select CUS_FNAME as `First Name`, CUS_LNAME as `Last Name`, CUS_INITIAL as `Customer Initial`
from CUSTOMER
where CUS_AREACODE = '615' and CUS_BALANCE != '0';
Question 2:
select P_DESCRIPT as `Product Description` , P_PRICE as `Price`
from PRODUCT
where P_QOH < 15;
Question 3:
select P_CODE as `Product Code`, P_DESCRIPT as `Product Description`, (P_PRICE * (1 - P_DISCOUNT)) as `Discounted Price`
from PRODUCT
where P_PRICE > 100;

BIN
Labs/Lab4/Queries.zip Normal file

Binary file not shown.

BIN
Labs/Lab4/SQL Lab4.zip Normal file

Binary file not shown.

View File

@ -0,0 +1,9 @@
+------------+-----------+------------------+
| First Name | Last Name | Customer Initial |
+------------+-----------+------------------+
| Kathy | Smith | W |
| Paul | Olowski | F |
| James | Brown | G |
| George | Williams | NULL |
+------------+-----------+------------------+

View File

@ -0,0 +1,3 @@
select CUS_FNAME as `First Name`, CUS_LNAME as `Last Name`, CUS_INITIAL as `Customer Initial`
from CUSTOMER
where CUS_AREACODE = '615' and CUS_BALANCE != '0';

View File

@ -0,0 +1,11 @@
+----------------------------------+--------+
| Product Description | Price |
+----------------------------------+--------+
| Power painter, 15 psi., 3-nozzle | 109.99 |
| B&D jigsaw, 12-in. blade | 109.92 |
| B&D jigsaw, 8-in. blade | 99.87 |
| B&D cordless drill, 1/2-in. | 38.95 |
| Sledge hammer, 12 lb. | 14.40 |
| Hicut chain saw, 16 in. | 256.99 |
+----------------------------------+--------+

View File

@ -0,0 +1,3 @@
select P_DESCRIPT as `Product Description` , P_PRICE as `Price`
from PRODUCT
where P_QOH < 15;

View File

@ -0,0 +1,9 @@
+--------------+-------------------------------------+------------------+
| Product Code | Product Description | Discounted Price |
+--------------+-------------------------------------+------------------+
| 11QER/31 | Power painter, 15 psi., 3-nozzle | 109.9900 |
| 2232/QTY | B&D jigsaw, 12-in. blade | 104.4240 |
| 89-WRE-Q | Hicut chain saw, 16 in. | 244.1405 |
| WR3/TT3 | Steel matting, 4'x8'x1/6", .5" mesh | 107.9550 |
+--------------+-------------------------------------+------------------+

View File

@ -0,0 +1,3 @@
select P_CODE as `Product Code`, P_DESCRIPT as `Product Description`, (P_PRICE * (1 - P_DISCOUNT)) as `Discounted Price`
from PRODUCT
where P_PRICE > 100;

65
Labs/Lab5/AllQueries.txt Normal file
View File

@ -0,0 +1,65 @@
1:
select *
from LGBRAND
order by BRAND_TYPE;
2:
select BRAND_TYPE as `Brand Type` ,count(BRAND_TYPE) as `Number of each brand types`
from LGBRAND
group by BRAND_TYPE;
3:
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where CUST_BALANCE != 0
group by CUST_STATE;
4:
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where
CUST_BALANCE != 0
group by CUST_STATE
having
count(CUST_CODE) > 100;
5:
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where
CUST_BALANCE != 0
group by CUST_STATE
having
count(CUST_CODE) > 100
order by STATE desc;
6:
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where
CUST_BALANCE != 0
group by CUST_STATE
having
count(CUST_CODE) > 100
order by count(CUST_CODE);
7:
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`
from LGCUSTOMER
natural join LGINVOICE
natural join LGLINE
natural join LGPRODUCT
natural join LGBRAND
where
CUST_STATE = "ME"
group by BRAND_TYPE;
8:
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`, CUST_STATE as `State`
from LGCUSTOMER
natural join LGINVOICE
natural join LGLINE
natural join LGPRODUCT
natural join LGBRAND
group by BRAND_TYPE, CUST_STATE
having SUM(LINE_NUM) < 10;
9:
select
MAX(EMP_HIREDATE) as `Hire date`,
EMP_FNAME as `First Name`,
EMP_LNAME as `Last Name`,
DATEDIFF(CURRENT_DATE, MAX(EMP_HIREDATE)) as `Days since hire`
from LGEMPLOYEE;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Labs/Lab5/Lab5.zip Normal file

Binary file not shown.

3
Labs/Lab5/Q1.sql Normal file
View File

@ -0,0 +1,3 @@
select *
from LGBRAND
order by BRAND_TYPE;

17
Labs/Lab5/Q1.txt Normal file
View File

@ -0,0 +1,17 @@
+----------+--------------------+------------+
| BRAND_ID | BRAND_NAME | BRAND_TYPE |
+----------+--------------------+------------+
| 25 | STUTTENFURST | CONTRACTOR |
| 27 | HOME COMFORT | CONTRACTOR |
| 28 | OLDE TYME QUALITY | CONTRACTOR |
| 30 | LONG HAUL | CONTRACTOR |
| 35 | LE MODE | PREMIUM |
| 26 | HOMESTEADER FINEST | PREMIUM |
| 33 | BINDER PRIME | PREMIUM |
| 34 | PRIME OF LIFE | VALUE |
| 32 | YOUR HOME HELPER | VALUE |
| 31 | VALU-MATTE | VALUE |
| 29 | BUSTERS | VALUE |
| 24 | REGAL HOME | VALUE |
| 23 | FORESTERS BEST | VALUE |
+----------+--------------------+------------+

3
Labs/Lab5/Q2.sql Normal file
View File

@ -0,0 +1,3 @@
select BRAND_TYPE as `Brand Type` ,count(BRAND_TYPE) as `Number of each brand types`
from LGBRAND
group by BRAND_TYPE;

7
Labs/Lab5/Q2.txt Normal file
View File

@ -0,0 +1,7 @@
+------------+----------------------------+
| Brand Type | Number of each brand types |
+------------+----------------------------+
| CONTRACTOR | 4 |
| PREMIUM | 3 |
| VALUE | 6 |
+------------+----------------------------+

4
Labs/Lab5/Q3.sql Normal file
View File

@ -0,0 +1,4 @@
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where CUST_BALANCE != 0
group by CUST_STATE;

28
Labs/Lab5/Q3.txt Normal file
View File

@ -0,0 +1,28 @@
+-------+-----------------------------+
| State | Number of non zero balances |
+-------+-----------------------------+
| AL | 39 |
| CT | 12 |
| DE | 2 |
| FL | 57 |
| GA | 32 |
| IN | 52 |
| KY | 42 |
| MA | 34 |
| MD | 51 |
| ME | 14 |
| MI | 30 |
| MS | 24 |
| NC | 59 |
| NH | 8 |
| NJ | 34 |
| NY | 104 |
| OH | 60 |
| PA | 118 |
| RI | 8 |
| SC | 23 |
| TN | 32 |
| VA | 38 |
| VT | 27 |
| WV | 27 |
+-------+-----------------------------+

7
Labs/Lab5/Q4.sql Normal file
View File

@ -0,0 +1,7 @@
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where
CUST_BALANCE != 0
group by CUST_STATE
having
count(CUST_CODE) > 100;

6
Labs/Lab5/Q4.txt Normal file
View File

@ -0,0 +1,6 @@
+-------+-----------------------------+
| State | Number of non zero balances |
+-------+-----------------------------+
| NY | 104 |
| PA | 118 |
+-------+-----------------------------+

8
Labs/Lab5/Q5.sql Normal file
View File

@ -0,0 +1,8 @@
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where
CUST_BALANCE != 0
group by CUST_STATE
having
count(CUST_CODE) > 100
order by STATE desc;

7
Labs/Lab5/Q5.txt Normal file
View File

@ -0,0 +1,7 @@
+-------+-----------------------------+
| State | Number of non zero balances |
+-------+-----------------------------+
| PA | 118 |
| NY | 104 |
+-------+-----------------------------+

8
Labs/Lab5/Q6.sql Normal file
View File

@ -0,0 +1,8 @@
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
from LGCUSTOMER
where
CUST_BALANCE != 0
group by CUST_STATE
having
count(CUST_CODE) > 100
order by count(CUST_CODE);

7
Labs/Lab5/Q6.txt Normal file
View File

@ -0,0 +1,7 @@
+-------+-----------------------------+
| State | Number of non zero balances |
+-------+-----------------------------+
| NY | 104 |
| PA | 118 |
+-------+-----------------------------+

9
Labs/Lab5/Q7.sql Normal file
View File

@ -0,0 +1,9 @@
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`
from LGCUSTOMER
natural join LGINVOICE
natural join LGLINE
natural join LGPRODUCT
natural join LGBRAND
where
CUST_STATE = "ME"
group by BRAND_TYPE;

8
Labs/Lab5/Q7.txt Normal file
View File

@ -0,0 +1,8 @@
+------------------------------+------------+
| Number of Products purchased | Brand |
+------------------------------+------------+
| 249 | CONTRACTOR |
| 126 | PREMIUM |
| 130 | VALUE |
+------------------------------+------------+

8
Labs/Lab5/Q8.sql Normal file
View File

@ -0,0 +1,8 @@
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`, CUST_STATE as `State`
from LGCUSTOMER
natural join LGINVOICE
natural join LGLINE
natural join LGPRODUCT
natural join LGBRAND
group by BRAND_TYPE, CUST_STATE
having SUM(LINE_NUM) < 10;

6
Labs/Lab5/Q8.txt Normal file
View File

@ -0,0 +1,6 @@
+------------------------------+-------+-------+
| Number of Products purchased | Brand | State |
+------------------------------+-------+-------+
| 7 | VALUE | DE |
+------------------------------+-------+-------+

6
Labs/Lab5/Q9.sql Normal file
View File

@ -0,0 +1,6 @@
select
MAX(EMP_HIREDATE) as `Hire date`,
EMP_FNAME as `First Name`,
EMP_LNAME as `Last Name`,
DATEDIFF(CURRENT_DATE, MAX(EMP_HIREDATE)) as `Days since hire`
from LGEMPLOYEE;

6
Labs/Lab5/Q9.txt Normal file
View File

@ -0,0 +1,6 @@
+------------+------------+-----------+-----------------+
| Hire date | First Name | Last Name | Days since hire |
+------------+------------+-----------+-----------------+
| 2017-12-15 | TAMARA | MCDONALD | 1155 |
+------------+------------+-----------+-----------------+

10
Labs/Lab6/1.sql Normal file
View File

@ -0,0 +1,10 @@
CREATE TABLE Courses
(
courseID INT AUTO_INCREMENT,
courseNum VARCHAR(10),
courseName VARCHAR(40),
courseDescription VARCHAR(80),
creditHours FLOAT DEFAULT 3.0,
CHECK (creditHours BETWEEN 0.0 AND 6.0),
PRIMARY KEY(courseID)
);

3
Labs/Lab6/10.sql Normal file
View File

@ -0,0 +1,3 @@
UPDATE Courses
SET approvedDate = ("2020-7-8")
where courseID = 1;

4
Labs/Lab6/11.sql Normal file
View File

@ -0,0 +1,4 @@
select studentName, courseName, courseDescription, creditHours, letterGrade
from Students
natural join Enrollments
natural join Courses;

2
Labs/Lab6/12.sql Normal file
View File

@ -0,0 +1,2 @@
INSERT INTO Students(studentName, email, gpa, dateOfBirth)
VALUES ('Isaac Shoebottom', 'ir.shoebottom@gmail.com', 3.5, "2002-08-07");

2
Labs/Lab6/13.sql Normal file
View File

@ -0,0 +1,2 @@
INSERT INTO Enrollments(studentID, courseID, letterGrade)
VALUES(1, 1, 'A+');

2
Labs/Lab6/14.sql Normal file
View File

@ -0,0 +1,2 @@
INSERT INTO Enrollments(studentID, courseID, letterGrade)
VALUES(1, 2, 'B');

11
Labs/Lab6/2.sql Normal file
View File

@ -0,0 +1,11 @@
CREATE TABLE Students
(
studentID INT AUTO_INCREMENT,
studentName VARCHAR(30) NOT NULL,
email VARCHAR(40),
gpa FLOAT DEFAULT 0.0,
PRIMARY KEY (studentID),
CONSTRAINT CHECK_GPA
CHECK (gpa BETWEEN 0 and 4.3)
);
ALTER TABLE Students ADD dateOfBirth DATETIME;

11
Labs/Lab6/3.sql Normal file
View File

@ -0,0 +1,11 @@
CREATE TABLE Enrollments
(
studentID INT,
courseID INT,
letterGrade CHAR(2),
PRIMARY KEY(studentID, courseID),
FOREIGN KEY(studentID)
REFERENCES Students(studentID)
ON DELETE NO ACTION
ON UPDATE CASCADE
);

5
Labs/Lab6/4.sql Normal file
View File

@ -0,0 +1,5 @@
ALTER TABLE Enrollments
ADD FOREIGN KEY(courseID)
REFERENCES Courses(courseID)
ON DELETE NO ACTION
ON UPDATE CASCADE;

5
Labs/Lab6/5.sql Normal file
View File

@ -0,0 +1,5 @@
ALTER TABLE Enrollments
ADD FOREIGN KEY(studentID)
REFERENCES Students(studentID)
ON DELETE NO ACTION
ON UPDATE CASCADE;

2
Labs/Lab6/7.sql Normal file
View File

@ -0,0 +1,2 @@
INSERT INTO Courses(courseNum, courseName, courseDescription, creditHours)
VALUES ('CS1103', 'Data & Information Management', 'Introduction to Databases', 7);

2
Labs/Lab6/8.sql Normal file
View File

@ -0,0 +1,2 @@
INSERT INTO Courses(courseNum, courseName, courseDescription, creditHours)
VALUES ('CS1303', 'Discrete Structures', 'Computer Science but it\'s math actually', 4);

1
Labs/Lab6/9.sql Normal file
View File

@ -0,0 +1 @@
ALTER TABLE Courses ADD approvedDate DATETIME;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,253 @@
Script started on Thu Mar 11 17:15:35 2021
]0;ishoebot@gc112m01:~[ishoebot@gc112m01 ~]$ exitlsdwa783987473829y2benjknbfdskbncxknbczxdwadwannd``eexitmysql -u ishoebot -p -h cs1103.cs.unb.ca
Enter password:
(BWelcome to the MariaDB monitor. Commands end with ; or \g.
(B(BYour MariaDB connection id is 590
Server version: 5.5.65-MariaDB MariaDB Server
(B(BCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
(B(BType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(B[?1034hMariaDB [(none)]> uys  se ishoebot
(BDatabase changed
(BMariaDB [ishoebot]> CREATE TABLE Students
-> (
-> studentID INT AUTO_INCREMENT,
-> studentName VARCHAR(30) NOT NULL,
-> email VARCHAR(40),
-> gpa FLOAT DEFAULT 0.0,
IMAR -> PRIMARY KEY (studentID)
-> CONSTRAINT CHECK_GPA
->  CHECK (gpa BETWEEN 0 and 4.3)
-> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CONSTRAINT CHECK_GPA
CHECK (gpa BETWEEN 0 and 4.3)
)' at line 8
(B(BMariaDB [ishoebot]> CREATE TABLE Students
-> (
-> studentID INT AUTO_INCREMENT,
-> studentName VARCHAR(30) NOT NULL,
-> email VARCHAR(40),
-> gpa FLOAT DEFAULT 0.0,
-> PRIMARY KEY (studentID),
-> CONSTRAINT CHECK_GPA
->  CHECK (gpa BETWEEN 0 and 4.3)
-> );
(BQuery OK, 0 rows affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> ALTER TABLE Students ADD dateOfBirth DATETIME;
Stage: 2 of 2 'Enabling keys' 0% of stage done
(BQuery OK, 0 rows affected (0.01 sec)
(B(BRecords: 0 Duplicates: 0 Warnings: 0
(B(B
(BMariaDB [ishoebot]> CREATE TABLE Enrollments
-> (
-> studentID INT,
-> courseID INT,
-> letterGrade CHAR(2),
-> PRIMARY KEY(studentID, courseID),
-> FOREIGN KEY(studentID)
-> REFERENCES Students(studentID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE
-> );
(BQuery OK, 0 rows affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> CREATE TABLE Courses
-> (
-> courseID INT AUTO_INCREMENT,
-> courseNum VARCHAR(10),
-> courseName VARCHAR(40),
-> courseDescription VARCHAR(80),
creditHours FL -> creditHours FLOAT DEFAULT 3.0,
-> CHECK (creditHours BETWEEN 0.0 AND 6.0)
-> PRIMARY KEY(courseID)
-> );
 -> );
 -> );
 -> );
 -> );
 -> );
 -> );
 -> );
 -> );
 -> );
 -> );
 -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PRIMARY KEY(courseID)
)' at line 9
(B(BMariaDB [ishoebot]> CREATE TABLE Courses
-> (
-> courseID INT AUTO_INCREMENT,
-> courseNum VARCHAR(10),
-> courseName VARCHAR(40),
-> courseDescription VARCHAR(80),
-> creditHours FLOAT DEFAULT 3.0,
-> CHECK (creditHours BETWEEN 0.0 AND 6.0),
EY(courseID -> PRIMARY KEY(courseID)
-> );
(BQuery OK, 0 rows affected (0.01 sec)
(B(B
(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> (
-> FOREIGN KEY(courseID)
FERE -> REFERENCES Courses(courseID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE
-> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(
FOREIGN KEY(courseID)
REFERENCES Courses(courseID)
ON DELETE NO ACTION
' at line 2
(B(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> (
-> ADD FOREIGN KEY(courseID)
-> REFERENCES Courses(courseID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE
-> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(
ADD FOREIGN KEY(courseID)
REFERENCES Courses(courseID)
ON DELETE NO ACTI' at line 2
(B(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> FOREIGN KEY(courseID)
-> REFERENCES Courses(courseID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FOREIGN KEY(courseID)
REFERENCES Courses(courseID)
ON DELETE NO ACTION
' at line 2
(B(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> ADD FOREIGN KEY(courseID)
-> REFERENCES Courses(courseID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE;
Stage: 2 of 2 'Enabling keys' 0% of stage done
(BQuery OK, 0 rows affected (0.01 sec)
(B(BRecords: 0 Duplicates: 0 Warnings: 0
(B(B
(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> ADD FOREIGN KEY(StudentID)
-> REFERENCES Students(StudentID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE;
Stage: 2 of 2 'Enabling keys' 0% of stage done
(BQuery OK, 0 rows affected (0.01 sec)
(B(BRecords: 0 Duplicates: 0 Warnings: 0
(B(B
(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> ADD FOREIGN KEY(studentID)
-> REFERENCES Students(studentID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE;
Stage: 2 of 2 'Enabling keys' 0% of stage done
(BQuery OK, 0 rows affected (0.01 sec)
(B(BRecords: 0 Duplicates: 0 Warnings: 0
(B(B
(BMariaDB [ishoebot]> ALTER TABLE EN nrollments DROP CONSTRAINT ENrollm      nrollments_ibfk_4
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CONSTRAINT Enrollments_ibfk_4' at line 1
(B(BMariaDB [ishoebot]> ;ALTER TABLE Enrollments DROP CONSTRAINT Enrollments_ibfk_4                  studentID;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CONSTRAINT studentID' at line 1
(B(BMariaDB [ishoebot]> ALTER TABLE Enrollments DROP CONSTRAINT studentID;
MariaDB [ishoebot]> ;ALTER TABLE Enrollments DROP CONSTRAINT Enrollments_ibfk_4 4l ;s  DROP CONSTRAINT[1@I[1@N[1@D[1@E[1@X Enrollments_ibfk_4;
ERROR 1091 (42000): Can't DROP 'Enrollments_ibfk_4'; check that column/key exists
(B(BMariaDB [ishoebot]> ALTER TABLE Enrollments DROP INDEX Enrollments_ibfk_4;                   St  studentID;
ERROR 1091 (42000): Can't DROP 'studentID'; check that column/key exists
(B(BMariaDB [ishoebot]> ALTER TABLE Enrollments DROP INDEX studentID;                constraint                                       slect    elect studentID from Enrollments where                                         atler      lter table student       Enrollments drop coluy    olumn studentID cascade constraints
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'constraints' at line 1
(B(BMariaDB [ishoebot]> ;alter table Enrollments drop column studentID cascade constraintsmn stttn[1@i[1@n[1@d[1@e[1@x
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'cascade constraints' at line 1
(B(BMariaDB [ishoebot]> ;alter table Enrollments drop index studentID cascade constraints
MariaDB [ishoebot]> ;alter table Enrollments drop column studentID cascade constraintss           indexl ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'index' at line 1
(B(BMariaDB [ishoebot]> alter table Enrollments drop column studentID cascade index;
MariaDB [ishoebot]> ;alter table Enrollments drop index studentID cascade constraintsex[1@s[1@t[1@u[1@d studentID cascade constraints;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'constraints' at line 1
(B(BMariaDB [ishoebot]> drop table Enrollments
-> ;
(BQuery OK, 0 rows affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> CREATE TABLE Enrollments
-> (
-> studentID INT,
-> courseID INT,
-> letterGrade CHAR(2),
-> PRIMARY KEY(studentID, courseID),
-> FOREIGN KEY(studentID)
-> REFERENCES Students(studentID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE
-> );
(BQuery OK, 0 rows affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> ALTER TABLE Enrollments
-> ADD FOREIGN KEY(courseID)
-> REFERENCES Courses(courseID)
-> ON DELETE NO ACTION
-> ON UPDATE CASCADE;
Stage: 2 of 2 'Enabling keys' 0% of stage done
(BQuery OK, 0 rows affected (0.01 sec)
(B(BRecords: 0 Duplicates: 0 Warnings: 0
(B(B
(BMariaDB [ishoebot]> INSERT INTO Courses(courseNum, courseName, courseDescription, creditHours)
Data & Inform -> VALUES ('CS1103', 'Data & Information Management', 'Introduction to Databases', 7);
(BQuery OK, 1 row affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> select * from Courses;
+----------+-----------+-------------------------------+---------------------------+-------------+
| courseID | courseNum | courseName | courseDescription | creditHours |
+----------+-----------+-------------------------------+---------------------------+-------------+
| 1 | CS1103 | Data & Information Management | Introduction to Databases | 7 |
+----------+-----------+-------------------------------+---------------------------+-------------+
(B1 row in set (0.00 sec)
(B(B
(BMariaDB [ishoebot]> INSERT INTO Courses(courseNum, courseName, courseDescription, creditHours)
-> VALUES ('CS1303', 'Discrete Structures', 'Computer Science but it\'s math actually', 4);
(BQuery OK, 1 row affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> ALTER TABLE Courses ADD approvedDate DATETIME;
Stage: 2 of 2 'Enabling keys' 0% of stage done
(BQuery OK, 2 rows affected (0.01 sec)
(B(BRecords: 2 Duplicates: 0 Warnings: 0
(B(B
(BMariaDB [ishoebot]> UPDATE Courses
rovedDate = ("2020-7- -> SET approvedDate = ("2020-7-8")
-> where courseID = 1;
(BQuery OK, 1 row affected (0.00 sec)
(B(BRows matched: 1 Changed: 1 Warnings: 0
(B(B
(BMariaDB [ishoebot]> select studentName, courseName, letterGrade
-> from Students
-> natural join Enrollments
-> natural join Courses;
(BEmpty set (0.00 sec)
(B(B
(BMariaDB [ishoebot]> INSERT INTO Students(studentName, email, gpa, dateOfBirth)
-> VALUES ('Isaac Shoebottom', 'ir.shoebottom@gmail.com', 3.5, "2002-08-07");
(BQuery OK, 1 row affected (0.00 sec)
(B(B
(BMariaDB [ishoebot]> INSERT INTO Enrollments(studentID, courseID, letterGrade)
-> VALUES(1, 1, '85');
(BQuery OK, 1 row affected (0.01 sec)
(B(B
(BMariaDB [ishoebot]> INSERT INTO Enrollments(studentID, courseID, letterGrade)
-> VALUES(1, 2, '95');
(BQuery OK, 1 row affected (0.01 sec)
(B(B
(BMariaDB [ishoebot]> select studentName, courseName, letterGrade
-> from Students
-> natural join Enrollments

View File

@ -0,0 +1,2 @@
ALTER TABLE Students
ADD scholarship INT DEFAULT 0;

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Labs/Lab7/Lab7Notes.pdf Normal file

Binary file not shown.

19
Labs/Lab7/Procedure.sql Normal file
View File

@ -0,0 +1,19 @@
DELIMITER \\
CREATE PROCEDURE AcceptStudent (
studentName VARCHAR(256),
emailAddress VARCHAR(256),
hsAverage FLOAT
)
BEGIN
IF (hsAverage < 0) OR (hsAverage > 100) THEN
SIGNAL SQLSTATE '45005'
SET MESSAGE_TEXT = 'High School average out of range.';
ELSEIF (hsAverage > 90) THEN
INSERT INTO Students(studentName, email, scholarship) VALUES (studentName, emailAddress, 1500);
ELSEIF (hsAverage >= 85) OR (hsAverage <= 90) THEN
INSERT INTO Students(studentName, email, scholarship) VALUES (studentName, emailAddress, 1000);
ELSE
INSERT INTO Students(studentName, email, scholarship) VALUES (studentName, emailAddress, 0);
END IF;
END\\
DELIMITER ;

6
Labs/Lab7/Test Cases.sql Normal file
View File

@ -0,0 +1,6 @@
CALL AcceptStudent('Adam Klitz', 'aklitz@gmail.com', 85);
CALL AcceptStudent('Joanna King', 'j.king@gyahoo.com', 70);
CALL AcceptStudent('Lanna Noman', 'nominal@outlook.com', 91);
SELECT * FROM Students;
CALL AcceptStudent('Ben Fry', 'benfry@yahoo.com', 140);

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,15 @@
CREATE PROCEDURE `studentTranscript`(
IN `ID` INT
)
BEGIN
IF EXISTS(SELECT 1 from Students where studentID = ID) THEN
SELECT courseName, letterGrade
FROM Enrollments
NATURAL JOIN Courses
NATURAL JOIN Students
WHERE studentID = ID;
ELSE
SIGNAL SQLSTATE '45006'
SET MESSAGE_TEXT = 'Student ID does not exist in system.';
END IF;
END

View File

@ -0,0 +1,54 @@
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Scanner;
public class Question1 {
public static void main(String[] args) {
Question1 question1 = new Question1();
Connection conn = question1.openConnection();
Scanner sc = new Scanner(System.in);
System.out.print("What is the name of the student?: ");
String studentName = sc.nextLine();
System.out.print("What is the email address of the student?: ");
String emailAddress = sc.nextLine();
System.out.print("What is the high school average of the student?: ");
String highSchoolAverage = sc.nextLine();
try {
String query = "{CALL AcceptStudent(?, ?, ?)}";
CallableStatement statement = conn.prepareCall(query);
statement.setString(1, studentName);
statement.setString(2, emailAddress);
statement.setString(3, highSchoolAverage);
statement.executeQuery();
} catch (SQLException sqlException) {
System.err.println(sqlException.getMessage());
}
System.out.println(studentName + " with email address: " + emailAddress + " and a high school average of: " + highSchoolAverage + " added");
question1.closeConnection(conn);
}
private Connection openConnection() {
final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot";
final String user = "ishoebot";
final String password = "k7FOLH5B";
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
}
catch (Exception exception) {
System.err.printf("Couldn't open a connection: (%s)", exception.getMessage());
}
return conn;
}
private void closeConnection(Connection conn) {
try {
conn.close();
}
catch (Exception exception) {
System.err.printf("Couldn't close connection: (%s)", exception.getMessage());
}
}
}

View File

@ -0,0 +1,48 @@
import java.sql.*;
public class Question2 {
public static void main(String[] args) {
if(args.length < 1) {
System.err.println("Usage: Question2 <StudentID>");
System.exit(-1);
}
Question2 question2 = new Question2();
Connection conn = question2.openConnection();
String studentID = args[0];
try {
String query = "{CALL studentTranscript(?)}";
CallableStatement statement = conn.prepareCall(query);
statement.setString(1, studentID);
ResultSet rs = statement.executeQuery();
while(rs.next()) {
String row = rs.getString(1) + ": " + rs.getString(2);
System.out.println(row);
}
} catch (SQLException sqlException) {
System.err.println(sqlException.getMessage());
}
question2.closeConnection(conn);
}
private Connection openConnection() {
final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot";
final String user = "ishoebot";
final String password = "k7FOLH5B";
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
}
catch (Exception exception) {
System.err.printf("Couldn't open a connection: (%s)", exception.getMessage());
}
return conn;
}
private void closeConnection(Connection conn) {
try {
conn.close();
}
catch (Exception exception) {
System.err.printf("Couldn't close connection: (%s)", exception.getMessage());
}
}
}

Binary file not shown.

BIN
Labs/Lab8/Lab8Notes.pdf Normal file

Binary file not shown.

15
Labs/Lab8/Prodecure.sql Normal file
View File

@ -0,0 +1,15 @@
CREATE PROCEDURE `studentTranscript`(
IN `ID` INT
)
BEGIN
IF EXISTS(SELECT 1 from Students where studentID = ID) THEN
SELECT courseName, letterGrade
FROM Enrollments
NATURAL JOIN Courses
NATURAL JOIN Students
WHERE studentID = ID;
ELSE
SIGNAL SQLSTATE '45006'
SET MESSAGE_TEXT = 'Student ID does not exist in system.';
END IF;
END

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Labs/Lab9/Lab9src.zip Normal file

Binary file not shown.

View File

@ -0,0 +1,139 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class AcceptStudentGUI extends Application {
private static TextField nameField;
private static TextField emailField;
private static TextField averageField;
private static Text response;
public void start(Stage primaryStage) {
primaryStage.setTitle("Accept a Student");
Label nameLabel = new Label("Name:");
Label emailLabel = new Label("Email:");
Label averageLabel = new Label("Average:");
nameField = new TextField();
nameField.setPrefWidth(150);
nameField.setMaxWidth(300);
emailField = new TextField();
emailField.setPrefWidth(150);
emailField.setMaxWidth(300);
averageField = new TextField();
averageField.setPrefWidth(60);
averageField.setMaxWidth(60);
averageField.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d{0,3}([.]\\d{0,2})?")) {
averageField.setText(oldValue);
}
});
Button accept = new Button("Accept");
accept.setOnAction(this::processAcceptStudent);
Button quit = new Button("Quit");
quit.setOnAction(this::quitApp);
response = new Text("");
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 10, 0, 10));
// Row 1: Buttons
grid.add(accept, 0, 0);
grid.add(quit, 2, 0);
//Row 2: name
grid.add(nameLabel, 0, 1);
grid.add(nameField, 1, 1);
//Row 3: email
grid.add(emailLabel, 0, 2);
grid.add(emailField, 1, 2);
//Row 4: HS average
grid.add(averageLabel, 0, 3);
grid.add(averageField, 1, 3);
//Row 5: response
grid.add(response, 0, 4, 2, 4);
Scene scene = new Scene(grid, 300, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
public void processAcceptStudent(ActionEvent event) {
Connection connection = openConnection();
String studentName = nameField.getText();
String emailAddress = emailField.getText();
String highSchoolAverage = averageField.getText();
try {
String query = "{CALL AcceptStudent(?, ?, ?)}";
CallableStatement statement = connection.prepareCall(query);
statement.setString(1, studentName);
statement.setString(2, emailAddress);
statement.setString(3, highSchoolAverage);
statement.executeQuery();
response.setText("Student accepted.");
response.setFill(Color.GREEN);
} catch (SQLException sqlException) {
response.setFill(Color.RED);
response.setText(sqlException.getMessage());
}
closeConnection(connection);
}
@SuppressWarnings("SpellCheckingInspection")
private static Connection openConnection() {
final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot";
final String user = "ishoebot";
final String password = "k7FOLH5B";
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
}
catch (Exception exception) {
response.setFill(Color.RED);
response.setText("Couldn't open a connection: " + exception.getMessage());
}
return conn;
}
private static void closeConnection(Connection conn) {
try {
conn.close();
}
catch (Exception exception) {
response.setFill(Color.RED);
response.setText("Couldn't close a connection: " + exception.getMessage());
}
}
public void quitApp(ActionEvent event) {
Platform.exit();
System.exit(0);
}
}

View File

@ -0,0 +1,159 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.sql.*;
public class StudentTranscriptGUI extends Application {
private static TextField studentIDField;
private static TableView<CourseGrade> tableView;
private static Text response;
public void start(Stage primaryStage) {
primaryStage.setTitle("Get a Transcript");
Label studentIDLabel = new Label("Student ID:");
tableView = new TableView<>();
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
TableColumn<CourseGrade, String> course = new TableColumn<>("Course");
TableColumn<CourseGrade, String> grade = new TableColumn<>("Grade");
tableView.getColumns().add(course);
tableView.getColumns().add(grade);
tableView.setPrefWidth(300);
//depreciated
course.impl_setReorderable(false);
grade.impl_setReorderable(false);
course.setCellValueFactory(new PropertyValueFactory<>("course"));
grade.setCellValueFactory(new PropertyValueFactory<>("grade"));
studentIDField = new TextField();
studentIDField.setPrefWidth(150);
studentIDField.setMaxWidth(300);
Button accept = new Button("Get Transcript");
accept.setOnAction(this::processAcceptStudent);
Button quit = new Button("Quit");
quit.setOnAction(this::quitApp);
response = new Text("");
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 10, 0, 10));
GridPane.setHalignment(quit, HPos.RIGHT);
// Row 1: Buttons
grid.add(accept, 0, 0);
grid.add(quit, 2, 0);
//Row 2: name
grid.add(studentIDLabel, 0, 1);
grid.add(studentIDField, 2, 1);
//Row 3: tableView
grid.add(tableView, 0, 2, 3, 1);
//Row 4: response
grid.add(response, 0, 3, 3, 4);
Scene scene = new Scene(grid, 300, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
public void processAcceptStudent(ActionEvent event) {
Connection connection = openConnection();
String studentID = studentIDField.getText();
tableView.getItems().clear();
try {
String query = "{CALL studentTranscript(?)}";
CallableStatement statement = connection.prepareCall(query);
statement.setString(1, studentID);
ResultSet rs = statement.executeQuery();
while(rs.next()) {
tableView.getItems().add(new CourseGrade(rs.getString(1), rs.getString(2)));
}
response.setText("Student transcript request completed.");
response.setFill(Color.GREEN);
} catch (SQLException sqlException) {
response.setFill(Color.RED);
response.setText(sqlException.getMessage());
}
closeConnection(connection);
}
@SuppressWarnings("SpellCheckingInspection")
private static Connection openConnection() {
final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot";
final String user = "ishoebot";
final String password = "k7FOLH5B";
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
}
catch (Exception exception) {
response.setFill(Color.RED);
response.setText("Couldn't open a connection: " + exception.getMessage());
}
return conn;
}
private static void closeConnection(Connection conn) {
try {
conn.close();
}
catch (Exception exception) {
response.setFill(Color.RED);
response.setText("Couldn't close a connection: " + exception.getMessage());
}
}
public void quitApp(ActionEvent event) {
Platform.exit();
System.exit(0);
}
@SuppressWarnings("unused")
public static class CourseGrade {
private String course;
private String grade;
public CourseGrade(String course, String grade) {
this.course = course;
this.grade = grade;
}
public void setCourse(String course) {
this.course = course;
}
public String getCourse() {
return course;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Some files were not shown because too many files have changed in this diff Show More