User Tools

Site Tools


en:web_development:databases:tables

This is an old revision of the document!


Web Development Lesson 7 - Databases

Tables

Objective

In this activity you will use a new tool to get a good look at the structure of a database.

Setup

There is nothing to set up in this exercise.

Tool: PHPMyAdmin

  • There are many databases available that all meet our needs, but we'll be using MySQL, which is one of the most popular for use with PHP.
  • To simplify access, we'll begin using PHPMyAdmin to administer the database. This tool also allows us to look at the contents of our database and to update information.
  • Navigate to phpmyadmin and login using the password stored on your computer.
  • You'll see a list of all the available databases on your left. Select the one belonging to your class.

Tables

  • You should now see a list of tables in the main pane of the site.
  • Click on the table called 'Marvel'.
  • Now you can see why it's called a table. It contains information that is presented in the form of a table, with column headings at the top and many rows of data below with each field containing data corresponding to its column.
  • Here you can edit, copy and delete data.
  • Above the table, you can see a menu of tabs. You're currently in the 'Browse' tab where you can see the data.
  • Below that is a yellow row showing the number of rows in the result and how long it took to process. At this stage you don't need to worry about the processing time, but that can be very important for optimising complex queries.
  • Below the yellow row is some text that says SELECT * FROM `marvel` . This is the SQL command that extracts the data. We'll spend more time looking at queries in the next activity.

Structure

  • Click on the 'Structure' tab.
  • Here we see a different table. It shows how the table is structured.
  • Each row corresponds to a field (column of data).
  • Two of the fields have type 'varchar' which means text. The number in brackets is the number of characters that are allowed.
  • 'first_appeared' is of type integer with length 4 for storing the year the character first appeared in Marvel comics.
  • 'hero_villain' is of type 'set' which means only specific values will be accepted. In this case, the values are 'Hero' and 'Villain'.
  • All columns have a 'No' value for 'Null' which means they must have a value. In some cases, you might be happy not to have any information for a certain field, in which case this would be marked 'Yes'.
  • Below this table, you'll see a section called 'Indexes'. An index is way of sorting the information, and every table must have at least one index, called the 'Primary' index that is unique. It would cause confusion and waste space if two rows could be the same.
  • In this table, the primary index is the 'character_name' field.
en/web_development/databases/tables.1640223198.txt.gz · Last modified: 2023/08/16 09:33 (external edit)