Your SlideShare is downloading. ×
word doc notes
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

word doc notes

173
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
173
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. CRUD – Create, Read, Update, Delete 03/30/2008 …………………………………………………………………………………………………….http://JilMac.com/Training/Web-Databases/CRUD.doc JilMac@sover.net M-F 6am-8pm, S-S 8am-8pm http://JilMac.com JilMac 802-254-8628 Most Shared Web Hosting accounts costing $2.50 to $30 per month include the ability to create a DataBase and write queries to it using MySQL. And most go unused. You do NOT have to integrate this into a web site – you can use the Database as is, export the data to a spreadsheet when needed. The data will be there when you are ready to expand your site to include Server Side development. With Web Hosting – you are rarely permitted to access the command line. You are given access to a Database Administration Software Application, the most popular on Shared Web Hosting plans is phpMyAdmin. This discussion is about creating a MySQL DataBase and using phpMyAdmin to add tables, relationships, adding, updating, deleting information. This is where the CRUD is. Create, Read, Update, and Delete. Go to your Web Hosting’s site: Examples: http://Hostica.com or http://CrystalTech.com or http://GoDaddy.com Go to the Login Screen and Log-in  security tip: ALWAYS glance up and make sure you are in an https:// session and that the URL name is your host. You usually have options at this point to manage: Domains, Web Options, Change Password, Change Account, Add Account, Account Settings, Platform Changes, e-Mail, FTP, Contact Billing info, Tools: Stats, DATABASES, Pre-installed Scripts, etc We’re after Databases, so look there. You may have options on what types of databases, or servers. For right now, since our objective is to CREATE a DATABASE, we want to select phpMyAdmin. CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 1
  • 2. You may see something simple like above. - or – You may have a more elaborate screen like the one to the Right. NOTE: You will need to login again – Site Administration, FTP, and Database logons are all different. 1.) Select the Database you want to work on. If you have the ability to create a new database – select that. NOTE: Many entry level Shared Web Hosting Plans may only allow 1 database. You can add as many tables as you would like. Some plans allow multiple databases, and some allow unlimited – you are limited by the disk space instead. Note the default when working with databases, if it is blue, it is clickable. Our Database has already been created. NEAUG Select by double clicking the database you want to work on Note the default when working with databases, if it is blue, it is clickable. CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 2
  • 3. In each table – you can add fields. Fields have Types, Length, Attributes, Null/NotNull, Default Values, they can be the key field, indexed, Unique or nothing. You can see each table – and some basic information about the tables – how many records, the size of the table When you are done at the top click on the Database link to see the tables that are in your databse. At the bottom you see a total # of table and the total size of your database. You can begin to add data manually to your new table. You can add additional tables and add data. You can also import Data and/or Export Data. You can print this view, or you can print the Data Dictionary. CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 3
  • 4. IMPORTING and EXPORTING What I want to do with this Web Site – is create an identical set of Tables – to be used for testing The originals will be renamed to the year The new set will be used for training, testing and updating. Select the database from the left-nav (Hint: Left-Nav’s are clickable – and not necessarly blue) Create a copy of TABLES: 1.Check the box of the TABLE you want to copy 2.Click Export 3. From the Export menu: 4. Select the table you want to copy 5. Make sure the radio button for SQL is selected Under Options – all unchecked Under Structure – all unchecked Under Data – Complete, Extended, Use Hex checked 6. Save File As: give it the name Save as file – CHECK – or it won’t save the file 7. Click GO Save the file in the location of choice 8. Edit the file Change the 4 locations where the TABLE name is – to the new TABLE name NOTE: auto_increment must be removed on all tables that have them – otherwise You are NOT creating a copy. You will have to go into the new tables and add the auto_increment back to each table IMPORTANT: If you had fields with the names of any reserved words: First, Last, Type, State – you have to re-name them before you can load table. You rename them in two places in the SQL: CREATE TABLE and INSERT INTO Members-2007 TABLE=NameFirst, NameLast, MemberType Members TABLE=First, Last, Type School-2007 TABLE=ST School TABLE=State 9. Save the file as the NEW TABLE NAME – leave the other as is in case you have to reload. Go back to the ADMINISTRATOR Click IMPORT Load the NEW TABLE Click GO If there are errors – correct them and repeat until you see Import has been successfully finished, 3 queries executed. NOTE: you can’t load a file with records being StudentNumber int(11) NOT NULL auto_increment, Members: `NameFirst` varchar(15) default NULL, `NameLast` varchar(15) default NULL, `SchoolID` varchar(4) default NULL, `GradYr` varchar(10) NOT NULL default '', `MemberType` varchar(10) default NULL, CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 4
  • 5. Editing Table in the Database Without ever writing any code, you can do CRUD to every table in every database you have on your host. CRUD = Create a new Record or Table Read = Click Browse folder TAB Update-pencil icon = change record Delete-red X icon = delete record STEPS: 1.) Go to your Web Hosting’s site: Examples: http://Hostica.com http://CrystalTech.com http://GoDaddy.com 2.) Go to the Login Screen and Log-in  security tip: ALWAYS glance up and make sure you are in an https:// session and that the URL name is your host. 3.) You usually have options at this point to manage: select DATABASES Domains, Web Options, Change Password, Change Account, Add Account, Account Settings, Platform Changes, e-Mail, FTP, Contact Billing info, Tools: Stats, DATABASES, Pre-installed Scripts, etc 4.) Select the Database you want to work with 5.) The LEFT-NAV has a list of tables click on one of them (the 2007’s are last years – leave them as history) 6.) Across the top of the screen you see BROWSE, Sturcture, SQL, Search, Insert, Export, Import, Operatons, Empty & Drop 7.) To view the records – select BROWSE. From here you can update and delete record 8.) To insert a new record: go to the SQL TAB, I use the INSERT INTO code from my loading tables .sql INSERT INTO `award` (`index`, `award`) VALUES (8, 'The JilMac Award'); Then click GO button You could also insert a bunch of records – and overwrite them INSERT INTO `award` (`index`, `award`) VALUES (9, ' '), (10, ‘ ‘), (11, ‘ ‘), (12, ‘ ‘), (13, ‘ ‘), (14, ‘ ‘), (15, ‘ ‘), (16, ‘ ‘), (17, ‘ ‘); Then click GO button CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 5
  • 6. CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 6
  • 7. Terms used in this presentation: Command Line: c:, in Windows to access the Command Line: Start>Run> type in “CMD” CRUD – Create, Read, Update, and Delete ……… using MySQL and phpMyAdmin Page 7