Web Design/Dynamic Websites/Creating Database Tables

< Web Design < Dynamic Websites
Web Design Creating Database Tables
This page is part of the Web Design project.

Before we can start using databases to create dynamic sites, we first need to create a database table! Since most cheap hosting sites support MySQL as their database server, we're going to use a special program that's been written by someone else to help us setup and administer our MySQL databases... it's called PhpMyAdmin.

From the PhpMyAdmin homepage:

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. 
Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, 
execute any SQL statement, manage keys on fields, manage privileges,export data into various 
formats and is available in 50 languages.

To take part in this activity, you'll need to know:

Getting aquainted with PhpMyAdmin

To start getting aquainted, there's a nice and simple PhpMyAdmin Tutorial that will get you started creating your first example table using PhpMyAdmin, and inserting data into it. Try it out and see how you find the experience!

After finishing the tutorial, you might like to reflect on your blog or elsewhere:

Creating your own table

Once you've finished with the example, we're ready to create our own database table! Referring back to an HTML form that you have created in the past (one that collects information from users, say for purchasing a product):

  1. write down the fields that will require to store this information in a database.
  2. Using PhpMyAdmin, create a new table in your database with a meaningful title (relevant to the data you're collecting, such as orders or enquiries etc)
  3. Specify the fields that you require to store your data (making sure that you choose the correct type, and that you've created a primary key etc).
  4. Insert 4 or 5 lines of sample data to your new table, each time noting the actual SQL code that is being used to add the information into your database.

More on Database Types

To re-cap some and pull together some of the things you've learned so far, read through Using MySQL down to (but not including unless you're keen) the Basic SQL Statement.

For the moment, it's important that you:

Phew! Enough for one day?! Next, we'll be finding out how we can connect to our database from PHP!

This article is issued from Wikiversity - version of the Tuesday, February 02, 2010. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.