mysql and phpmyadmin
DESCRIPTION
MySQL and phpMyAdmin. Navigate to http://webapptst.lasalle.edu/pma and log on (username: pmadmin). The pma (phpMyAdmin) interface. Use the drop-down list to select the test database. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/1.jpg)
1
MySQL and phpMyAdmin
![Page 2: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/2.jpg)
2
Navigate to http://webapptst.lasalle.edu/pma and log on (username: pmadmin)
![Page 3: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/3.jpg)
3
The pma (phpMyAdmin) interface
![Page 4: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/4.jpg)
4
Use the drop-down list to select the test database
The mysql database is administrative, and we don’t have permissions for it. There are even more databases here that are not shown to this user.
The (3) after test indicates that currently the test database contains three tables.
![Page 5: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/5.jpg)
5
The test database in the pma interface
We see in the first column above a list of the tables in the test database, in the second column one finds buttons allowing particular actions on those tables, in the third column one can see the number of records in the table. The remaining columns will be of less interest to us as we begin.
![Page 6: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/6.jpg)
6
Table Actions
1. The browse button will show that all of the data in the table. (One can also update and delete the data here.)
2. The search button will set up a query based on that table.
3. The insert button allows one to add new records to the table.
4. The properties button allows one to the table’s structure (the metadata), i.e. what are the fields, their types, how long can they be, etc.
5. The empty button allows one to delete all of the records in the table. Be careful – it will give a little warning. (The table structure remains.)
6. The drop button allows one drop the table eliminating both data and metadata.
![Page 7: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/7.jpg)
7
Browse: Browse shows the data in the ArtWork table
The arrows show a few ways to get back to the test database page.
![Page 8: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/8.jpg)
8
Search: Search gives one a Query-By-Example interface to search the ArtWork table
![Page 9: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/9.jpg)
9
Insert: Insert provides a place for a user to enter data into the ArtWork table.
![Page 10: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/10.jpg)
10
Properties: Properties displays the design/structure of the ArtWork table.
![Page 11: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/11.jpg)
11
Allows one to write SQL queries for the test database.
![Page 12: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/12.jpg)
12
![Page 13: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/13.jpg)
13
Export ArtWork as CSV (comma-separated varaiables)
While the name “comma separated variables” suggested the fields should be separated (terminated) by a comma, there will be a problem if the data itself contains commas. Try to choose a delimiter that would not appear in the data.
![Page 14: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/14.jpg)
14
Export ArtWork as CSV (Cont.)
![Page 15: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/15.jpg)
15
CSV (actually semicolon-separated) file in Notepad
![Page 16: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/16.jpg)
16
Export ArtWork As XML
![Page 17: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/17.jpg)
17
It does not open the XML file, but to save it you can right click, choose View Source which will show the XML file in Notepad and it can be saved from there.
![Page 18: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/18.jpg)
18
![Page 19: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/19.jpg)
19
The result of the search is a table which you then chose to browse.
The search is accomplished by a SQL statement, which can be edited or turned into PHP code.
![Page 20: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/20.jpg)
20
This view provides a Query-By-Example interface. It is like the interface we encountered when we clicked on the search button associated with a table. But this interface is better suited for doing queries that involve multiple table (joins).
![Page 21: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/21.jpg)
21
Return to the test database main page, click on the search button next to the Artist table
Accepting the default settings yields a simple query that obtains all of the fields of all of the records.
![Page 22: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/22.jpg)
22
To choose only a few fields, hold down the control
key while clicking on the field names in the list.
One can “project” out only the fields one wants to see.
![Page 23: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/23.jpg)
23
One can “select” out records that satisfy a particular condition, choose a comparison operator and enter a value.
![Page 24: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/24.jpg)
24
The result page shows both the results of and the SQL for the query.
Result of query
SQL for query
![Page 25: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/25.jpg)
25
1.
2.
3.
We can click the Edit link and change aspects of the query.
![Page 26: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/26.jpg)
26
When we start using PHP pages to interact with the database, we will need PHP variables that correspond to SQL queries.
PMA provides this for us.
![Page 27: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/27.jpg)
27
We can produce a quick report on the results of the query by clicking on the Print view link.
The Export link leads to an interface like that for exporting a table.
![Page 28: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/28.jpg)
28
Ascending and Descending
We can put the artists in their birth order by selecting that field and choosing ascending (in this case).
![Page 29: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/29.jpg)
29
Greater than operatorInternally dates correspond to numbers (not text) and operators like “greater than or equal to” make sense. The difficulty is in knowing how the particular interface likes to format dates. Here we used a year-month-day format.
![Page 30: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/30.jpg)
30
Return to the test database main page and then click on the Query button.
![Page 31: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/31.jpg)
31
Use the drop-down list to select Artwork.* and Artist.* which means all
of the fields from both tables. Check that they should be displayed.
![Page 32: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/32.jpg)
32
Cartesian Product: The result lists every possible pair of artwork and
artist regardless of whether the artwork was by the artist.
![Page 33: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/33.jpg)
33
We create a “join” by selecting from the Cartesian product records in which the ArtistID (primary key) from Artist and ArtistID from ArtWork (foreign key) match.
![Page 34: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/34.jpg)
34
Result of the join.
![Page 35: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/35.jpg)
35
We can refine this query by choosing only the fields we want to see (projection).
![Page 36: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/36.jpg)
36
Result of “join” with projection.
![Page 37: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/37.jpg)
37
We can additional selection conditions.
![Page 38: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/38.jpg)
38
Even though this is a valid query, there is a limited amount of data and the query produces zero records. (The interface could be a little nicer at letting you know.)
![Page 39: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/39.jpg)
39
Pre-existing data file
• Suppose we already have a data file, and we do not want to enter the data using the Insert feature (which will be shown later) which allows us to enter data one record at a time.
• Then we can import data.
• The first step is to examine the data file and known its format.
![Page 40: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/40.jpg)
40
A file containing data on members of the
House of Representatives in a csv file
CSV files can be opened in Excel, though they are just text files (and can be open in Notepad as well)
![Page 41: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/41.jpg)
41
Create a table (give it a unique name).
![Page 42: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/42.jpg)
42
Enter fields – use order seen in data file.
![Page 43: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/43.jpg)
43
Table created
![Page 44: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/44.jpg)
44
Scroll to bottom of page to find Insert link.
![Page 45: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/45.jpg)
45
Click Browse button and find data file.
![Page 46: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/46.jpg)
46
Select delimiter information.
File was comma delimited. Fields were not “enclosed.”
![Page 47: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/47.jpg)
47
Scroll down to submit button
![Page 48: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/48.jpg)
48
Result page of import.
![Page 49: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/49.jpg)
49
Click on table and on Browse button. Slightly problem with first record.
![Page 50: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/50.jpg)
50
Select offending record and click Delete button.
![Page 51: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/51.jpg)
51
Warning message about Delete, also shows SQL for delete.
![Page 52: MySQL and phpMyAdmin](https://reader035.vdocuments.mx/reader035/viewer/2022062309/568159d7550346895dc725a2/html5/thumbnails/52.jpg)
52
Result of Delete