tutorial.sql Assignment Complete tutorial.sql using phpmyadmin Web Based Standard for MySQL Access All Web-Hosting Companies Provide phpmyadmin Its Not for Active Production Systems The System for Testing Development tutorial Assignment Videos MySQL Pre-tutorial PHPMyAdmin: testing Database http://cim.saddlebck.edu/phpmyadmin Most Recent Version http://cim.saddleback.edu/phpmyadmin4.4 Video Version Deprecated Closed Caption http://cim.saddleback.edu/phpmyadmin3.5 http://cim.saddleback.edu/~premiere (Import in PHPMyAdmin) Import fruit.sql to create fruit tables 2 Intro to PHPmyAdmin and tutorial.sql 1 st 5 Queries Video 2: Intro to Submit and Submit tutorial.sql 1 st 5 Queries http://cim.saddleback.edu/submit Video 3: 2 nd Five Queries for tutorial.sql 9/15, 6/2011, 8/08 & 11/05 Professor T. DeDonno 2 Professor T. DeDonno CIMW 105 Hand-Out Page 1
MySQL Pre tutorial Login to PHPMyAdmin Select Your Database Import fruit.sql Creates Fruit Tables 8/15, 6/11, 8/08 & 11/2005 Professor T. DeDonno 3 Accomplished Goal Fruit Tables 4 1) Login to phpmyadmin http://cim.saddleback.edu/phpmyadmin 2) Username: sbusername, password Student Number/ID (not mysite pswd) 3) Select your database DB0username 4) Click Import tab, 5) Select premiere fruit.sql import file will create these tables Table: fruit fruitid name price 1 apple 2.50 2 pear 3.00 3 banana 1.00 4 grpe.75 8 pluot 4.50 6 plum 1.25 8/15, 6/11, 8/08 & 11/05 Professor T. DeDonno Table: inventory fruitid quantity 1 100 3 500 2 100 1 250 2 200 4 Tutorial PHPMyAdmin Import Professor T. DeDonno CIMW 105 Hand-Out Page 2
After fruit.sql import 5 8/15, 6/2011, 8/08 & 11/2005 Professor T. DeDonno Tutorial PHPMyAdmin Import 5 MySQL 1st Tutorial Goal Create First 5 Queries for tutorial.sql To Do This #T1 SQL Tabl for Show tables #T2, #T3 Navigator for Displaying Contents #T4 #T5 SQL Tab for Describe Query 6/2011, 8/08 & 11/05 Professor T. DeDonno 6 Professor T. DeDonno CIMW 105 Hand-Out Page 3
Part 1: Tutorial Assignment Objectives 7 Five Queries to Complete w Comments #T1) show tables; #T2) select * from fruit; #T3) select * from inventory; #T4) describe fruit; #T5) describe inventory; Add # comment before each Query Click SQL Tab,Write Query to Display Tables show tables; Use Navigator Display Table Contents select * from tablename; USE SQL Tab enter describe Tablename Query describe tablename; 8/15, 6/2011, 8/08 & 11/05 Professor T. DeDonno Tutorial 1 st 5 Queries 7 #T1 Show Table Names Just Created 8 I. Login to phpmyadmin http://cim.saddleback.edu/pma II. Select Your Database III. Click SQL Tab IV. Type Script show tables; V. Add # Comment VI. Optional Save Queries Locally using Text Editor 8/15, 6/2011, 8/08 & 11/05 Professor T. DeDonno Tutorial 1 st 5 Queries 8 Professor T. DeDonno CIMW 105 Hand-Out Page 4
#T2,3) Display Content fruit, inventory 9 ) 1. Left Nav-Bar Navigator 2. Click fruit Table 3. Notice Main Window Pane 4. Edit select * fruit; 5. Add Comment #T3 display newline 6. Repeat for Inventory 9 Tutorial 1 st 5 Queries #T4 & #T5) Describe tablename; 10 6/2011, 8/08 & 11/2005 Professor T. DeDonno Describe table name; Also Click Tab Structure Add comments Tutorial 1 st 5 Queries 10 Professor T. DeDonno CIMW 105 Hand-Out Page 5
Keypoint Summary Quiz 11 Can Save local version of tutorial.sq Can Also use command line interface Other Deprecated Videos Cover This PHPMyAdmin has become the defacto standard for MySQL/Database Web-Based Interface (T or F)? Unravel the location of key information (phpmyadmin, database scripts, submit) don t let the Web Guide You (T or F)? 11 9/15, 6/13, 6/11, 8/08 & 11/05 Professor T. DeDonno Tutorial 1 st 5 Queries submit Skills to Memorize!!! Learn to Set Browser Startup Pages Always Let Web Guide You Do Not Decipher Short-cuts http://cim.saddleback.edu/submit Ctrl^C Copy. Ctrl^V Paste 8/15, 6/11, 8/08 & 11/05 Professor T. DeDonno 12 Professor T. DeDonno CIMW 105 Hand-Out Page 6
21 st Century Browsing 13 Critical Skill Advance Surfer Level Pick a Browser You don t Use Chrome, Opera, IE, Safari, Konqueror FireFox, CyberFox (64 bit FirFox) I m using Chrome minimum default Real Estate Let Web Guide (Create Tab for 5 Key Sites) Open initial site either class site, blackboard, or DB http://cim.saddleback.edu/cimw105 Set Other Tabs: submit, premiere, blackboard, phpmyadmin Save Default Pages as Starting Home Page 8/15, 6/11, 8/08 & 11/05 Professor T. DeDonno 13 Setting CIMW105 Browser 14 Install a new Browser (I m using Chrome) Go to Class Site http://cim.saddleback.edu/cimw105 Right^Click Submit Assignment Link Open in New Tab Login Using your SBUsername, Student Number http://cim.saddleback.edu/submit Go Back Right^Click New Tab Premiere DB Scripts http://cim.saddleback.edu/~premiere Video/Quizzes Right^Click new tab Blackboard Link Testing DB Right^Click new tab PHPMyAdmin Link CIM Login SBUsername, Student Number 8/15, 6/11, 8/08 & 11/05 Professor T. DeDonno 14 Professor T. DeDonno CIMW 105 Hand-Out Page 7
I m Using Chrome for Class You can use whatever Student Question ( I Just Open Chrome ) CyberFox is my main browser 15 Click Control Menu Setting Login to your gmail (android) Click Set Pages 15 submit 24/7 Auto Grader 16 Creates the File tutorial.sql in your Home Folder This is not your Web Site (public_html is a sub-folder) Queries Executed using a default user/database Make sure your Queries are Working Submit is for Submitting not Debugging May turn in Assignments Multiple Times (Due Dates Matter) Last Submitted Assignment is Recorded Pay Attention to Input/Output Specifications On Error Displays Your Output Versus Solution 16 Professor T. DeDonno CIMW 105 Hand-Out Page 8
Submit Grading Table 17 List Current Grade, Date of Last Submission; Due Date (is Usually Monday at 9AM) Quizzes Generally Expire Sunday 11:55PM 25% Penalty up to 7 Days Late 50% Penalty After That Don t Resubmit Correct Assignment after Due Date Semester May End before a Sunday You cannot submit final assignments late Blackboard Welcome Announcement Key Dates 17 Submit tutorial.sql test First 5 18 Submit Link: Blackboard, Assignments, Premiere http://cim.saddleback.edu/submit Goal submit tutorial.sql first 5 Queries Use Browser s 5 Tabs Use PHPMyAdmin Console History copy (Control^C) queries then Paste (Control^V) them into submit editing pane Ctrl^C Universal Copy Ctrl^V Universal Paste Can Wait to Fix Errors in next Video Set 9/15, 6/2011, 8/08 & 11/05 Professor T. DeDonno 18 Professor T. DeDonno CIMW 105 Hand-Out Page 9
Assignment Submit Page 19 Click Accordion to Open Click for Grade Table Edit w VI or set Themes Control^G Hot Key Grade 19 MySQL 2 nd Tutorial Create & Comment 2 nd Five Queries Add Them to Submit One at a time http://cim.saddleback.edu/submit 20 Professor T. DeDonno CIMW 105 Hand-Out Page 10
Outline MySQL 2 nd Tutorial 21 Use Browser with 5 Tab Home Page Ctrl^C Copy and Ctrl^V Paste Use PMA for Queries 6..10 & Submit One at a time Copy and Paste from History can be tricky Comments for 2 nd 5 tutorial.sql Queries # T6 Display only fruit Names # T7 Display Total Inventory Quantity for all Fruit # T8 Display Fruit Name w fruitid=1 # T9 Sum All Fruit in inventory w fruitid 1 # T10 display inventory verify #7 & #9 correct 21 #T6) Select name from fruit; Login phpmyadmin Select DB SB0username Select Table fruit Start SQL Tab Select * and (click name left colum) Go Add Comment Terminate query with ; Copy & Paste into submit 22 6/2011, 8/08 & 11/2005 Professor T. DeDonno 22 Professor T. DeDonno CIMW 105 Hand-Out Page 11
Accent, Single, Double Quote 23 Use ` accent for column, table &/or DB names On Keyboard Accent is Upper Left Corner Use ' Single Quote Literal values Keyboard Right Side Shift Double Quote Use " Double Quotes : Character String #Display costs as pennies for fruit w ID of 1 select `price` * '100' as "pennies" from fruit where `fruitid` = '1'; PHPMyAdmin Inserts Accents, Quotes Automatically Critical when Variables or Views Exist Universal Single Quote Literal Quote 23 9/15, 6/2011, 8/08 & 11/2005 Professor T. DeDonno Write Query #T7 and #T8 7) #T7 Display Total Inventory Quantity for all Fruit select sum( quantity ) from inventory; 24 8) #T8 Display Fruit Name w fruitid=1 select name from fruit where fruitid=1; Table: fruit fruitid Name Price 1 Apple 2.50 2 Pear 3.00 3 Banana 1.00 4 Grpe.75 8 Pluot 4.50 6 Plum 1.25 Table: inventory fruitid quantity 1 100 3 500 2 100 1 250 2 200 Total 1150 24 Professor T. DeDonno CIMW 105 Hand-Out Page 12
Write Last 2 Queries and Save 25 9) #T9 Sum All Fruit in inventory w fruitid 1 select sum( quantity ) from inventory where fruitid=1; 10)#T10 look at output from query, then #make sure this comment verifies 7 and 9 select * from inventory; fruitid 1 100+250 = 350 Sum( quantity ) = 100+500+100+250+200 = 600 + 350+200 = 1150 25 Other Interfaces for tutorial.sql 26 Create a local tutoral.sql File Putty - Command Line Interface Batch Commands, Note All Assignments are Batch Files Actually See Submit & MySQL Input/Output MySQL Workbench PC/Mac/Linux GUI Application Install a Local Copy of MySQL & WorkBench I don t debug Failed Installation But Vary Interface Frequently & it s a Configurable Workspace Supporting PHPMyAdmin Web Based Interface Also Web-Casts NetBeans SQL Editor Programmers Interface 26 Professor T. DeDonno CIMW 105 Hand-Out Page 13
Tutorial.sql Summary 27 Control^C Copy Control^V Paste Control ^G short cut key grade submit Show Tables; Select * from fruit Where fruitid=1; Select * from fruit Where fruitid= 5; How Would you list contents of table:inventory? 27 Accent Mark (Key Below ~) Review in tutorial.sql Videos Enclose Field & Table Names in Accent Want to use reserved keyword as Table name Select * from `select`; select * from `orders`; 28 If Not MySQL May Try Variable Expansion When You Click to Create Query PHPMyAdmin Does This Automatically View Present Must Delimit Table/Field Names For Production Code Add Accents 2/14, 5/2013, 8/08 Professor T. DeDonno 28 Professor T. DeDonno CIMW 105 Hand-Out Page 14
intermediate.sql assignment 29 Get intermediate.sql http://cim.saddleback.edu/database Links Also Assignments and Blackboard Save File Locally Import or Cut and Paste One Query at a Time Tell me What each SQL cmd does You do this by adding a comment before Each line, I did this for the first Query. submit intermediate.sql Your Version Must have # Comments Before Each Query 6/2011, 8/08 & 11/2005 Professor T. DeDonno 29 Assignment File Name MOVED TO SELECT SUBMIT 30 Filenames Matters (tutorial.sql not Tutorial.sql tutorial.sql.txt) Always Include # or comments Blanks Lines also increase readability But Don t Intermingle #, -- and/or ; inside Query Statements Always end SQL query with ; semicolon Not Always Evident with PHPMyAdmin Main Link http://cim.saddleback.edu/submit Actual Location cim.saddleback.edu/~tdedonno/submit Links for Submit Everywhere, assignments, blackboard, etc. 30 Professor T. DeDonno CIMW 105 Hand-Out Page 15