Structured Query Language
The Seeds Database

Throughout the remainder of this guide, you will create and manipulate a database of seeds using MySQL. Your first job is to define the table. To do this, go to your web server and browse to PHPMyAdmin. Create a new database (an option to do so is on the first page you see when PHPMyAdmin loads).

Data Dictionary

Field NameExplanationType
NameThe name of the plant.varchar(25)
TypeThe type of plant (eg hardy annual)varchar(40)
SeedThe number of seeds in a gramint(5)
WhereWhere the seeds should be plantedvarchar(11)
WhenThe month when the seeds should be plantedvarchar(9)
TimeThe time it takes the plant to germinateint(2)
FlowersThe month when the flowers start to appear on the plantvarchar(9)
VarietyThe variety of this particular plantvarchar(30)
DescriptionA description of the plantvarchar(100)
PriceThe cost of a gram of the seeds.float(2,2)

Notice that the data types are expressed differently in MySQL. A manual can be downloaded from the MySQL home page which will explain data types further. The purpose of including this here is to show how MySQL allows SQL statements for data definitionas well as data manipulation.

The SQL to create this is as follows,

CREATE TABLE `tblseeds` (
`name` VARCHAR( 25 ) NOT NULL ,
`type` VARCHAR( 40 ) NOT NULL ,
`seed` INT( 5 ) NOT NULL ,
`where` VARCHAR( 11 ) NOT NULL ,
`when` VARCHAR( 9 ) NOT NULL ,
`time` VARCHAR( 2 ) NOT NULL ,
`flowers` VARCHAR( 9 ) NOT NULL ,
`variety` VARCHAR( 30 ) NOT NULL ,
`description` VARCHAR( 100 ) NOT NULL ,
`price` FLOAT( 2, 2 ) NOT NULL ,
PRIMARY KEY ( `name` ) );

Create your table by typing or copying the SQL into the query window in PHPMyAdmin

Importing The Data

Click on the import link in PHPMyAdmin and choose to import the following file (which includes SQL statements to insert rows in the table).

Seeds Data SQL

If you click, rather than download the link, you should see the format for an INSERT query. Find a few more records to add (making things up if you have to) and create INSERT queries to add them to the table.